From b79a1a38bae146511e199d80fafc49c8b74c7daf Mon Sep 17 00:00:00 2001 From: Daniel Dimitrov Date: Tue, 17 Dec 2024 17:15:57 +0100 Subject: [PATCH] try to improve action/cache --- .github/workflows/ci.yml | 94 ++++++++++++++++++++++++++++++---------- 1 file changed, 72 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a0d664b17..cb97b833f8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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/eslint-suggestion-action@v4.1.7 with: @@ -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/jest-coverage-report-action@v2.3.1