build: simplify/fix test caching (#7084)

* build: rm unnecessary cache-on-main

* build: hardhat fan-in cache
This commit is contained in:
Zach Pomerantz 2023-08-08 16:48:27 -07:00 committed by GitHub
parent 097ef6a3df
commit b2dfb29f51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 41 deletions

@ -1,32 +0,0 @@
name: Cache on main
description: caches node_modules/.cache, but only saves from main
inputs:
path:
description: 'A list of files, directories, and wildcard patterns to cache and store'
required: true
key:
description: 'An explicit key for restoring and saving the cache'
required: true
restore-keys:
description: 'An ordered list of keys to use for restoring stale cache if no cache hit occured for key. Note `cache-hit` returns false in this case.'
required: false
# Many build steps have their own caches to improve subsequent build times.
# Build tools are configured to cache to node_modules/.cache, so they are cached independently of node_modules.
# Caches are saved every run *on main* (by keying on github.run_id), and the most recent available cache is loaded.
# Caches are not saved on feature branches because they have limited utility, and extend the runtime of the workflow.
# See https://jongleberry.medium.com/speed-up-your-ci-and-dx-with-node-modules-cache-ac8df82b7bb0.
runs:
using: composite
steps:
- uses: actions/cache/restore@v3
with:
path: ${{ inputs.path }}
key: ${{ inputs.key }}
restore-keys: ${{ inputs.restore-keys }}
- if: github.ref_name == 'main'
uses: actions/cache/save@v3
with:
path: ${{ inputs.path }}
key: ${{ inputs.key }}

@ -18,7 +18,7 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: ./.github/actions/setup - uses: ./.github/actions/setup
- uses: ./.github/actions/cache-on-main - uses: actions/cache@v3
with: with:
path: node_modules/.cache path: node_modules/.cache
key: ${{ runner.os }}-eslint-${{ github.run_id }} key: ${{ runner.os }}-eslint-${{ github.run_id }}
@ -35,7 +35,7 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: ./.github/actions/setup - uses: ./.github/actions/setup
- uses: ./.github/actions/cache-on-main - uses: actions/cache@v3
with: with:
path: node_modules/.cache path: node_modules/.cache
key: ${{ runner.os }}-tsc-${{ github.run_id }} key: ${{ runner.os }}-tsc-${{ github.run_id }}
@ -64,7 +64,7 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: ./.github/actions/setup - uses: ./.github/actions/setup
- uses: ./.github/actions/cache-on-main - uses: actions/cache@v3
with: with:
path: node_modules/.cache path: node_modules/.cache
key: ${{ runner.os }}-jest-${{ github.run_id }} key: ${{ runner.os }}-jest-${{ github.run_id }}
@ -86,7 +86,7 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: ./.github/actions/setup - uses: ./.github/actions/setup
- uses: ./.github/actions/cache-on-main - uses: actions/cache@v3
with: with:
path: node_modules/.swc path: node_modules/.swc
key: ${{ runner.os }}-swc-${{ github.run_id }} key: ${{ runner.os }}-swc-${{ github.run_id }}
@ -103,7 +103,7 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: ./.github/actions/setup - uses: ./.github/actions/setup
- uses: ./.github/actions/cache-on-main - uses: actions/cache@v3
with: with:
path: node_modules/.cache path: node_modules/.cache
key: ${{ runner.os }}-cypress-tsc-${{ github.run_id }} key: ${{ runner.os }}-cypress-tsc-${{ github.run_id }}
@ -131,7 +131,7 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: ./.github/actions/setup - uses: ./.github/actions/setup
- uses: ./.github/actions/cache-on-main - uses: actions/cache@v3
with: with:
path: /root/.cache/Cypress path: /root/.cache/Cypress
key: ${{ runner.os }}-cypress-${{ hashFiles('**/node_modules/cypress/package.json') }} key: ${{ runner.os }}-cypress-${{ hashFiles('**/node_modules/cypress/package.json') }}
@ -144,7 +144,7 @@ jobs:
name: build name: build
path: build path: build
- uses: ./.github/actions/cache-on-main - uses: actions/cache/restore@v3
with: with:
path: cache path: cache
key: ${{ runner.os }}-hardhat-${{ hashFiles('hardhat.config.js') }}-${{ github.run_id }} key: ${{ runner.os }}-hardhat-${{ hashFiles('hardhat.config.js') }}-${{ github.run_id }}
@ -179,12 +179,30 @@ jobs:
name: Cypress tests name: Cypress tests
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_TEST_REPORTER_WEBHOOK }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_TEST_REPORTER_WEBHOOK }}
- uses: actions/upload-artifact@v3
with:
name: hardhat-cache
path: cache
hardhat-cache:
needs: [cypress-test-matrix]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: hardhat-cache
path: cache
- uses: actions/cache/save@v3
with:
path: cache
key: ${{ runner.os }}-hardhat-${{ hashFiles('hardhat.config.js') }}-${{ github.run_id }}
cloud-typecheck: cloud-typecheck:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: ./.github/actions/setup - uses: ./.github/actions/setup
- uses: ./.github/actions/cache-on-main - uses: actions/cache@v3
with: with:
path: node_modules/.cache path: node_modules/.cache
key: ${{ runner.os }}-cloud-tsc-${{ github.run_id }} key: ${{ runner.os }}-cloud-tsc-${{ github.run_id }}
@ -202,7 +220,7 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: ./.github/actions/setup - uses: ./.github/actions/setup
- uses: ./.github/actions/cache-on-main - uses: actions/cache@v3
with: with:
path: node_modules/.cache path: node_modules/.cache
key: ${{ runner.os }}-cloud-jest-${{ github.run_id }} key: ${{ runner.os }}-cloud-jest-${{ github.run_id }}