Skip to content

Commit

Permalink
chore(repo): Update CI caching strategy (#3566)
Browse files Browse the repository at this point in the history
Co-authored-by: Nikos Douvlis <[email protected]>
  • Loading branch information
tmilewski and nikosdouvlis authored Jun 17, 2024
1 parent 9100c1b commit f8c8a7c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .changeset/new-geese-watch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
17 changes: 15 additions & 2 deletions .github/actions/init/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,27 @@ runs:
- name: Setup NodeJS ${{ inputs.node-version }}
uses: actions/setup-node@v4
with:
cache: 'npm'
node-version: ${{ inputs.node-version }}
registry-url: ${{ inputs.registry-url }}

- name: Restore node_modules
id: cache-node-modules
uses: actions/cache/restore@v3
with:
path: node_modules
key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }}-${{ inputs.node-version }}

- name: Install NPM Dependencies
run: mkdir node_modules && npm ci --cache /home/runner/.npm --audit=false --fund=false --prefer-offline
if: steps.cache-node-modules.outputs.cache-hit != 'true' # Don't run if it's an **exact** match
run: mkdir node_modules && npm ci --audit=false --fund=false --prefer-offline && npm prune
shell: bash

- name: Save node_modules
uses: actions/cache/save@v3
with:
path: node_modules
key: ${{ steps.cache-node-modules.outputs.cache-primary-key }}

- name: Get Playwright Version
if: inputs.playwright-enabled == 'true'
shell: bash
Expand Down
23 changes: 11 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
turbo-token: ${{ secrets.TURBO_TOKEN }}

- name: List node_modules
run: npm ls
run: npm ls --package-lock-only
shell: bash

- name: Require Changeset
Expand Down Expand Up @@ -166,6 +166,16 @@ jobs:
fetch-depth: 0
show-progress: false

- name: Setup
id: config
uses: ./.github/actions/init
with:
node-version: ${{ env.NODE_VERSION }}
turbo-signature: ${{ secrets.TURBO_REMOTE_CACHE_SIGNATURE_KEY }}
turbo-team: ${{ vars.TURBO_TEAM }}
turbo-token: ${{ secrets.TURBO_TOKEN }}
playwright-enabled: true

- name: Task Status
id: task-status
env:
Expand All @@ -179,17 +189,6 @@ jobs:
(npx turbo-ignore --task=test:integration:${{ matrix.test-name }} --fallback=${{ github.base_ref || 'refs/heads/main' }}) || AFFECTED=1
echo "affected=${AFFECTED}" >> $GITHUB_OUTPUT
- name: Setup
if: ${{ steps.task-status.outputs.affected == '1' }}
id: config
uses: ./.github/actions/init
with:
node-version: ${{ env.NODE_VERSION }}
turbo-signature: ${{ secrets.TURBO_REMOTE_CACHE_SIGNATURE_KEY }}
turbo-team: ${{ vars.TURBO_TEAM }}
turbo-token: ${{ secrets.TURBO_TOKEN }}
playwright-enabled: true

- name: Verdaccio
if: ${{ steps.task-status.outputs.affected == '1' }}
uses: ./.github/actions/verdaccio
Expand Down

0 comments on commit f8c8a7c

Please sign in to comment.