|
| 1 | +name: Warm caches |
| 2 | + |
| 3 | +# GitHub only shares caches saved on main with other branches, and the PR |
| 4 | +# workflows never run on main. This job seeds the caches they restore. |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: [main] |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: warm-caches-${{ github.ref }} |
| 13 | + cancel-in-progress: true |
| 14 | + |
| 15 | +jobs: |
| 16 | + linux: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + timeout-minutes: 15 |
| 19 | + permissions: |
| 20 | + contents: read |
| 21 | + steps: |
| 22 | + - name: Checkout |
| 23 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 24 | + with: |
| 25 | + persist-credentials: false |
| 26 | + |
| 27 | + - name: Setup pnpm |
| 28 | + uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9 |
| 29 | + |
| 30 | + - name: Setup Node.js |
| 31 | + uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 |
| 32 | + with: |
| 33 | + node-version: 22 |
| 34 | + cache: "pnpm" |
| 35 | + |
| 36 | + # No restore-keys: a fresh save per commit keeps the cache from growing |
| 37 | + # forever, at the cost of a cold build on every main push. |
| 38 | + - name: Cache turbo artifacts |
| 39 | + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 |
| 40 | + with: |
| 41 | + path: .turbo/cache |
| 42 | + key: turbo-${{ github.sha }} |
| 43 | + |
| 44 | + # Same key as code-storybook.yml's storybook job. |
| 45 | + - name: Cache Playwright browsers |
| 46 | + id: playwright-cache |
| 47 | + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 |
| 48 | + with: |
| 49 | + path: ~/.cache/ms-playwright |
| 50 | + key: playwright-chromium-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }} |
| 51 | + |
| 52 | + - name: Install dependencies |
| 53 | + run: pnpm install --frozen-lockfile |
| 54 | + env: |
| 55 | + SKIP_ELECTRON_REBUILD: "1" |
| 56 | + |
| 57 | + - name: Seed turbo cache (build + typecheck) |
| 58 | + run: | |
| 59 | + pnpm run build:deps |
| 60 | + pnpm run typecheck |
| 61 | +
|
| 62 | + - name: Install Playwright Chromium |
| 63 | + if: steps.playwright-cache.outputs.cache-hit != 'true' |
| 64 | + working-directory: apps/code |
| 65 | + run: pnpm exec playwright install chromium |
| 66 | + |
| 67 | + macos: |
| 68 | + runs-on: macos-latest |
| 69 | + timeout-minutes: 30 |
| 70 | + permissions: |
| 71 | + contents: read |
| 72 | + steps: |
| 73 | + - name: Checkout |
| 74 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 75 | + with: |
| 76 | + persist-credentials: false |
| 77 | + |
| 78 | + - name: Setup pnpm |
| 79 | + uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9 |
| 80 | + |
| 81 | + - name: Setup Node.js |
| 82 | + id: node |
| 83 | + uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 |
| 84 | + with: |
| 85 | + node-version: 22 |
| 86 | + cache: "pnpm" |
| 87 | + |
| 88 | + # Same keys as test.yml's integration-test job. |
| 89 | + - name: Cache Electron binary |
| 90 | + id: electron-cache |
| 91 | + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 |
| 92 | + with: |
| 93 | + path: ~/Library/Caches/electron |
| 94 | + key: electron-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }} |
| 95 | + |
| 96 | + - name: Cache Playwright browsers |
| 97 | + id: playwright-cache |
| 98 | + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 |
| 99 | + with: |
| 100 | + path: ~/Library/Caches/ms-playwright |
| 101 | + key: playwright-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }} |
| 102 | + |
| 103 | + # macOS minutes are 10x; do nothing when every cache is already warm. |
| 104 | + - name: Install dependencies |
| 105 | + if: >- |
| 106 | + steps.node.outputs.cache-hit != 'true' || |
| 107 | + steps.electron-cache.outputs.cache-hit != 'true' || |
| 108 | + steps.playwright-cache.outputs.cache-hit != 'true' |
| 109 | + # Electron's own postinstall fills ~/Library/Caches/electron; the sqlite |
| 110 | + # rebuild only touches node_modules, which is not cached, so skip it. |
| 111 | + run: pnpm install --frozen-lockfile |
| 112 | + env: |
| 113 | + SKIP_ELECTRON_REBUILD: "1" |
| 114 | + |
| 115 | + - name: Install Playwright Chromium |
| 116 | + if: steps.playwright-cache.outputs.cache-hit != 'true' |
| 117 | + run: pnpm --filter code exec playwright install chromium |
0 commit comments