Skip to content

Commit 195ce2d

Browse files
ehildenbclaude
andauthored
Optimize Nix release workflow (#4927)
The k-framework-binary (private, via kup) and k-framework (public, via cachix) publishes built the same three derivations on separate runners, recompiling K four times (2 jobs x 2 OS) for work that needs two builds. Fold them into one matrix job: the first publish populates the local Nix store so the second's nix build is an instant store hit. The two publishes stay independent (continue-on-error + if: always()) so a flaky upload to one cache neither blocks nor masks the other, and a final guard re-fails the job if either push failed, preserving the release gate the two separate jobs provided. Drop the removed cachix-release-dependencies from the release job's needs. --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 5cbb488 commit 195ce2d

1 file changed

Lines changed: 22 additions & 36 deletions

File tree

.github/workflows/release.yml

Lines changed: 22 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
gh release upload --repo runtimeverification/k --clobber "v${version}" "${tarball}"
4646
4747
cachix-release:
48-
name: 'k-framework-binary cachix release'
48+
name: 'Cachix release (binary cache `k-framework-binary` + dependency cache `k-framework`)'
4949
strategy:
5050
matrix:
5151
include:
@@ -79,7 +79,14 @@ jobs:
7979
with:
8080
name: k-framework-binary
8181

82-
- name: 'Publish K to k-framework-binary cache'
82+
# Both publishes build the same three derivations, so they run as sequential
83+
# steps on one runner: the first populates the local Nix store and the second is
84+
# a store hit. They run independently (continue-on-error) so a flaky upload to
85+
# one cache neither blocks nor masks the other, and a final guard fails the job
86+
# if either push failed.
87+
- name: 'Publish K to k-framework-binary cache (private)'
88+
id: binary
89+
continue-on-error: true
8390
uses: workflow/nix-shell-action@v3.3.2
8491
env:
8592
CACHIX_AUTH_TOKEN: '${{ secrets.CACHIX_PRIVATE_KFB_TOKEN }}'
@@ -91,7 +98,7 @@ jobs:
9198
script: |
9299
# Install kup
93100
export PATH="$(nix build github:runtimeverification/kup --no-link --json | jq -r '.[].outputs | to_entries[].value')/bin:$PATH"
94-
101+
95102
# Publish all three package variants using kup publish
96103
# Using public macOS runner has proven reliable for large file uploads
97104
kup publish --verbose k-framework-binary .#k --keep-days 180 || true
@@ -101,38 +108,9 @@ jobs:
101108
# kup/cachix pin visibility can be flaky; verify pins and narinfo via public API
102109
bash .github/scripts/check-cachix-pin.sh
103110
104-
cachix-release-dependencies:
105-
name: 'k-framework cachix release'
106-
strategy:
107-
matrix:
108-
include:
109-
- runner: ubuntu-24.04
110-
os: ubuntu-24.04
111-
- runner: macos-latest
112-
os: macos-15
113-
runs-on: ${{ matrix.runner }}
114-
timeout-minutes: 120
115-
steps:
116-
- name: 'Check out code'
117-
uses: actions/checkout@v4
118-
119-
- name: 'Install Nix'
120-
if: ${{ !startsWith(matrix.os, 'self') }}
121-
uses: cachix/install-nix-action@v31.5.1
122-
with:
123-
install_url: https://releases.nixos.org/nix/nix-2.30.1/install
124-
extra_nix_config: |
125-
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
126-
substituters = http://cache.nixos.org
127-
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
128-
129-
- name: 'Install Cachix'
130-
if: ${{ !startsWith(matrix.os, 'self') }}
131-
uses: cachix/cachix-action@v14
132-
with:
133-
name: k-framework-binary
134-
135-
- name: 'Build and cache K and K dependencies'
111+
- name: 'Build and cache K and K dependencies (public)'
112+
id: dependencies
113+
continue-on-error: true
136114
uses: workflow/nix-shell-action@v3
137115
env:
138116
GC_DONT_GC: 1
@@ -152,6 +130,14 @@ jobs:
152130
DRV_K_OPENSSL_PROCPS_SECP256K1=$(nix-store --query --deriver ${K_OPENSSL_PROCPS_SECP256K1})
153131
nix-store --query --requisites --include-outputs ${DRV_K_OPENSSL_PROCPS_SECP256K1} | cachix push k-framework
154132
133+
- name: 'Fail if either cachix publish failed'
134+
run: |
135+
binary='${{ steps.binary.outcome }}'
136+
dependencies='${{ steps.dependencies.outcome }}'
137+
echo "binary publish: ${binary}"
138+
echo "dependencies publish: ${dependencies}"
139+
[ "${binary}" = 'success' ] && [ "${dependencies}" = 'success' ]
140+
155141
pyk-build-wheel:
156142
name: 'Pyk: Build Python wheel'
157143
runs-on: ubuntu-24.04
@@ -313,7 +299,7 @@ jobs:
313299
name: 'Publish Release'
314300
runs-on: [self-hosted, linux, normal]
315301
environment: production
316-
needs: [cachix-release, cachix-release-dependencies, source-tarball, ubuntu-jammy, ubuntu-noble, set-release-id]
302+
needs: [cachix-release, source-tarball, ubuntu-jammy, ubuntu-noble, set-release-id]
317303
steps:
318304
- name: 'Check out code'
319305
uses: actions/checkout@v4

0 commit comments

Comments
 (0)