2022-07-02 01:05:37 +03:00
|
|
|
name: Test
|
2022-06-16 16:17:48 +03:00
|
|
|
|
2023-04-17 19:28:00 +03:00
|
|
|
# Many build steps have their own caches, so each job has its own cache to improve subsequent build times.
|
2023-06-22 21:48:42 +03:00
|
|
|
# Build tools are configured to cache to node_modules/.cache, so they are cached independently of node_modules.
|
2023-05-10 01:49:53 +03:00
|
|
|
# Caches are saved every run (by keying on github.run_id), and the most recent available cache is loaded.
|
2023-04-17 19:28:00 +03:00
|
|
|
# See https://jongleberry.medium.com/speed-up-your-ci-and-dx-with-node-modules-cache-ac8df82b7bb0.
|
|
|
|
|
2022-06-16 16:17:48 +03:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
2023-07-06 00:42:43 +03:00
|
|
|
- releases/staging
|
2022-06-16 16:17:48 +03:00
|
|
|
pull_request:
|
2023-10-05 22:12:21 +03:00
|
|
|
workflow_dispatch:
|
2022-06-16 16:17:48 +03:00
|
|
|
|
|
|
|
jobs:
|
2022-07-02 01:05:37 +03:00
|
|
|
lint:
|
2022-06-17 00:42:18 +03:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
2022-07-02 01:05:37 +03:00
|
|
|
- uses: ./.github/actions/setup
|
2023-08-09 02:48:27 +03:00
|
|
|
- uses: actions/cache@v3
|
2023-04-17 19:28:00 +03:00
|
|
|
with:
|
|
|
|
path: node_modules/.cache
|
2023-06-23 21:40:58 +03:00
|
|
|
key: ${{ runner.os }}-eslint-${{ github.run_id }}
|
|
|
|
restore-keys: ${{ runner.os }}-eslint-
|
2022-07-02 01:05:37 +03:00
|
|
|
- run: yarn lint
|
2023-05-12 19:19:20 +03:00
|
|
|
- if: failure() && github.ref_name == 'main'
|
|
|
|
uses: ./.github/actions/report
|
|
|
|
with:
|
|
|
|
name: Lint
|
2023-05-24 20:15:28 +03:00
|
|
|
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_TEST_REPORTER_WEBHOOK }}
|
2023-04-13 22:43:47 +03:00
|
|
|
|
|
|
|
typecheck:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- uses: ./.github/actions/setup
|
2023-08-09 02:48:27 +03:00
|
|
|
- uses: actions/cache@v3
|
2023-04-17 19:28:00 +03:00
|
|
|
with:
|
|
|
|
path: node_modules/.cache
|
2023-06-23 21:40:58 +03:00
|
|
|
key: ${{ runner.os }}-tsc-${{ github.run_id }}
|
|
|
|
restore-keys: ${{ runner.os }}-tsc-
|
2023-04-13 22:43:47 +03:00
|
|
|
- run: yarn typecheck
|
2023-05-12 19:19:20 +03:00
|
|
|
- if: failure() && github.ref_name == 'main'
|
|
|
|
uses: ./.github/actions/report
|
|
|
|
with:
|
|
|
|
name: Typecheck
|
2023-05-24 20:15:28 +03:00
|
|
|
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_TEST_REPORTER_WEBHOOK }}
|
2022-07-14 18:28:51 +03:00
|
|
|
|
2022-07-13 18:31:19 +03:00
|
|
|
deps-tests:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- uses: ./.github/actions/setup
|
2022-11-24 20:23:56 +03:00
|
|
|
- run: yarn yarn-deduplicate --strategy=highest --list --fail
|
2023-05-12 19:19:20 +03:00
|
|
|
- if: failure() && github.ref_name == 'main'
|
|
|
|
uses: ./.github/actions/report
|
|
|
|
with:
|
|
|
|
name: Dependency checks
|
2023-05-24 20:15:28 +03:00
|
|
|
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_TEST_REPORTER_WEBHOOK }}
|
2022-06-17 00:42:18 +03:00
|
|
|
|
2022-07-02 01:05:37 +03:00
|
|
|
unit-tests:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- uses: ./.github/actions/setup
|
2023-08-09 02:48:27 +03:00
|
|
|
- uses: actions/cache@v3
|
2023-04-17 19:28:00 +03:00
|
|
|
with:
|
|
|
|
path: node_modules/.cache
|
2023-06-23 21:40:58 +03:00
|
|
|
key: ${{ runner.os }}-jest-${{ github.run_id }}
|
|
|
|
restore-keys: ${{ runner.os }}-jest-
|
2023-04-28 00:34:37 +03:00
|
|
|
- run: yarn test --coverage --maxWorkers=100%
|
2023-02-02 23:06:15 +03:00
|
|
|
- uses: codecov/codecov-action@v3
|
|
|
|
with:
|
|
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
|
|
fail_ci_if_error: false
|
2023-04-24 22:44:41 +03:00
|
|
|
flags: unit-tests
|
2023-05-12 19:19:20 +03:00
|
|
|
- if: failure() && github.ref_name == 'main'
|
|
|
|
uses: ./.github/actions/report
|
|
|
|
with:
|
|
|
|
name: Unit tests
|
2023-05-24 20:15:28 +03:00
|
|
|
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_TEST_REPORTER_WEBHOOK }}
|
2022-06-17 00:42:18 +03:00
|
|
|
|
2023-08-08 20:38:37 +03:00
|
|
|
build:
|
2023-04-21 01:34:09 +03:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- uses: ./.github/actions/setup
|
2023-08-09 02:48:27 +03:00
|
|
|
- uses: actions/cache@v3
|
2023-04-21 01:34:09 +03:00
|
|
|
with:
|
2023-08-08 20:38:37 +03:00
|
|
|
path: node_modules/.swc
|
|
|
|
key: ${{ runner.os }}-swc-${{ github.run_id }}
|
|
|
|
restore-keys: ${{ runner.os }}-swc-
|
|
|
|
- run: yarn build
|
2023-06-09 21:00:27 +03:00
|
|
|
- uses: actions/upload-artifact@v3
|
2023-04-21 01:34:09 +03:00
|
|
|
with:
|
2023-08-08 20:38:37 +03:00
|
|
|
name: build
|
2023-04-21 01:34:09 +03:00
|
|
|
path: build
|
|
|
|
if-no-files-found: error
|
|
|
|
|
2023-08-02 08:13:19 +03:00
|
|
|
cypress-typecheck:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- uses: ./.github/actions/setup
|
2023-08-09 02:48:27 +03:00
|
|
|
- uses: actions/cache@v3
|
2023-08-02 08:13:19 +03:00
|
|
|
with:
|
|
|
|
path: node_modules/.cache
|
|
|
|
key: ${{ runner.os }}-cypress-tsc-${{ github.run_id }}
|
|
|
|
restore-keys: ${{ runner.os }}-cypress-tsc-
|
|
|
|
- run: yarn typecheck:cypress
|
|
|
|
- if: failure() && github.ref_name == 'main'
|
|
|
|
uses: ./.github/actions/report
|
|
|
|
with:
|
|
|
|
name: Cypress typecheck
|
|
|
|
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_TEST_REPORTER_WEBHOOK }}
|
|
|
|
|
2023-04-27 03:02:53 +03:00
|
|
|
# Allows for parallel re-runs of cypress tests without re-building.
|
|
|
|
cypress-rerun:
|
2023-03-07 20:27:20 +03:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2023-04-27 03:02:53 +03:00
|
|
|
- run: exit 0
|
2023-03-07 20:27:20 +03:00
|
|
|
|
2023-04-17 19:28:00 +03:00
|
|
|
cypress-test-matrix:
|
2023-08-08 20:38:37 +03:00
|
|
|
needs: [build, cypress-rerun]
|
2023-03-17 23:09:20 +03:00
|
|
|
runs-on: ubuntu-latest
|
2023-04-17 19:28:00 +03:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
containers: [1, 2, 3, 4]
|
2023-03-17 23:09:20 +03:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- uses: ./.github/actions/setup
|
2023-08-09 02:48:27 +03:00
|
|
|
- uses: actions/cache@v3
|
2023-03-17 23:09:20 +03:00
|
|
|
with:
|
|
|
|
path: /root/.cache/Cypress
|
2023-05-19 16:32:42 +03:00
|
|
|
key: ${{ runner.os }}-cypress-${{ hashFiles('**/node_modules/cypress/package.json') }}
|
2023-04-17 19:28:00 +03:00
|
|
|
- run: |
|
2023-03-17 23:09:20 +03:00
|
|
|
yarn cypress install
|
|
|
|
yarn cypress info
|
|
|
|
|
2023-04-17 19:28:00 +03:00
|
|
|
- uses: actions/download-artifact@v3
|
2022-06-17 00:42:18 +03:00
|
|
|
with:
|
2023-08-08 20:38:37 +03:00
|
|
|
name: build
|
2022-06-17 00:42:18 +03:00
|
|
|
path: build
|
2022-06-16 16:17:48 +03:00
|
|
|
|
2023-08-09 02:48:27 +03:00
|
|
|
- uses: actions/cache/restore@v3
|
2023-05-25 21:53:39 +03:00
|
|
|
with:
|
|
|
|
path: cache
|
|
|
|
key: ${{ runner.os }}-hardhat-${{ hashFiles('hardhat.config.js') }}-${{ github.run_id }}
|
|
|
|
restore-keys: ${{ runner.os }}-hardhat-${{ hashFiles('hardhat.config.js') }}-
|
|
|
|
|
2022-06-17 00:42:18 +03:00
|
|
|
- uses: cypress-io/github-action@v4
|
2022-06-16 16:17:48 +03:00
|
|
|
with:
|
2022-06-17 00:42:18 +03:00
|
|
|
install: false
|
2023-05-19 16:32:42 +03:00
|
|
|
record: true
|
|
|
|
parallel: true
|
2022-06-16 16:17:48 +03:00
|
|
|
start: yarn serve
|
|
|
|
wait-on: 'http://localhost:3000'
|
2023-07-05 23:30:54 +03:00
|
|
|
browser: electron
|
2023-05-19 16:32:42 +03:00
|
|
|
group: e2e
|
2023-07-07 19:41:20 +03:00
|
|
|
spec: ${{ github.ref_name == 'releases/staging' && 'cypress/{e2e,staging}/**/*.test.ts' || 'cypress/e2e/**/*.test.ts' }}
|
2022-06-16 16:17:48 +03:00
|
|
|
env:
|
2022-06-16 17:08:25 +03:00
|
|
|
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
2022-07-02 01:12:51 +03:00
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
2023-05-19 16:32:42 +03:00
|
|
|
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 }}
|
2023-05-19 22:24:11 +03:00
|
|
|
- if: failure() && github.ref_name == 'main'
|
|
|
|
uses: ./.github/actions/report
|
|
|
|
with:
|
|
|
|
name: Cypress tests
|
2023-05-24 20:15:28 +03:00
|
|
|
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_TEST_REPORTER_WEBHOOK }}
|
2023-07-06 00:42:43 +03:00
|
|
|
|
2023-08-09 02:48:27 +03:00
|
|
|
- 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 }}
|
|
|
|
|
2023-07-25 22:12:13 +03:00
|
|
|
cloud-typecheck:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- uses: ./.github/actions/setup
|
2023-08-09 02:48:27 +03:00
|
|
|
- uses: actions/cache@v3
|
2023-07-25 22:12:13 +03:00
|
|
|
with:
|
|
|
|
path: node_modules/.cache
|
|
|
|
key: ${{ runner.os }}-cloud-tsc-${{ github.run_id }}
|
|
|
|
restore-keys: ${{ runner.os }}-cloud-tsc-
|
|
|
|
- run: yarn typecheck:cloud
|
|
|
|
- if: failure() && github.ref_name == 'main'
|
|
|
|
uses: ./.github/actions/report
|
|
|
|
with:
|
|
|
|
name: Cloud typecheck
|
|
|
|
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_TEST_REPORTER_WEBHOOK }}
|
|
|
|
|
|
|
|
cloud-tests:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- uses: ./.github/actions/setup
|
2023-08-09 02:48:27 +03:00
|
|
|
- uses: actions/cache@v3
|
2023-07-25 22:12:13 +03:00
|
|
|
with:
|
|
|
|
path: node_modules/.cache
|
|
|
|
key: ${{ runner.os }}-cloud-jest-${{ github.run_id }}
|
|
|
|
restore-keys: ${{ runner.os }}-cloud-jest-
|
2023-09-08 20:53:22 +03:00
|
|
|
# Ignore start:cloud output so it doesn't flood the test output.
|
|
|
|
# Only use 1 worker for testing, as the other is used to run start:cloud (the proxy server under test).
|
|
|
|
- run: yarn start-server-and-test 'yarn start:cloud >/dev/null' 3000 'yarn test:cloud --coverage --maxWorkers=1'
|
2023-08-17 18:30:56 +03:00
|
|
|
- uses: codecov/codecov-action@v3
|
|
|
|
with:
|
|
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
|
|
fail_ci_if_error: false
|
|
|
|
flags: cloud-tests
|
2023-07-25 22:12:13 +03:00
|
|
|
|
2023-07-06 00:42:43 +03:00
|
|
|
pre:
|
2023-07-07 18:47:32 +03:00
|
|
|
if: ${{ github.ref_name == 'main' || github.ref_name == 'releases/staging' }}
|
2023-07-06 00:42:43 +03:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/github-script@v6.4.1
|
|
|
|
with:
|
|
|
|
script: |
|
|
|
|
github.rest.repos.createCommitStatus({
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
2023-07-07 20:48:00 +03:00
|
|
|
sha: context.sha,
|
2023-07-06 00:42:43 +03:00
|
|
|
state: 'pending',
|
|
|
|
context: 'Test / promotion',
|
|
|
|
description: 'Running tests...',
|
|
|
|
target_url: 'https://github.com/Uniswap/interface/actions/runs/' + context.runId
|
|
|
|
})
|
|
|
|
|
|
|
|
post:
|
2023-07-07 18:47:32 +03:00
|
|
|
if: ${{ github.ref_name == 'main' || github.ref_name == 'releases/staging' }}
|
2023-09-08 20:53:22 +03:00
|
|
|
needs: [pre, lint, typecheck, deps-tests, unit-tests, cypress-test-matrix, cloud-tests]
|
2023-07-06 00:42:43 +03:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/github-script@v6.4.1
|
|
|
|
with:
|
|
|
|
script: |
|
|
|
|
github.rest.repos.createCommitStatus({
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
2023-07-07 20:48:00 +03:00
|
|
|
sha: context.sha,
|
2023-07-06 00:42:43 +03:00
|
|
|
state: ${{ env.STATUS }} ? 'success' : 'failure',
|
|
|
|
context: 'Test / promotion',
|
|
|
|
description: ${{ env.STATUS }} ? 'All tests passed' : 'One or more tests failed and are blocking promotion',
|
|
|
|
target_url: 'https://github.com/Uniswap/interface/actions/runs/' + context.runId
|
|
|
|
})
|
|
|
|
env:
|
|
|
|
STATUS: |
|
|
|
|
${{ needs.lint.result == 'success' }} &&
|
|
|
|
${{ needs.typecheck.result == 'success' }} &&
|
|
|
|
${{ needs.deps-tests.result == 'success' }} &&
|
|
|
|
${{ needs.unit-tests.result == 'success' }} &&
|
2023-09-08 20:53:22 +03:00
|
|
|
${{ needs.cypress-test-matrix.result == 'success' }} &&
|
|
|
|
${{ needs.cloud-tests.result == 'success' }}
|