. #96
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test | |
# Many build steps have their own caches, so each job has its own cache 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 (by keying on github.run_id), and the most recent available cache is loaded. | |
# See https://jongleberry.medium.com/speed-up-your-ci-and-dx-with-node-modules-cache-ac8df82b7bb0. | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/setup | |
- uses: ./.github/actions/cache-on-main | |
with: | |
path: node_modules/.cache | |
key: ${{ runner.os }}-eslint-${{ github.run_id }} | |
restore-keys: ${{ runner.os }}-eslint- | |
- run: yarn lint | |
- if: failure() && github.ref_name == 'main' | |
uses: ./.github/actions/report | |
with: | |
name: Lint | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_TEST_REPORTER_WEBHOOK }} | |
typecheck: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/setup | |
- uses: ./.github/actions/cache-on-main | |
with: | |
path: node_modules/.cache | |
key: ${{ runner.os }}-tsc-${{ github.run_id }} | |
restore-keys: ${{ runner.os }}-tsc- | |
- run: yarn typecheck | |
- if: failure() && github.ref_name == 'main' | |
uses: ./.github/actions/report | |
with: | |
name: Typecheck | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_TEST_REPORTER_WEBHOOK }} | |
deps-tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/setup | |
- run: yarn yarn-deduplicate --strategy=highest --list --fail | |
- if: failure() && github.ref_name == 'main' | |
uses: ./.github/actions/report | |
with: | |
name: Dependency checks | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_TEST_REPORTER_WEBHOOK }} | |
unit-tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/setup | |
- uses: ./.github/actions/cache-on-main | |
with: | |
path: node_modules/.cache | |
key: ${{ runner.os }}-jest-${{ github.run_id }} | |
restore-keys: ${{ runner.os }}-jest- | |
- run: yarn test --coverage --maxWorkers=100% | |
- uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
fail_ci_if_error: false | |
flags: unit-tests | |
- if: failure() && github.ref_name == 'main' | |
uses: ./.github/actions/report | |
with: | |
name: Unit tests | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_TEST_REPORTER_WEBHOOK }} | |
build-e2e: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/setup | |
- uses: ./.github/actions/cache-on-main | |
with: | |
path: node_modules/.cache | |
key: ${{ runner.os }}-build-e2e-${{ github.run_id }} | |
restore-keys: ${{ runner.os }}-build-e2e- | |
- run: yarn build:e2e | |
env: | |
NODE_OPTIONS: "--max_old_space_size=4096" | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: build-e2e | |
path: build | |
if-no-files-found: error | |
# Allows for parallel re-runs of cypress tests without re-building. | |
cypress-rerun: | |
runs-on: ubuntu-latest | |
steps: | |
- run: exit 0 | |
cypress-test-matrix: | |
needs: [build-e2e, cypress-rerun] | |
runs-on: ubuntu-latest | |
container: cypress/browsers:node-18.14.1-chrome-111.0.5563.64-1-ff-111.0-edge-111.0.1661.43-1 | |
strategy: | |
fail-fast: false | |
matrix: | |
containers: [1, 2, 3, 4] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/setup | |
- uses: ./.github/actions/cache-on-main | |
with: | |
path: /root/.cache/Cypress | |
key: ${{ runner.os }}-cypress-${{ hashFiles('**/node_modules/cypress/package.json') }} | |
- run: | | |
yarn cypress install | |
yarn cypress info | |
- uses: actions/download-artifact@v3 | |
with: | |
name: build-e2e | |
path: build | |
- uses: ./.github/actions/cache-on-main | |
with: | |
path: cache | |
key: ${{ runner.os }}-hardhat-${{ hashFiles('hardhat.config.js') }}-${{ github.run_id }} | |
restore-keys: ${{ runner.os }}-hardhat-${{ hashFiles('hardhat.config.js') }}- | |
- uses: cypress-io/github-action@v4 | |
with: | |
install: false | |
record: true | |
parallel: true | |
start: yarn serve | |
wait-on: 'http://localhost:3000' | |
browser: chrome | |
group: e2e | |
env: | |
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
COMMIT_INFO_BRANCH: ${{ github.event.pull_request.head.ref || github.ref_name }} | |
COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title || github.event.head_commit.message }} | |
COMMIT_INFO_AUTHOR: ${{ github.event.sender.login || github.event.head_commit.author.login }} | |
# Cypress requires an email for filtering by author, but GitHub does not expose one. | |
# GitHub's public profile email can be deterministically produced from user id/login. | |
COMMIT_INFO_EMAIL: ${{ github.event.sender.id || github.event.head_commit.author.id }}+${{ github.event.sender.login || github.event.head_commit.author.login }}@users.noreply.github.com | |
COMMIT_INFO_SHA: ${{ github.event.pull_request.head.sha || github.event.head_commit.sha }} | |
COMMIT_INFO_TIMESTAMP: ${{ github.event.pull_request.updated_at || github.event.head_commit.timestamp }} | |
CYPRESS_PULL_REQUEST_ID: ${{ github.event.pull_request.number }} | |
CYPRESS_PULL_REQUEST_URL: ${{ github.event.pull_request.html_url }} | |
- uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
fail_ci_if_error: false | |
flags: e2e-tests | |
- if: failure() && github.ref_name == 'main' | |
uses: ./.github/actions/report | |
with: | |
name: Cypress tests | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_TEST_REPORTER_WEBHOOK }} |