From 77b640c41bc180b741def706a86e1413e69af0aa Mon Sep 17 00:00:00 2001 From: Moody Salem Date: Wed, 21 Apr 2021 12:35:49 -0500 Subject: [PATCH] chore(tests): improve the CI (#1370) * improve the CI * change triggers * add pull request target back --- .github/workflows/integration-tests.yaml | 38 ++++++++++++++ .github/workflows/lint.yml | 21 ++------ .github/workflows/release.yaml | 10 ++-- .github/workflows/tests.yaml | 65 ------------------------ .github/workflows/unit-tests.yaml | 28 ++++++++++ README.md | 6 ++- cypress/support/commands.js | 12 +++-- 7 files changed, 86 insertions(+), 94 deletions(-) create mode 100644 .github/workflows/integration-tests.yaml delete mode 100644 .github/workflows/tests.yaml create mode 100644 .github/workflows/unit-tests.yaml diff --git a/.github/workflows/integration-tests.yaml b/.github/workflows/integration-tests.yaml new file mode 100644 index 0000000000..7fb68ede52 --- /dev/null +++ b/.github/workflows/integration-tests.yaml @@ -0,0 +1,38 @@ +name: Integration Tests + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + integration-tests: + name: Cypress + runs-on: ubuntu-16.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up node + uses: actions/setup-node@v2 + with: + node-version: 14 + registry-url: https://registry.npmjs.org + + - name: Install dependencies + run: yarn install --frozen-lockfile + + - run: yarn cypress install + - run: yarn build + env: + CI: false + REACT_APP_NETWORK_URL: "https://mainnet.infura.io/v3/4bf032f2d38a4ed6bb975b80d6340847" + + - run: yarn integration-test + env: + CYPRESS_INTEGRATION_TEST_PRIVATE_KEY: ${{ secrets.CYPRESS_INTEGRATION_TEST_PRIVATE_KEY }} + + diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8da30a37d2..50967dee27 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -14,33 +14,20 @@ jobs: runs-on: ubuntu-latest steps: - - name: Check out Git repository + - name: Checkout uses: actions/checkout@v2 - name: Set up node - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: - node-version: 12 - always-auth: true + node-version: 14 registry-url: https://registry.npmjs.org - - name: Set output of cache - id: yarn-cache - run: echo "::set-output name=dir::$(yarn cache dir)" - - - name: Node dependency cache - uses: actions/cache@v1 - with: - path: ${{ steps.yarn-cache.outputs.dir }} - key: yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - yarn- - - name: Install dependencies run: yarn install --frozen-lockfile - name: Run linters - uses: wearerequired/lint-action@77d70b9a07ecb93bc98dc46dc27d96c4f004d035 + uses: wearerequired/lint-action@b98b0918aa71490373d2eca9e8e39a9bc1cc2517 with: github_token: ${{ secrets.github_token }} eslint: true diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2056f202e6..e5fa827ddb 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -15,7 +15,7 @@ jobs: changelog: ${{ steps.github_tag_action.outputs.changelog }} steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v2 - name: Bump version and push tag id: github_tag_action @@ -31,12 +31,12 @@ jobs: if: ${{ needs.bump_version.outputs.new_tag != null }} steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - name: Set up node + uses: actions/setup-node@v2 with: - node-version: '12' - always-auth: true + node-version: 14 registry-url: https://registry.npmjs.org - name: Install dependencies diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml deleted file mode 100644 index c127cccd48..0000000000 --- a/.github/workflows/tests.yaml +++ /dev/null @@ -1,65 +0,0 @@ -name: Tests -on: - push: - branches: - - main - pull_request: - branches: - - main - -jobs: - integration-tests: - name: Integration tests - runs-on: ubuntu-16.04 - steps: - - name: Checkout - uses: actions/checkout@v1 - - uses: actions/setup-node@v1 - with: - node-version: '12' - always-auth: true - registry-url: https://registry.npmjs.org - - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn cache dir)" - - uses: actions/cache@v1 - id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- - - run: yarn install --frozen-lockfile - - run: yarn cypress install - - run: yarn build - env: - CI: false - REACT_APP_NETWORK_URL: "https://mainnet.infura.io/v3/4bf032f2d38a4ed6bb975b80d6340847" - - run: yarn integration-test - - unit-tests: - name: Unit tests - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v1 - - uses: actions/setup-node@v1 - with: - node-version: '12' - always-auth: true - registry-url: https://registry.npmjs.org - - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn cache dir)" - - uses: actions/cache@v1 - id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- - - run: yarn install --frozen-lockfile - - run: yarn test - diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml new file mode 100644 index 0000000000..b12c57c2d1 --- /dev/null +++ b/.github/workflows/unit-tests.yaml @@ -0,0 +1,28 @@ +name: Unit Tests +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + unit-tests: + name: Unit tests + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up node + uses: actions/setup-node@v2 + with: + node-version: 14 + registry-url: https://registry.npmjs.org + + - name: Install dependencies + run: yarn install --frozen-lockfile + + - name: Run unit tests + run: yarn test diff --git a/README.md b/README.md index fa2162c696..2131bf69fa 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ # Uniswap Interface -[![Lint](https://github.com/Uniswap/uniswap-interface/workflows/Lint/badge.svg)](https://github.com/Uniswap/uniswap-interface/actions?query=workflow%3ALint) -[![Tests](https://github.com/Uniswap/uniswap-interface/workflows/Tests/badge.svg)](https://github.com/Uniswap/uniswap-interface/actions?query=workflow%3ATests) +[![Unit Tests](https://github.com/Uniswap/uniswap-interface/actions/workflows/unit-tests.yaml/badge.svg)](https://github.com/Uniswap/uniswap-interface/actions/workflows/unit-tests.yaml) +[![Integration Tests](https://github.com/Uniswap/uniswap-interface/actions/workflows/integration-tests.yaml/badge.svg)](https://github.com/Uniswap/uniswap-interface/actions/workflows/integration-tests.yaml) +[![Lint](https://github.com/Uniswap/uniswap-interface/actions/workflows/lint.yml/badge.svg)](https://github.com/Uniswap/uniswap-interface/actions/workflows/lint.yml) +[![Release](https://github.com/Uniswap/uniswap-interface/actions/workflows/release.yaml/badge.svg)](https://github.com/Uniswap/uniswap-interface/actions/workflows/release.yaml) [![Styled With Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://prettier.io/) An open source interface for Uniswap -- a protocol for decentralized exchange of Ethereum tokens. diff --git a/cypress/support/commands.js b/cypress/support/commands.js index a2c0deb52f..7de1050cff 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -8,13 +8,15 @@ import { JsonRpcProvider } from '@ethersproject/providers' import { Wallet } from '@ethersproject/wallet' import { _Eip1193Bridge } from '@ethersproject/experimental/lib/eip1193-bridge' -// never send real ether to this, obviously -const PRIVATE_KEY_TEST_NEVER_USE = '0xad20c82497421e9784f18460ad2fe84f73569068e98e270b3e63743268af5763' +const TEST_PRIVATE_KEY = Cypress.env('INTEGRATION_TEST_PRIVATE_KEY') // address of the above key -export const TEST_ADDRESS_NEVER_USE = '0x0fF2D1eFd7A57B7562b2bf27F3f37899dB27F4a5' +export const TEST_ADDRESS_NEVER_USE = new Wallet(TEST_PRIVATE_KEY).address -export const TEST_ADDRESS_NEVER_USE_SHORTENED = '0x0fF2...F4a5' +export const TEST_ADDRESS_NEVER_USE_SHORTENED = `${TEST_ADDRESS_NEVER_USE.substr( + 0, + 6 +)}...${TEST_ADDRESS_NEVER_USE.substr(-4, 4)}` class CustomizedBridge extends _Eip1193Bridge { async sendAsync(...args) { @@ -75,7 +77,7 @@ Cypress.Commands.overwrite('visit', (original, url, options) => { options && options.onBeforeLoad && options.onBeforeLoad(win) win.localStorage.clear() const provider = new JsonRpcProvider('https://rinkeby.infura.io/v3/4bf032f2d38a4ed6bb975b80d6340847', 4) - const signer = new Wallet(PRIVATE_KEY_TEST_NEVER_USE, provider) + const signer = new Wallet(TEST_PRIVATE_KEY, provider) win.ethereum = new CustomizedBridge(signer, provider) } })