From cc919ab3df310c9a66d5444c64a2507af6233ce5 Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Thu, 16 Jun 2022 17:42:18 -0400 Subject: [PATCH] build: optimize github actions (#3922) * 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 --- .github/workflows/crowdin-sync.yaml | 21 ++++--- .github/workflows/crowdin.yaml | 21 ++++--- .github/workflows/lint.yml | 16 ++++-- .github/workflows/release.yaml | 24 ++++---- .github/workflows/tests-e2e.yaml | 87 ++++++++++++++++++++++++++--- .github/workflows/tests-unit.yaml | 21 ++++--- .gitignore | 3 - 7 files changed, 141 insertions(+), 52 deletions(-) diff --git a/.github/workflows/crowdin-sync.yaml b/.github/workflows/crowdin-sync.yaml index c85d6f3feb..13bb94721c 100644 --- a/.github/workflows/crowdin-sync.yaml +++ b/.github/workflows/crowdin-sync.yaml @@ -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') }} - - name: Extract translations - run: "yarn i18n:extract" + - if: steps.install-cache.outputs.cache-hit != 'true' + run: yarn install --frozen-lockfile --ignore-scripts - - name: Synchronize + - run: yarn i18n:extract + + - name: Download Crowdin translations uses: crowdin/github-action@1.4.9 with: upload_sources: false diff --git a/.github/workflows/crowdin.yaml b/.github/workflows/crowdin.yaml index 04466e21b4..d29131499e 100644 --- a/.github/workflows/crowdin.yaml +++ b/.github/workflows/crowdin.yaml @@ -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') }} - - name: Extract translations - run: "yarn i18n:extract" + - if: steps.install-cache.outputs.cache-hit != 'true' + run: yarn install --frozen-lockfile --ignore-scripts - - name: Synchronize + - run: yarn i18n:extract + + - name: Upload Crowdin sources uses: crowdin/github-action@1.1.0 with: upload_sources: true diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 328179866e..b4f5c29fb7 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -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 }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2e56fd2656..c5ec581d8f 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -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 @@ -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') }} - - name: Build the IPFS bundle - run: yarn build + - if: steps.install-cache.outputs.cache-hit != 'true' + run: yarn install --frozen-lockfile --ignore-scripts + + - run: yarn prepare + + - run: yarn build - name: Pin to IPFS id: upload diff --git a/.github/workflows/tests-e2e.yaml b/.github/workflows/tests-e2e.yaml index bb34c456b5..3b3471a2a1 100644 --- a/.github/workflows/tests-e2e.yaml +++ b/.github/workflows/tests-e2e.yaml @@ -9,21 +9,94 @@ on: - main jobs: - cypress-tests: - name: Run Cypress tests + build: + name: Build runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 + - uses: actions/checkout@v3 - - name: Cypress install - uses: cypress-io/github-action@v4 + - uses: actions/setup-node@v3 with: - build: yarn build + 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 tests + runs-on: ubuntu-latest + needs: build + strategy: + fail-fast: false + matrix: + containers: [1, 2, 3, 4] + 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/ # 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 + + - uses: cypress-io/github-action@v4 + with: + 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 }} diff --git a/.github/workflows/tests-unit.yaml b/.github/workflows/tests-unit.yaml index 538e4c7f16..899e2f5179 100644 --- a/.github/workflows/tests-unit.yaml +++ b/.github/workflows/tests-unit.yaml @@ -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') }} - - name: Run unit tests - run: yarn test + - if: steps.install-cache.outputs.cache-hit != 'true' + run: yarn install --frozen-lockfile --ignore-scripts + + - run: yarn prepare + + - run: yarn test diff --git a/.gitignore b/.gitignore index 5b53d5b28b..d87685b009 100644 --- a/.gitignore +++ b/.gitignore @@ -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