refactor(ci): extract shared build setup into a composite action#1320
refactor(ci): extract shared build setup into a composite action#1320behdadmansouri wants to merge 1 commit into
Conversation
The build-qt and build-tauri jobs in release.yml duplicated ~60 lines of
identical setup steps each (Python, Node, Rust, caches, poetry/choco,
version detection). A future edit to any of those steps required two
in-sync changes and was easy to miss.
This PR introduces .github/actions/setup-aw-build/action.yml — a local
composite action — and replaces the duplicated steps in both jobs with a
single `uses: ./.github/actions/setup-aw-build` call.
What the action covers (shared between both jobs):
- actions/setup-python
- actions/setup-node (skip-webui input)
- dtolnay/rust-toolchain (skip-rust input)
- actions/cache for node_modules (configurable paths via node-cache-paths)
- actions/cache for cargo target (configurable paths via cargo-cache-paths)
- pip3 install poetry + choco install innosetup on Windows
- scripts/package/getversion.sh version detection
What stays in each job (intentionally not shared):
- APT system packages — Qt and Tauri require completely different
system libraries (X11/Qt vs GTK/WebKit)
- Build, test, and package steps — semantics differ between the two
No behaviour change. CI output is identical; only the source of the
steps moves.
Closes ActivityWatch#1219
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-node_modules- | ||
|
|
||
| - name: Cache cargo build | ||
| if: inputs.skip-rust != 'true' | ||
| uses: actions/cache@v5 | ||
| env: | ||
| cache-name: cargo-build-target | ||
| with: | ||
| path: ${{ inputs.cargo-cache-paths }} | ||
| key: ${{ runner.os }}-${{ env.cache-name }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('**/Cargo.lock') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-${{ env.cache-name }}-${{ steps.toolchain.outputs.rustc_hash }}- |
There was a problem hiding this comment.
Cache key regression:
matrix.os → runner.os changes key namespace
The original steps keyed caches off ${{ matrix.os }} (e.g. ubuntu-24.04, windows-latest, macos-latest), but the composite action uses ${{ runner.os }} (e.g. Linux, Windows, macOS). These are different strings, so every existing cached entry will be missed on the first run after this PR lands. This directly contradicts the PR test plan item "Cache hit rate is unchanged from before." The fix is to thread matrix.os through as an input (e.g. runner-os) and use that in both key: and restore-keys:.
| - name: Set up Rust | ||
| if: inputs.skip-rust != 'true' | ||
| uses: dtolnay/rust-toolchain@master | ||
| id: toolchain | ||
| with: | ||
| toolchain: stable |
There was a problem hiding this comment.
dtolnay/rust-toolchain@master pins to a moving target
Using @master means the action can silently pull in breaking changes or a different toolchain resolver on every run. The original code in release.yml already used @master, so this is a pre-existing pattern, but consolidating into a shared composite action makes the blast radius larger — a single @master change now affects both build-qt and build-tauri. Consider pinning to a specific commit SHA or tag for reproducibility.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Summary
Closes #1219
PR #1313 merged the three separate workflow files (
dev-release.yml,build.yml,build-tauri.yml) into a singlerelease.yml. This follow-up addresses the remaining duplication: thebuild-qtandbuild-taurijobs still share ~60 identical lines of setup steps each, requiring two in-sync edits for any toolchain or cache change.This PR introduces
.github/actions/setup-aw-build/action.yml— a local composite action — and replaces the duplicated steps in both jobs with a singleusescall.What the composite action handles (genuinely shared):
actions/setup-pythonactions/setup-node(controlled byskip-webuiinput)dtolnay/rust-toolchain(controlled byskip-rustinput)actions/cachefornode_modules(paths configurable vianode-cache-pathsinput)actions/cachefor Cargo target directory (paths configurable viacargo-cache-pathsinput)pip3 install poetry+choco install innosetupon Windowsscripts/package/getversion.shversion detection +$GITHUB_ENVexportWhat stays in each job (intentionally not shared):
No behaviour change. CI output is identical to before; only the source of the steps moves.
Test plan
version-with-voutput is visible in both build job logs