Skip to content

Commit

Permalink
try to improve action/cache
Browse files Browse the repository at this point in the history
  • Loading branch information
compojoom committed Dec 17, 2024
1 parent 166f6c8 commit b79a1a3
Showing 1 changed file with 72 additions and 22 deletions.
94 changes: 72 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,53 @@ jobs:
# This job installs dependencies once and caches them.
build:
runs-on: ubuntu-latest
outputs:
yarn-cache-key: ${{ steps.restore-yarn.outputs.cache-primary-key }}
nc-cache-key: ${{ steps.restore-nc.outputs.cache-primary-key }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Enable Corepack
shell: bash
run: corepack enable
- uses: actions/checkout@v4

- name: Setup Node & yarn
uses: actions/setup-node@v4
- name: Restore Yarn Cache
id: restore-yarn
uses: actions/cache/restore@v4
with:
node-version: '22.11.0' # jod
cache: 'yarn'

- name: Cache Yarn dependencies
uses: ./.github/actions/cache-deps
path: |
**/node_modules
${{ github.workspace }}/.yarn/install-state.gz
key: ${{ runner.os }}-web-core-modules-${{ hashFiles('**/package.json', '**/yarn.lock') }}

- name: Restore Nextjs/Cypress Cache
id: restore-nc
uses: actions/cache/restore@v4
with:
path: |
${{ github.workspace }}/.next/cache
/home/runner/.cache/Cypress
key: ${{ runner.os }}-nextjs-cypress-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
restore-keys: |
${{ runner.os }}-nextjs-cypress-
- name: Yarn install
shell: bash
run: yarn install --immutable
- name: Yarn after install
shell: bash
run: yarn after-install
if: steps.restore-yarn.outputs.cache-hit != 'true'
run: yarn install --immutable

- run: yarn after-install

- name: Save Yarn Cache
uses: actions/cache/save@v4
with:
path: |
**/node_modules
${{ github.workspace }}/.yarn/install-state.gz
key: ${{ steps.restore-yarn.outputs.cache-primary-key }}

- name: Save Nextjs/Cypress Cache
uses: actions/cache/save@v4
with:
path: |
${{ github.workspace }}/.next/cache
/home/runner/.cache/Cypress
key: ${{ steps.restore-nc.outputs.cache-primary-key }}

eslint:
needs: build
Expand All @@ -49,8 +73,21 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Cache Yarn dependencies
uses: ./.github/actions/cache-deps
- name: Restore Yarn Cache
uses: actions/cache/restore@v4
with:
path: |
**/node_modules
${{ github.workspace }}/.yarn/install-state.gz
key: ${{ needs.build.outputs.yarn-cache-key }}

- name: Restore Nextjs/Cypress Cache
uses: actions/cache/restore@v4
with:
path: |
${{ github.workspace }}/.next/cache
/home/runner/.cache/Cypress
key: ${{ needs.build.outputs.nc-cache-key }}

- uses: CatChen/[email protected]
with:
Expand All @@ -76,8 +113,21 @@ jobs:
shell: bash
run: corepack enable

- name: Cache Yarn dependencies
uses: ./.github/actions/cache-deps
- name: Restore Yarn Cache
uses: actions/cache/restore@v4
with:
path: |
**/node_modules
${{ github.workspace }}/.yarn/install-state.gz
key: ${{ needs.build.outputs.yarn-cache-key }}

- name: Restore Nextjs/Cypress Cache
uses: actions/cache/restore@v4
with:
path: |
${{ github.workspace }}/.next/cache
/home/runner/.cache/Cypress
key: ${{ needs.build.outputs.nc-cache-key }}

- name: Annotations and coverage report
uses: ArtiomTr/[email protected]
Expand Down

0 comments on commit b79a1a3

Please sign in to comment.