diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index f87bf136..610426e4 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -58,14 +58,17 @@ jobs: node-version: 24 cache: pnpm - - name: cache Next.js build + # Turbopack persists its build cache here (turbopackFileSystemCacheForBuild). + # The key is deterministic (no commit SHA) so every PR restores the same + # entry — in practice the one `main` last saved, which is the only cache + # sibling PRs can all see. + - name: cache Turbopack build cache uses: actions/cache@v5 with: path: apps/readest-app/.next/cache - key: nextjs-web-${{ github.sha }}-${{ hashFiles('pnpm-lock.yaml') }} + key: turbo-build-web-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }} restore-keys: | - nextjs-web-${{ github.sha }}- - nextjs-web- + turbo-build-web-${{ runner.os }}- - name: install Dependencies working-directory: apps/readest-app @@ -89,9 +92,21 @@ jobs: run: | pnpm build-web && pnpm check:all + - name: cache playwright browsers + id: playwright-cache + uses: actions/cache@v5 + with: + path: ~/.cache/ms-playwright + key: playwright-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }} + - name: install playwright browsers working-directory: apps/readest-app - run: npx playwright install --with-deps chromium + run: | + if [ "${{ steps.playwright-cache.outputs.cache-hit }}" = 'true' ]; then + npx playwright install-deps chromium + else + npx playwright install --with-deps chromium + fi - name: run web e2e tests id: web_e2e @@ -122,20 +137,17 @@ jobs: node-version: 24 cache: pnpm - - name: cache Next.js build - uses: actions/cache@v5 - with: - path: apps/readest-app/.next/cache - key: nextjs-test-${{ github.sha }}-${{ hashFiles('pnpm-lock.yaml') }} - restore-keys: | - nextjs-test-${{ github.sha }}- - nextjs-test- - - name: install Dependencies working-directory: apps/readest-app run: | pnpm install && pnpm setup-vendors + - name: cache apt packages + uses: actions/cache@v5 + with: + path: /var/cache/apt/archives + key: apt-test-web-${{ runner.os }} + - name: install LuaJIT + busted (for koplugin tests) run: | sudo apt-get update @@ -149,9 +161,21 @@ jobs: sudo luarocks --lua-version=5.1 install busted sudo luarocks --lua-version=5.1 install lsqlite3complete + - name: cache playwright browsers + id: playwright-cache + uses: actions/cache@v5 + with: + path: ~/.cache/ms-playwright + key: playwright-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }} + - name: install playwright browsers working-directory: apps/readest-app - run: npx playwright install --with-deps chromium + run: | + if [ "${{ steps.playwright-cache.outputs.cache-hit }}" = 'true' ]; then + npx playwright install-deps chromium + else + npx playwright install --with-deps chromium + fi - name: run web tests working-directory: apps/readest-app @@ -180,14 +204,15 @@ jobs: node-version: 24 cache: pnpm - - name: cache Next.js build + # The tauri tests run `next dev`, whose Turbopack cache lives in + # `.next/dev/cache` (a different path from the `next build` cache). + - name: cache Turbopack dev cache uses: actions/cache@v5 with: - path: apps/readest-app/.next/cache - key: nextjs-tauri-${{ github.sha }}-${{ hashFiles('pnpm-lock.yaml') }} + path: apps/readest-app/.next/dev/cache + key: turbo-dev-tauri-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }} restore-keys: | - nextjs-tauri-${{ github.sha }}- - nextjs-tauri- + turbo-dev-tauri-${{ runner.os }}- - name: install Dependencies working-directory: apps/readest-app diff --git a/apps/readest-app/next.config.mjs b/apps/readest-app/next.config.mjs index eda4b3c7..cad5ea63 100644 --- a/apps/readest-app/next.config.mjs +++ b/apps/readest-app/next.config.mjs @@ -27,6 +27,13 @@ const nextConfig = { unoptimized: true, }, devIndicators: false, + experimental: { + // Persist Turbopack's compilation cache to `.next/` so CI can restore it + // between runs. Dev caching is on by default since Next 16.1; build + // caching is opt-in (beta). + turbopackFileSystemCacheForDev: true, + turbopackFileSystemCacheForBuild: true, + }, // Configure assetPrefix or else the server won't properly resolve your assets. assetPrefix: '', reactStrictMode: true,