Skip to content

Commit c5e5ae1

Browse files
senamakelclaude
andauthored
ci: speed up GitHub Actions builds (~14m → ~3-5m warm) (tinyhumansai#136)
* chore: add CI profile for faster compilation in Cargo.toml files - Introduced a new `[profile.ci]` section in both root and Tauri Cargo.toml files to optimize build settings for continuous integration. - Adjusted compilation parameters to prioritize speed over runtime performance, including reduced optimization level and enabled code generation units. * refactor(tests): update agent test setup to return temporary directory - Modified the `build_agent_with` function calls in the agent tests to return a temporary directory alongside the agent instance, improving resource management during tests. - Ensured consistency in test setup across multiple test functions. * chore: update .gitignore to include fastembed_cache - Added 'workflow' and '.fastembed_cache' to the .gitignore file to prevent unnecessary files from being tracked in the repository. * test: enhance dispatch routing tests with panic handling Updated the `dispatch_routes_memory_doc_ingest` test to use `AssertUnwindSafe` and `catch_unwind` for better handling of potential panics during execution. This ensures that the test verifies route existence even if the handler encounters a panic, improving robustness against shared state issues in concurrent tests. * ci: speed up builds with rust-cache, sccache, mold linker, and CI profile - Replace manual Cargo registry cache with Swatinem/rust-cache@v2 (caches target/ directories for both core and Tauri crates) - Add mozilla-actions/sccache for cross-branch compilation caching - Install mold linker on Linux for faster linking - Use --profile ci for sidecar build (opt-level 1, codegen-units 16) - Override release profile env vars for Tauri build with CI-tuned settings - Add --bundles none to CI build (skip unused deb/appimage packaging) - Restrict push triggers to main branch only (PRs already cover feature branches, preventing duplicate runs) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(ci): unset RUSTC_WRAPPER for cargo fmt to avoid sccache errors The sccache-action sets RUSTC_WRAPPER globally for the job. cargo fmt invokes rustc through sccache which fails if the GHA cache service is unavailable. Clear RUSTC_WRAPPER for fmt steps and remove redundant per-step env overrides (the action already sets them job-wide). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * refactor: implement Default trait for various structs and enums - Added Default implementations for ConnectionStatus, AgentBuilder, NativeRuntime, AutocompleteEngine, CliChannel, ActionTracker, SkillStatus, and ExtractionMode to streamline object initialization. - Simplified condition checks in several places by replacing map_or with is_some_and and is_none_or for better readability and performance. - Updated various instances of string handling in message sending to remove unnecessary conversions. This refactor enhances code clarity and consistency across the codebase. * style: clean up whitespace and improve code formatting - Removed unnecessary blank lines in several files to enhance code readability. - Simplified condition checks by consolidating method calls into single lines for better clarity. - Improved formatting in various functions to maintain consistency across the codebase. * fix(ci): use --bundles deb instead of unsupported none value Tauri CLI on this version doesn't support 'none' as a bundle type. Use 'deb' as the lightest single bundle to minimize packaging time. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat(ci): add Dockerfile and CI workflows for building and pushing Docker images - Introduced a Dockerfile to set up a CI environment with necessary dependencies for Tauri, Rust, Node.js, and sccache. - Created a new workflow to build and push the CI Docker image to GitHub Container Registry on main branch pushes. - Updated existing workflows to utilize the new Docker image for building and testing, enhancing consistency and efficiency in CI processes. * chore(ci): update container image references in CI workflows - Removed unnecessary permissions for packages in build, test, and typecheck workflows. - Updated container image references to use a specific digest instead of the latest tag for improved stability and reproducibility in CI processes. * fix(ci): use correct amd64 Docker image digest Previous digest was from arm64 build (Mac). Rebuilt with --platform linux/amd64 for GitHub Actions runners. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(ci): use tag instead of digest for Docker image reference GHCR doesn't support pulling OCI index manifests by digest reliably. Use the rust-1.93.0 tag which is pinned to a specific Rust version and resolves correctly on amd64 CI runners. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(ci): rename Docker package to openhuman_ci Move from nested ghcr.io/tinyhumansai/openhuman/ci-runner to ghcr.io/tinyhumansai/openhuman_ci to avoid GHCR nested package manifest resolution issues. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(ci): remove sccache env vars from container jobs sccache can't access the GHA cache API from inside a Docker container (missing ACTIONS_CACHE_URL/ACTIONS_RUNTIME_TOKEN). Swatinem/rust-cache already caches target/ which provides the main build speedup. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: update installer smoke workflow to trigger on main branch pushes - Added a trigger for the installer smoke workflow to run on pushes to the main branch, enhancing CI coverage for mainline changes. * fix: enhance Sentry DSN retrieval logic - Updated the Sentry DSN retrieval process to include an additional fallback option using `option_env!`, ensuring that the DSN can be sourced from both environment variables and optional configuration, improving robustness in observability setup. * chore: add OPENHUMAN_SENTRY_DSN to release workflow and example secrets - Included the OPENHUMAN_SENTRY_DSN variable in the release workflow configuration to enhance observability setup. - Updated the ci-secrets.example.json file to include a placeholder for OPENHUMAN_SENTRY_DSN, providing clarity for developers on required environment variables. --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8486a3b commit c5e5ae1

43 files changed

Lines changed: 253 additions & 237 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/Dockerfile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
FROM ubuntu:22.04
2+
3+
ENV DEBIAN_FRONTEND=noninteractive
4+
5+
# System deps for Tauri + mold linker + clang (for mold)
6+
RUN apt-get update && apt-get install -y --no-install-recommends \
7+
build-essential \
8+
curl \
9+
ca-certificates \
10+
git \
11+
pkg-config \
12+
libgtk-3-dev \
13+
libwebkit2gtk-4.1-dev \
14+
libappindicator3-dev \
15+
librsvg2-dev \
16+
patchelf \
17+
mold \
18+
clang \
19+
libssl-dev \
20+
&& rm -rf /var/lib/apt/lists/*
21+
22+
# Rust 1.93.0 with minimal profile + fmt/clippy
23+
ENV RUSTUP_HOME=/usr/local/rustup \
24+
CARGO_HOME=/usr/local/cargo \
25+
PATH="/usr/local/cargo/bin:$PATH"
26+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- \
27+
-y --default-toolchain 1.93.0 --profile minimal \
28+
-c rustfmt -c clippy \
29+
-t x86_64-unknown-linux-gnu
30+
31+
# Node.js 24.x + yarn
32+
RUN curl -fsSL https://deb.nodesource.com/setup_24.x | bash - \
33+
&& apt-get install -y --no-install-recommends nodejs \
34+
&& npm install -g yarn \
35+
&& rm -rf /var/lib/apt/lists/*
36+
37+
# sccache (pre-installed so the action only needs to configure it)
38+
RUN curl -fsSL https://github.com/mozilla/sccache/releases/download/v0.10.0/sccache-v0.10.0-x86_64-unknown-linux-musl.tar.gz \
39+
| tar xz -C /usr/local/bin --strip-components=1 sccache-v0.10.0-x86_64-unknown-linux-musl/sccache \
40+
&& chmod +x /usr/local/bin/sccache
41+
42+
# Verify installs
43+
RUN rustc --version && cargo --version && node --version && yarn --version && mold --version && sccache --version

.github/workflows/build.yml

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: Build
22

33
on:
44
push:
5+
branches: [main]
56
pull_request:
67

78
permissions:
@@ -16,45 +17,22 @@ jobs:
1617
build:
1718
name: Build Tauri App
1819
runs-on: ubuntu-22.04
20+
container:
21+
image: ghcr.io/tinyhumansai/openhuman_ci:rust-1.93.0
1922
steps:
2023
- name: Checkout code
2124
uses: actions/checkout@v4
2225
with:
2326
fetch-depth: 1
2427
submodules: true
2528

26-
- name: Setup Node.js 24.x
27-
uses: actions/setup-node@v4
29+
- name: Cache Rust build artifacts
30+
uses: Swatinem/rust-cache@v2
2831
with:
29-
node-version: 24.x
30-
cache: "yarn"
31-
32-
- name: Install Rust (rust-toolchain.toml)
33-
uses: dtolnay/rust-toolchain@1.93.0
34-
with:
35-
targets: x86_64-unknown-linux-gnu
36-
37-
- name: Install Tauri dependencies
38-
run: |
39-
sudo apt-get update
40-
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
41-
42-
# Skip first 7 lines of Cargo.lock (workspace package version bumps) so the key tracks dependency changes only
43-
- name: Cargo.lock fingerprint (deps only)
44-
id: cargo-lock-fingerprint
45-
shell: bash
46-
run: |
47-
echo "hash=$(tail -n +8 Cargo.lock | openssl dgst -sha256 | awk '{print $2}')" >> "$GITHUB_OUTPUT"
48-
49-
- name: Cache Cargo registry and git sources
50-
uses: actions/cache@v4
51-
with:
52-
path: |
53-
~/.cargo/registry
54-
~/.cargo/git
55-
key: ${{ runner.os }}-cargo-registry-${{ steps.cargo-lock-fingerprint.outputs.hash }}
56-
restore-keys: |
57-
${{ runner.os }}-cargo-registry-
32+
workspaces: |
33+
. -> target
34+
app/src-tauri -> target
35+
cache-on-failure: true
5836

5937
- name: Cache node modules
6038
id: yarn-cache
@@ -70,18 +48,23 @@ jobs:
7048
run: yarn install --frozen-lockfile
7149

7250
- name: Build sidecar core binary
73-
run: cargo build --manifest-path Cargo.toml --release --target x86_64-unknown-linux-gnu --bin openhuman-core
51+
run: cargo build --profile ci --target x86_64-unknown-linux-gnu --bin openhuman-core
7452

7553
- name: Stage sidecar for Tauri bundler
7654
run: |
7755
mkdir -p app/src-tauri/binaries
78-
cp target/x86_64-unknown-linux-gnu/release/openhuman-core app/src-tauri/binaries/openhuman-core-x86_64-unknown-linux-gnu
56+
cp target/x86_64-unknown-linux-gnu/ci/openhuman-core app/src-tauri/binaries/openhuman-core-x86_64-unknown-linux-gnu
7957
chmod +x app/src-tauri/binaries/openhuman-core-x86_64-unknown-linux-gnu
8058
8159
- name: Build Tauri app
8260
working-directory: app
8361
run: |
8462
TAURI_CONFIG_OVERRIDE='{"plugins":{"updater":{"active":false}}}'
85-
yarn tauri build -c "$TAURI_CONFIG_OVERRIDE"
63+
yarn tauri build -c "$TAURI_CONFIG_OVERRIDE" --bundles deb
8664
env:
8765
NODE_ENV: production
66+
CARGO_PROFILE_RELEASE_OPT_LEVEL: "1"
67+
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: "16"
68+
CARGO_PROFILE_RELEASE_LTO: "false"
69+
CARGO_PROFILE_RELEASE_STRIP: "true"
70+
CARGO_PROFILE_RELEASE_DEBUG: "false"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Build CI Docker Image
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- ".github/Dockerfile"
8+
- ".github/workflows/docker-ci-image.yml"
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: read
13+
packages: write
14+
15+
jobs:
16+
build-image:
17+
name: Build and push CI image
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Log in to GHCR
24+
uses: docker/login-action@v3
25+
with:
26+
registry: ghcr.io
27+
username: ${{ github.actor }}
28+
password: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- name: Build and push
31+
uses: docker/build-push-action@v6
32+
with:
33+
context: .github
34+
file: .github/Dockerfile
35+
push: true
36+
tags: |
37+
ghcr.io/tinyhumansai/openhuman_ci:latest
38+
ghcr.io/tinyhumansai/openhuman_ci:rust-1.93.0

.github/workflows/installer-smoke.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: Installer Smoke
22

33
on:
44
push:
5+
branches: [main]
56
pull_request:
67
workflow_dispatch:
78

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ jobs:
375375
MATRIX_TARGET: ${{ matrix.settings.target }}
376376
CORE_MANIFEST: ${{ steps.core-paths.outputs.core_manifest }}
377377
CORE_BIN_NAME: ${{ steps.core-paths.outputs.core_bin_name }}
378+
OPENHUMAN_SENTRY_DSN: ${{ vars.OPENHUMAN_SENTRY_DSN }}
378379

379380
- name: Stage sidecar for Tauri bundler
380381
shell: bash

.github/workflows/test.yml

Lines changed: 11 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: Test
22

33
on:
44
push:
5+
branches: [main]
56
pull_request:
67

78
permissions:
@@ -58,39 +59,21 @@ jobs:
5859
rust-tests:
5960
name: Rust Tests + Quality
6061
runs-on: ubuntu-22.04
62+
container:
63+
image: ghcr.io/tinyhumansai/openhuman_ci:rust-1.93.0
6164
steps:
6265
- name: Checkout code
6366
uses: actions/checkout@v4
6467
with:
6568
fetch-depth: 1
6669

67-
- name: Install Rust (rust-toolchain.toml)
68-
uses: dtolnay/rust-toolchain@1.93.0
70+
- name: Cache Rust build artifacts
71+
uses: Swatinem/rust-cache@v2
6972
with:
70-
components: rustfmt, clippy
71-
targets: x86_64-unknown-linux-gnu
72-
73-
- name: Install Tauri build dependencies
74-
run: |
75-
sudo apt-get update
76-
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
77-
78-
# Match build.yml: lockfile body only (skip workspace version header noise)
79-
- name: Cargo.lock fingerprint (deps only)
80-
id: cargo-lock-fingerprint
81-
shell: bash
82-
run: |
83-
echo "hash=$(tail -n +8 Cargo.lock | openssl dgst -sha256 | awk '{print $2}')" >> "$GITHUB_OUTPUT"
84-
85-
- name: Cache Cargo registry and git sources
86-
uses: actions/cache@v4
87-
with:
88-
path: |
89-
~/.cargo/registry
90-
~/.cargo/git
91-
key: ${{ runner.os }}-rust-test-cargo-${{ steps.cargo-lock-fingerprint.outputs.hash }}
92-
restore-keys: |
93-
${{ runner.os }}-rust-test-cargo-
73+
workspaces: |
74+
. -> target
75+
app/src-tauri -> target
76+
cache-on-failure: true
9477

9578
- name: Check formatting (cargo fmt)
9679
run: cargo fmt --all -- --check
@@ -102,52 +85,13 @@ jobs:
10285
run: cargo test -p openhuman
10386

10487
- name: Build sidecar core binary
105-
run: cargo build --manifest-path Cargo.toml --release --target x86_64-unknown-linux-gnu --bin openhuman-core
88+
run: cargo build --profile ci --target x86_64-unknown-linux-gnu --bin openhuman-core
10689

10790
- name: Stage sidecar for Tauri shell tests
10891
run: |
10992
mkdir -p app/src-tauri/binaries
110-
cp target/x86_64-unknown-linux-gnu/release/openhuman-core app/src-tauri/binaries/openhuman-core-x86_64-unknown-linux-gnu
93+
cp target/x86_64-unknown-linux-gnu/ci/openhuman-core app/src-tauri/binaries/openhuman-core-x86_64-unknown-linux-gnu
11194
chmod +x app/src-tauri/binaries/openhuman-core-x86_64-unknown-linux-gnu
11295
11396
- name: Test Tauri shell (OpenHuman)
11497
run: cargo test --manifest-path app/src-tauri/Cargo.toml
115-
116-
# e2e-macos:
117-
# name: E2E (macOS / Appium)
118-
# runs-on: macos-latest
119-
# timeout-minutes: 90
120-
# steps:
121-
# - name: Checkout code
122-
# uses: actions/checkout@v4
123-
# with:
124-
# fetch-depth: 1
125-
# submodules: recursive
126-
127-
# - name: Setup Node.js 24.x
128-
# uses: actions/setup-node@v4
129-
# with:
130-
# node-version: 24.x
131-
# cache: "yarn"
132-
133-
# - name: Install Rust (rust-toolchain.toml)
134-
# uses: dtolnay/rust-toolchain@1.93.0
135-
136-
# - name: Install dependencies
137-
# run: yarn install --frozen-lockfile
138-
139-
# - name: Ensure .env exists for E2E build
140-
# run: |
141-
# touch .env
142-
# touch app/.env
143-
144-
# - name: Install Appium and mac2 driver
145-
# run: |
146-
# npm install -g appium
147-
# appium driver install mac2
148-
149-
# - name: Build E2E app bundle
150-
# run: yarn workspace openhuman-app test:e2e:build
151-
152-
# - name: Run all E2E flows
153-
# run: yarn workspace openhuman-app test:e2e:all:flows

.github/workflows/typecheck.yml

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: Type Check
22

33
on:
44
push:
5+
branches: [main]
56
pull_request:
67

78
permissions:
@@ -61,37 +62,20 @@ jobs:
6162
rust-quality:
6263
name: Rust Quality (fmt + clippy)
6364
runs-on: ubuntu-22.04
65+
container:
66+
image: ghcr.io/tinyhumansai/openhuman_ci:rust-1.93.0
6467
steps:
6568
- name: Checkout code
6669
uses: actions/checkout@v4
6770
with:
6871
fetch-depth: 1
6972

70-
- name: Install Rust (rust-toolchain.toml)
71-
uses: dtolnay/rust-toolchain@1.93.0
73+
- name: Cache Rust build artifacts
74+
uses: Swatinem/rust-cache@v2
7275
with:
73-
components: rustfmt, clippy
74-
75-
- name: Install Tauri build dependencies
76-
run: |
77-
sudo apt-get update
78-
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
79-
80-
- name: Cargo.lock fingerprint (deps only)
81-
id: cargo-lock-fingerprint
82-
shell: bash
83-
run: |
84-
echo "hash=$(tail -n +8 Cargo.lock | openssl dgst -sha256 | awk '{print $2}')" >> "$GITHUB_OUTPUT"
85-
86-
- name: Cache Cargo registry and git sources
87-
uses: actions/cache@v4
88-
with:
89-
path: |
90-
~/.cargo/registry
91-
~/.cargo/git
92-
key: ${{ runner.os }}-cargo-registry-${{ steps.cargo-lock-fingerprint.outputs.hash }}
93-
restore-keys: |
94-
${{ runner.os }}-cargo-registry-
76+
workspaces: |
77+
. -> target
78+
cache-on-failure: true
9579

9680
- name: Check formatting (cargo fmt)
9781
run: cargo fmt --all -- --check

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,5 @@ tauri.key.pub
5757
/target/
5858
src-tauri/target/
5959

60-
workflow
60+
workflow
61+
.fastembed_cache

Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,13 @@ landlock = ["sandbox-landlock"]
120120
probe = ["dep:probe-rs"]
121121
rag-pdf = ["dep:pdf-extract"]
122122
whatsapp-web = ["dep:wa-rs", "dep:wa-rs-core", "dep:wa-rs-binary", "dep:wa-rs-proto", "dep:wa-rs-ureq-http", "dep:wa-rs-tokio-transport", "serde-big-array"]
123+
124+
# Fast CI builds: trade runtime perf for compile speed
125+
[profile.ci]
126+
inherits = "release"
127+
opt-level = 1
128+
codegen-units = 16
129+
lto = false
130+
incremental = false
131+
strip = true
132+
debug = false

app/src-tauri/Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,13 @@ env_logger = "0.11"
4040
# This feature is used for production builds or when a dev server is not specified, DO NOT REMOVE!!
4141
custom-protocol = ["tauri/custom-protocol"]
4242
sandbox-bubblewrap = []
43+
44+
# Fast CI builds: trade runtime perf for compile speed
45+
[profile.ci]
46+
inherits = "release"
47+
opt-level = 1
48+
codegen-units = 16
49+
lto = false
50+
incremental = false
51+
strip = true
52+
debug = false

0 commit comments

Comments
 (0)