ci: cache runtime pack for live regression gate #11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| changes: | |
| name: detect integration-impacting changes | |
| runs-on: ubuntu-latest | |
| outputs: | |
| integration: ${{ steps.filter.outputs.integration }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Detect changed paths | |
| id: filter | |
| uses: dorny/paths-filter@v3 | |
| with: | |
| filters: | | |
| integration: | |
| - "runtime/**" | |
| - "src-tauri/src/**" | |
| - "src/lib/components/layout/**" | |
| - "src/lib/services/runtimeService.ts" | |
| - "src/lib/stores/runtimeDebugStore.ts" | |
| - "src/lib/stores/taskStore.ts" | |
| - "src/lib/__tests__/integration/**" | |
| - "mise.toml" | |
| - "mise-tasks/test-*" | |
| - "scripts/testing/**" | |
| - "scripts/git-hooks/pre-push" | |
| - ".github/workflows/ci.yml" | |
| check: | |
| name: check (fast) | |
| runs-on: macos-14 | |
| timeout-minutes: 30 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: pnpm | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache Rust artifacts | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| workspaces: | | |
| src-tauri -> target | |
| - name: Setup mise | |
| uses: jdx/mise-action@v2 | |
| - name: Install sccache | |
| run: brew install sccache | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Run fast gate | |
| run: mise run check | |
| check-full: | |
| name: check-full (live regressions) | |
| runs-on: macos-14 | |
| timeout-minutes: 75 | |
| needs: [check, changes] | |
| if: needs.changes.outputs.integration == 'true' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: pnpm | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache Rust artifacts | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| workspaces: | | |
| src-tauri -> target | |
| - name: Setup mise | |
| uses: jdx/mise-action@v2 | |
| - name: Install runtime deps | |
| run: brew install qemu sccache | |
| - name: Install pi CLI for runtime build | |
| run: npm install -g @mariozechner/pi-coding-agent | |
| - name: Resolve pi CLI version | |
| id: pi-version | |
| run: | | |
| set -euo pipefail | |
| PI_VERSION=$(npm list -g @mariozechner/pi-coding-agent --depth=0 --json \ | |
| | 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");') | |
| echo "version=$PI_VERSION" >> "$GITHUB_OUTPUT" | |
| echo "pi_version=$PI_VERSION" | |
| - name: Restore runtime pack cache | |
| id: runtime-pack-cache | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: "~/Library/Application Support/com.pi.work/runtime" | |
| key: runtime-pack-${{ runner.os }}-${{ runner.arch }}-pi-${{ steps.pi-version.outputs.version }}-${{ hashFiles('mise-tasks/runtime-build', 'runtime/init.sh', 'runtime/taskd.js') }} | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Run full live regression gate | |
| env: | |
| PIWORK_QEMU_ACCEL: tcg | |
| PIWORK_RUNTIME_CACHE_HIT: ${{ steps.runtime-pack-cache.outputs.cache-hit }} | |
| run: mise run test-regressions | |
| - name: Check runtime pack cache save eligibility | |
| if: always() | |
| id: runtime-pack-cache-ready | |
| run: | | |
| set -euo pipefail | |
| RUNTIME_DIR="$HOME/Library/Application Support/com.pi.work/runtime" | |
| if [[ -f "$RUNTIME_DIR/manifest.json" ]] \ | |
| && [[ -f "$RUNTIME_DIR/vmlinuz-virt" ]] \ | |
| && [[ -f "$RUNTIME_DIR/initramfs-virt-fast" ]]; then | |
| echo "ready=true" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| echo "ready=false" >> "$GITHUB_OUTPUT" | |
| - name: Save runtime pack cache | |
| if: always() && steps.runtime-pack-cache.outputs.cache-hit != 'true' && steps.runtime-pack-cache-ready.outputs.ready == 'true' | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: "~/Library/Application Support/com.pi.work/runtime" | |
| key: runtime-pack-${{ runner.os }}-${{ runner.arch }}-pi-${{ steps.pi-version.outputs.version }}-${{ hashFiles('mise-tasks/runtime-build', 'runtime/init.sh', 'runtime/taskd.js') }} | |
| - name: Collect integration diagnostics on failure | |
| if: failure() | |
| run: | | |
| set -euo pipefail | |
| DEST="tmp/dev/ci-diagnostics" | |
| mkdir -p "$DEST" | |
| cp -f tmp/dev/piwork.integration.log "$DEST/" 2>/dev/null || true | |
| cp -f tmp/dev/piwork.log "$DEST/" 2>/dev/null || true | |
| MAC_VM_DIR="$HOME/Library/Application Support/com.pi.work/vm" | |
| LINUX_VM_DIR="$HOME/.local/share/com.pi.work/vm" | |
| if [ -d "$MAC_VM_DIR" ]; then | |
| mkdir -p "$DEST/vm-macos" | |
| cp -R "$MAC_VM_DIR/." "$DEST/vm-macos/" || true | |
| fi | |
| if [ -d "$LINUX_VM_DIR" ]; then | |
| mkdir -p "$DEST/vm-linux" | |
| cp -R "$LINUX_VM_DIR/." "$DEST/vm-linux/" || true | |
| fi | |
| { | |
| echo "=== Environment ===" | |
| uname -a || true | |
| echo | |
| echo "HOME=$HOME" | |
| echo | |
| echo "=== Dest tree ===" | |
| find "$DEST" -maxdepth 4 -print || true | |
| } > "$DEST/diagnostics.txt" | |
| - name: Upload integration diagnostics on failure | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: integration-diagnostics | |
| path: tmp/dev/ci-diagnostics | |
| if-no-files-found: ignore |