Skip to content

Commit 7ef92b8

Browse files
ci(ci): cache the released tarballs under their flake.lock pin (#243)
* ci(ci): cache the released tarballs under their flake.lock pin Every Mutation and CI job ran `nix build .#stryker-published`, 101-124 s each with nothing cached; on main's Mutation run three of those sat on the critical path. The new released-tarballs action restores `.sfs-deps/` as plain .tgz files keyed on the pin's rev and narHash plus the runner OS, and only builds with Nix (installing it if absent) and saves on a miss. `pnpm install --frozen-lockfile` still checks each tarball against the lockfile integrity, so a bad cache entry fails the install. * ci(ci): restore the released tarballs in the tarball-contents job too The Nix workflow's tarball-contents job still built .#stryker-published on every run. It now uses the released-tarballs action like CI and Mutation.
1 parent 7373776 commit 7ef92b8

4 files changed

Lines changed: 59 additions & 18 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Released tarballs
2+
description: >-
3+
Puts the released tarballs the lockfile installs from into `.sfs-deps/`, as plain `.tgz`
4+
files. They are cached under the `stryker-published` pin in flake.lock, so Nix builds them
5+
only when the pin moves. `pnpm install --frozen-lockfile` still checks each tarball against
6+
the integrity the lockfile records.
7+
8+
outputs:
9+
cache-hit:
10+
description: "'true' when `.sfs-deps/` came from the cache"
11+
value: ${{ steps.restore.outputs.cache-hit }}
12+
13+
runs:
14+
using: composite
15+
steps:
16+
- id: key
17+
name: Key of the pinned release
18+
shell: bash
19+
run: |
20+
pin=$(jq -er '.nodes["stryker-published"].locked | "\(.rev)-\(.narHash)"' flake.lock)
21+
echo "key=sfs-deps-$RUNNER_OS-$(sha256sum <<< "$pin" | cut -c1-64)" >> "$GITHUB_OUTPUT"
22+
23+
- id: restore
24+
uses: actions/cache/restore@v6
25+
with:
26+
path: .sfs-deps
27+
key: ${{ steps.key.outputs.key }}
28+
29+
- id: nix
30+
if: steps.restore.outputs.cache-hit != 'true'
31+
name: Is Nix installed
32+
shell: bash
33+
run: echo "present=$(command -v nix >/dev/null && echo true || echo false)" >> "$GITHUB_OUTPUT"
34+
35+
- if: steps.restore.outputs.cache-hit != 'true' && steps.nix.outputs.present != 'true'
36+
uses: cachix/install-nix-action@v31
37+
38+
- if: steps.restore.outputs.cache-hit != 'true'
39+
name: Build the tarballs of the pinned release
40+
shell: bash
41+
run: |
42+
published=$(nix build --no-link --print-out-paths .#stryker-published)
43+
rm -rf .sfs-deps
44+
mkdir .sfs-deps
45+
cp "$published"/*.tgz .sfs-deps/
46+
chmod u+w .sfs-deps/*.tgz
47+
48+
- if: steps.restore.outputs.cache-hit != 'true'
49+
uses: actions/cache/save@v6
50+
with:
51+
path: .sfs-deps
52+
key: ${{ steps.key.outputs.key }}

‎.github/workflows/ci.yml‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ jobs:
2727
- uses: cachix/install-nix-action@v31
2828
- name: dprint from the flake
2929
run: echo "$(nix build --no-link --print-out-paths .#dprint)/bin" >> "$GITHUB_PATH"
30-
- name: The released tarballs the lockfile installs from
31-
run: nix build .#stryker-published --out-link .sfs-deps
30+
- uses: ./.github/actions/released-tarballs
3231
- uses: pnpm/action-setup@v6
3332
- uses: actions/setup-node@v7
3433
with:
@@ -80,8 +79,7 @@ jobs:
8079
node-version: 24
8180
cache: pnpm
8281
- uses: cachix/install-nix-action@v31
83-
- name: The released tarballs the lockfile installs from
84-
run: nix build .#stryker-published --out-link .sfs-deps
82+
- uses: ./.github/actions/released-tarballs
8583
- run: pnpm install --frozen-lockfile
8684
- name: deno from the flake
8785
run: echo "$(nix build --no-link --print-out-paths .#deno)/bin" >> "$GITHUB_PATH"

‎.github/workflows/mutation.yml‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ jobs:
6262
with:
6363
node-version: 24
6464
cache: pnpm
65-
- uses: cachix/install-nix-action@v31
66-
- name: The released tarballs the lockfile installs from
67-
run: nix build .#stryker-published --out-link .sfs-deps
65+
- uses: ./.github/actions/released-tarballs
6866
- run: pnpm install --frozen-lockfile
6967

7068
- name: Restore the incremental report of the last run
@@ -118,9 +116,7 @@ jobs:
118116
with:
119117
node-version: 24
120118
cache: pnpm
121-
- uses: cachix/install-nix-action@v31
122-
- name: The released tarballs the lockfile installs from
123-
run: nix build .#stryker-published --out-link .sfs-deps
119+
- uses: ./.github/actions/released-tarballs
124120
- run: pnpm install --frozen-lockfile
125121

126122
- id: restore
@@ -167,9 +163,7 @@ jobs:
167163
with:
168164
node-version: 24
169165
cache: pnpm
170-
- uses: cachix/install-nix-action@v31
171-
- name: The released tarballs the lockfile installs from
172-
run: nix build .#stryker-published --out-link .sfs-deps
166+
- uses: ./.github/actions/released-tarballs
173167
- run: pnpm install --frozen-lockfile
174168
- uses: actions/download-artifact@v8
175169
with:
@@ -239,9 +233,7 @@ jobs:
239233
with:
240234
node-version: 24
241235
cache: pnpm
242-
- uses: cachix/install-nix-action@v31
243-
- name: The released tarballs the lockfile installs from
244-
run: nix build .#stryker-published --out-link .sfs-deps
236+
- uses: ./.github/actions/released-tarballs
245237
- run: pnpm install --frozen-lockfile
246238
- uses: actions/download-artifact@v8
247239
with:

‎.github/workflows/nix.yml‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ jobs:
4545
with:
4646
node-version: 24
4747
cache: pnpm
48-
- name: The released tarballs the lockfile installs from
49-
run: nix build .#stryker-published --out-link .sfs-deps
48+
- uses: ./.github/actions/released-tarballs
5049
- run: pnpm install --frozen-lockfile
5150
- run: nix build .#packages.x86_64-linux.workspace-tarballs --out-link tarballs
5251
- run: pnpm -r --if-present run build

0 commit comments

Comments
 (0)