From edb8bb6b54f60b71b79b9608c75c855e3e4fb10b Mon Sep 17 00:00:00 2001 From: Will Manning Date: Mon, 4 May 2026 14:14:36 -0400 Subject: [PATCH] Cache Bun install + Next.js build artifacts in CI Co-Authored-By: Claude Opus 4.7 (1M context) Signed-off-by: Will Manning --- .github/workflows/ci.yml | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5395414..ad5c978 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,8 +5,11 @@ on: branches: [main] pull_request: +# Cancel in-flight runs for the same workflow + ref. Including +# `github.workflow` in the key keeps this from colliding with any other +# workflow that happens to share a ref-based group prefix. concurrency: - group: ci-${{ github.ref }} + group: ci-${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true # Least-privilege: this workflow only reads the repo to lint/build/verify; it @@ -34,6 +37,31 @@ jobs: with: node-version-file: .nvmrc + # Cache Bun's resolved package store keyed on the lockfile hash. Cuts + # ~10s off `bun install` on a clean runner; the restore-key falls back + # to any prior cache from this OS so partial hits still help. + - name: Cache Bun install cache + uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 + with: + path: ~/.bun/install/cache + key: ${{ runner.os }}-bun-${{ hashFiles('bun.lock') }} + restore-keys: | + ${{ runner.os }}-bun- + + # Cache Next.js's incremental build output. Keyed on lockfile + commit + # SHA so the exact-key match is always per-commit fresh; restore-keys + # fall back to any previous build on the same lockfile, then any build + # on this OS — so most CI runs hit a cache and skip rebuilding + # unchanged webpack modules. + - name: Cache Next.js build cache + uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 + with: + path: ${{ github.workspace }}/.next/cache + key: ${{ runner.os }}-nextjs-${{ hashFiles('bun.lock') }}-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-nextjs-${{ hashFiles('bun.lock') }}- + ${{ runner.os }}-nextjs- + - name: Install run: bun install --frozen-lockfile