Skip to content

Commit d63dce9

Browse files
committed
ci: cache runtime pack for live regression gate
1 parent b9a52cb commit d63dce9

File tree

2 files changed

+75
-1
lines changed

2 files changed

+75
-1
lines changed

.github/workflows/ci.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,54 @@ jobs:
119119
- name: Install pi CLI for runtime build
120120
run: npm install -g @mariozechner/pi-coding-agent
121121

122+
- name: Resolve pi CLI version
123+
id: pi-version
124+
run: |
125+
set -euo pipefail
126+
PI_VERSION=$(npm list -g @mariozechner/pi-coding-agent --depth=0 --json \
127+
| node -e 'const fs = require("node:fs"); const data = JSON.parse(fs.readFileSync(0, "utf8")); process.stdout.write(data.dependencies?.["@mariozechner/pi-coding-agent"]?.version ?? "unknown");')
128+
echo "version=$PI_VERSION" >> "$GITHUB_OUTPUT"
129+
echo "pi_version=$PI_VERSION"
130+
131+
- name: Restore runtime pack cache
132+
id: runtime-pack-cache
133+
uses: actions/cache/restore@v4
134+
with:
135+
path: "~/Library/Application Support/com.pi.work/runtime"
136+
key: runtime-pack-${{ runner.os }}-${{ runner.arch }}-pi-${{ steps.pi-version.outputs.version }}-${{ hashFiles('mise-tasks/runtime-build', 'runtime/init.sh', 'runtime/taskd.js') }}
137+
122138
- name: Install dependencies
123139
run: pnpm install --frozen-lockfile
124140

125141
- name: Run full live regression gate
126142
env:
127143
PIWORK_QEMU_ACCEL: tcg
144+
PIWORK_RUNTIME_CACHE_HIT: ${{ steps.runtime-pack-cache.outputs.cache-hit }}
128145
run: mise run test-regressions
129146

147+
- name: Check runtime pack cache save eligibility
148+
if: always()
149+
id: runtime-pack-cache-ready
150+
run: |
151+
set -euo pipefail
152+
RUNTIME_DIR="$HOME/Library/Application Support/com.pi.work/runtime"
153+
154+
if [[ -f "$RUNTIME_DIR/manifest.json" ]] \
155+
&& [[ -f "$RUNTIME_DIR/vmlinuz-virt" ]] \
156+
&& [[ -f "$RUNTIME_DIR/initramfs-virt-fast" ]]; then
157+
echo "ready=true" >> "$GITHUB_OUTPUT"
158+
exit 0
159+
fi
160+
161+
echo "ready=false" >> "$GITHUB_OUTPUT"
162+
163+
- name: Save runtime pack cache
164+
if: always() && steps.runtime-pack-cache.outputs.cache-hit != 'true' && steps.runtime-pack-cache-ready.outputs.ready == 'true'
165+
uses: actions/cache/save@v4
166+
with:
167+
path: "~/Library/Application Support/com.pi.work/runtime"
168+
key: runtime-pack-${{ runner.os }}-${{ runner.arch }}-pi-${{ steps.pi-version.outputs.version }}-${{ hashFiles('mise-tasks/runtime-build', 'runtime/init.sh', 'runtime/taskd.js') }}
169+
130170
- name: Collect integration diagnostics on failure
131171
if: failure()
132172
run: |

scripts/testing/run-regressions.sh

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,42 @@ set -euo pipefail
44
ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)
55
cd "$ROOT_DIR"
66

7+
runtime_dir() {
8+
if [[ "$(uname -s)" == "Darwin" ]]; then
9+
printf '%s\n' "$HOME/Library/Application Support/com.pi.work/runtime"
10+
else
11+
printf '%s\n' "${XDG_DATA_HOME:-$HOME/.local/share}/piwork/runtime"
12+
fi
13+
}
14+
15+
runtime_pack_is_ready() {
16+
local dir="$1"
17+
18+
[[ -f "$dir/manifest.json" ]] \
19+
&& [[ -f "$dir/vmlinuz-virt" ]] \
20+
&& [[ -f "$dir/initramfs-virt-fast" ]]
21+
}
22+
23+
ensure_runtime_pack() {
24+
local dir
25+
dir=$(runtime_dir)
26+
27+
if [[ "${PIWORK_RUNTIME_CACHE_HIT:-}" == "true" ]] && runtime_pack_is_ready "$dir"; then
28+
echo "[runtime-build] cache hit and runtime pack is ready at $dir; skipping rebuild"
29+
return
30+
fi
31+
32+
if [[ "${PIWORK_RUNTIME_CACHE_HIT:-}" == "true" ]]; then
33+
echo "[runtime-build] cache hit reported, but runtime pack is missing/incomplete at $dir; rebuilding"
34+
else
35+
echo "[runtime-build] cache miss; rebuilding runtime pack"
36+
fi
37+
38+
mise run runtime-build
39+
}
40+
741
pnpm exec svelte-kit sync
8-
mise run runtime-build
42+
ensure_runtime_pack
943
pnpm exec vitest run --minWorkers=1 --maxWorkers=1 \
1044
src/lib/__tests__/integration/runtime-steady-state.integration.test.ts \
1145
src/lib/__tests__/integration/journey-sequential.integration.test.ts

0 commit comments

Comments
 (0)