Skip to content

Commit

Permalink
build: optimize github actions (Uniswap#3922)
Browse files Browse the repository at this point in the history
* build: parallelize cypress

- Parallelizes cypress CI runs
- Cleans up CI workflow files

* build: fix typo

* build: cache node_modules

* build: cache node_modules everywhere

* fix: action/cache usage

* fix: do not cache dynamically built files

* build: use standard container for cypress

* fix: cache cypress

* fix: cache cypress
  • Loading branch information
zzmp authored Jun 16, 2022
1 parent 53d6eb0 commit cc919ab
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 51 deletions.
21 changes: 12 additions & 9 deletions .github/workflows/crowdin-sync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,26 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: Set up node
uses: actions/setup-node@v3
- uses: actions/setup-node@v3
with:
node-version: 14
registry-url: https://registry.npmjs.org
cache: 'yarn'

- name: Install dependencies
run: yarn install --frozen-lockfile
- uses: actions/cache@v3
id: install-cache
with:
path: node_modules/
key: ${{ runner.os }}-install-${{ hashFiles('**/yarn.lock') }}

- if: steps.install-cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile --ignore-scripts

- name: Extract translations
run: "yarn i18n:extract"
- run: yarn i18n:extract

- name: Synchronize
- name: Download Crowdin translations
uses: crowdin/[email protected]
with:
upload_sources: false
Expand Down
21 changes: 12 additions & 9 deletions .github/workflows/crowdin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,26 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: Set up node
uses: actions/setup-node@v3
- uses: actions/setup-node@v3
with:
node-version: 14
registry-url: https://registry.npmjs.org
cache: 'yarn'

- name: Install dependencies
run: yarn install --frozen-lockfile
- uses: actions/cache@v3
id: install-cache
with:
path: node_modules/
key: ${{ runner.os }}-install-${{ hashFiles('**/yarn.lock') }}

- if: steps.install-cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile --ignore-scripts

- name: Extract translations
run: "yarn i18n:extract"
- run: yarn i18n:extract

- name: Synchronize
- name: Upload Crowdin sources
uses: crowdin/[email protected]
with:
upload_sources: true
Expand Down
16 changes: 10 additions & 6 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,22 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: Set up node
uses: actions/setup-node@v3
- uses: actions/setup-node@v3
with:
node-version: 14
registry-url: https://registry.npmjs.org
cache: 'yarn'

- name: Install dependencies
run: yarn install --frozen-lockfile
- uses: actions/cache@v3
id: install-cache
with:
path: node_modules/
key: ${{ runner.os }}-install-${{ hashFiles('**/yarn.lock') }}

- if: steps.install-cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile --ignore-scripts

- name: Run eslint w/ autofix
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login == github.repository_owner }}
Expand Down
24 changes: 14 additions & 10 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ jobs:
new_tag: ${{ steps.github_tag_action.outputs.new_tag }}
changelog: ${{ steps.github_tag_action.outputs.changelog }}
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: Bump version and push tag
id: github_tag_action
Expand All @@ -31,21 +30,26 @@ jobs:
needs: bump_version
if: ${{ needs.bump_version.outputs.new_tag != null }}
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: Set up node
uses: actions/setup-node@v3
- uses: actions/setup-node@v3
with:
node-version: 14
registry-url: https://registry.npmjs.org
cache: 'yarn'

- name: Install dependencies
run: yarn install --frozen-lockfile
- uses: actions/cache@v3
id: install-cache
with:
path: node_modules/
key: ${{ runner.os }}-install-${{ hashFiles('**/yarn.lock') }}

- if: steps.install-cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile --ignore-scripts

- run: yarn prepare

- name: Build the IPFS bundle
run: yarn build
- run: yarn build

- name: Pin to IPFS
id: upload
Expand Down
85 changes: 79 additions & 6 deletions .github/workflows/tests-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,94 @@ on:
- main

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 14
registry-url: https://registry.npmjs.org
cache: 'yarn'

- uses: actions/cache@v3
id: install-cache
with:
path: node_modules/
key: ${{ runner.os }}-install-${{ hashFiles('**/yarn.lock') }}

- if: steps.install-cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile --ignore-scripts

- run: yarn prepare

- run: yarn build

- uses: actions/upload-artifact@v2
with:
name: build
path: build
if-no-files-found: error

- uses: actions/cache@v3
id: cypress-cache
with:
path: /home/runner/.cache/Cypress
key: ${{ runner.os }}-cypress-${{ hashFiles('node_modules/cypress') }}

- if: steps.cypress-cache.outputs.cache-hit != 'true'
run: yarn cypress install

cypress-tests:
name: Run Cypress tests
name: Run tests
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
containers: [1, 2, 3, 4]
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 14
registry-url: https://registry.npmjs.org
cache: 'yarn'

- uses: actions/cache@v3
id: install-cache
with:
path: node_modules/ # this should always be a cache hit, from install
key: ${{ runner.os }}-install-${{ hashFiles('**/yarn.lock') }}

- if: steps.install-cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile --ignore-scripts

- uses: actions/download-artifact@v2
with:
name: build
path: build

- uses: actions/cache@v3
id: cypress-cache
with:
path: /home/runner/.cache/Cypress
key: ${{ runner.os }}-cypress-${{ hashFiles('node_modules/cypress') }}

- if: steps.cypress-cache.outputs.cache-hit != 'true'
run: yarn cypress install

- name: Cypress install
uses: cypress-io/github-action@v4
- uses: cypress-io/github-action@v4
with:
build: yarn build
install: false
start: yarn serve
wait-on: 'http://localhost:3000'
browser: chrome
record: true
parallel: true
env:
CI: false # disables lint checks when building
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
Expand Down
21 changes: 13 additions & 8 deletions .github/workflows/tests-unit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,23 @@ jobs:
name: Run tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: Set up node
uses: actions/setup-node@v3
- uses: actions/setup-node@v3
with:
node-version: 14
registry-url: https://registry.npmjs.org
cache: 'yarn'

- name: Install dependencies
run: yarn install --frozen-lockfile
- uses: actions/cache@v3
id: install-cache
with:
path: node_modules/
key: ${{ runner.os }}-install-${{ hashFiles('**/yarn.lock') }}

- if: steps.install-cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile --ignore-scripts

- run: yarn prepare

- name: Run unit tests
run: yarn test
- run: yarn test
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
# generated contract types
/src/types/v3
/src/abis/types
/src/lib/locales/**/*.js
/src/lib/locales/**/en-US.po
/src/lib/locales/**/pseudo.po
/src/locales/**/*.js
/src/locales/**/en-US.po
/src/locales/**/pseudo.po
Expand Down

0 comments on commit cc919ab

Please sign in to comment.