Skip to content

Commit acac364

Browse files
committed
ci: Reduce runs of nix
Run only once nix files were changed. Also add caching.
1 parent 6d04195 commit acac364

2 files changed

Lines changed: 16 additions & 15 deletions

File tree

.github/workflows/nix-build.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
name: Nix Build Verification
22

3+
concurrency:
4+
group: nix-build-${{ github.ref }}
5+
cancel-in-progress: true
6+
37
on:
48
pull_request:
59
branches:
610
- main
711
paths:
812
- 'nix/**'
9-
- 'go.mod'
10-
- 'go.sum'
11-
- '**.go'
1213
- '.github/workflows/nix-build.yml'
1314
push:
1415
branches:
1516
- main
1617
paths:
1718
- 'nix/**'
18-
- 'go.mod'
19-
- 'go.sum'
20-
- '**.go'
2119
- '.github/workflows/nix-build.yml'
2220
workflow_dispatch:
2321

@@ -50,6 +48,9 @@ jobs:
5048
experimental-features = nix-command flakes
5149
accept-flake-config = true
5250
51+
- name: Set up Magic Nix Cache
52+
uses: DeterminateSystems/magic-nix-cache-action@v13
53+
5354
- name: Build with Nix
5455
run: |
5556
nix-build nix/default.nix --show-trace
@@ -87,6 +88,9 @@ jobs:
8788
extra_nix_config: |
8889
experimental-features = nix-command flakes
8990
91+
- name: Set up Magic Nix Cache
92+
uses: DeterminateSystems/magic-nix-cache-action@v13
93+
9094
- name: Check Nix formatting (nixfmt-rfc-style)
9195
run: |
9296
nix-shell -p nixfmt-rfc-style --run "nixfmt --check nix/package.nix nix/default.nix"

.github/workflows/nix-version-sync.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ jobs:
3434
extra_nix_config: |
3535
experimental-features = nix-command flakes
3636
37+
- name: Set up Magic Nix Cache
38+
uses: DeterminateSystems/magic-nix-cache-action@v13
39+
3740
- name: Determine version
3841
id: version
3942
run: |
@@ -96,14 +99,6 @@ jobs:
9699
sed -i "s|vendorHash = \"[^\"]*\";|vendorHash = \"sha256-$VENDOR_HASH\";|" nix/package.nix
97100
echo "Updated vendorHash in nix/package.nix"
98101
99-
- name: Verify build
100-
run: |
101-
echo "Building with updated hashes to verify..."
102-
nix-build nix/default.nix --show-trace
103-
104-
echo "Verifying binary..."
105-
result/bin/infer version
106-
107102
- name: Format Nix file
108103
run: |
109104
nix-shell -p nixfmt-rfc-style --run "nixfmt nix/package.nix"
@@ -123,9 +118,11 @@ jobs:
123118
- ✅ Updated `version` to `${{ steps.version.outputs.version }}`
124119
- ✅ Updated source `hash` to `sha256-${{ steps.source-hash.outputs.hash }}`
125120
- ✅ Updated `vendorHash` to `sha256-${{ steps.vendor-hash.outputs.hash }}`
126-
- ✅ Verified build succeeds
127121
- ✅ Formatted with nixfmt-rfc-style
128122
123+
The `Nix Build Verification` workflow runs on this PR and is the
124+
authoritative gate for verifying the updated hashes build cleanly.
125+
129126
### Verification
130127
```bash
131128
nix-build nix/default.nix

0 commit comments

Comments
 (0)