From 868c4c3e53a534d5ab98bb41309742ba69965789 Mon Sep 17 00:00:00 2001 From: Michal Zielenkiewicz Date: Wed, 6 Sep 2023 12:14:32 +0200 Subject: [PATCH] Split main workflow into build, lint and test workflows --- .github/workflows/ci-build.yml | 52 +++++++++++ .github/workflows/ci-lint.yml | 59 ++++++++++++ .../{build-test.yaml => ci-test.yml} | 89 ++++++++++--------- README.md | 11 ++- 4 files changed, 168 insertions(+), 43 deletions(-) create mode 100644 .github/workflows/ci-build.yml create mode 100644 .github/workflows/ci-lint.yml rename .github/workflows/{build-test.yaml => ci-test.yml} (64%) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml new file mode 100644 index 0000000000..d469f03d2f --- /dev/null +++ b/.github/workflows/ci-build.yml @@ -0,0 +1,52 @@ +# NOTE: This name appears in GitHub's Checks API and in workflow's status badge. +name: ci-build + +# Trigger the workflow when: +on: + # A push occurs to one of the matched branches. + push: + branches: + - master + - stable/* + # Or when a pull request event occurs for a pull request against one of the + # matched branches. + pull_request: + branches: + - master + - stable/* + +# Explicitly disable secrets.GITHUB_TOKEN permissions. +permissions: {} + +jobs: + yarn_cache: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Set up Node.js 18 + uses: actions/setup-node@v3 + id: yarn-cache + with: + node-version: '18.x' + cache: yarn + - if: steps.yarn-cache.outputs.cache-hit != 'true' + run: yarn install --frozen-lockfile + + build: + # NOTE: This name appears in GitHub's Checks API. + name: build + needs: [yarn_cache] + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Set up Node.js 18 + uses: actions/setup-node@v3 + with: + node-version: '18.x' + cache: yarn + - name: Install dependencies + run: yarn install --frozen-lockfile + - name: Build app + run: yarn build diff --git a/.github/workflows/ci-lint.yml b/.github/workflows/ci-lint.yml new file mode 100644 index 0000000000..afd54a3b2a --- /dev/null +++ b/.github/workflows/ci-lint.yml @@ -0,0 +1,59 @@ +# NOTE: This name appears in GitHub's Checks API and in workflow's status badge. +name: ci-lint + +# Trigger the workflow when: +on: + # A push occurs to one of the matched branches. + push: + branches: + - master + - stable/* + # Or when a pull request event occurs for a pull request against one of the + # matched branches. + pull_request: + branches: + - master + - stable/* + +# Explicitly disable secrets.GITHUB_TOKEN permissions. +permissions: {} + +jobs: + yarn_cache: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Set up Node.js 18 + uses: actions/setup-node@v3 + id: yarn-cache + with: + node-version: '18.x' + cache: yarn + - if: steps.yarn-cache.outputs.cache-hit != 'true' + run: yarn install --frozen-lockfile + + lint: + # NOTE: This name appears in GitHub's Checks API. + name: lint + needs: [yarn_cache] + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Set up Node.js 18 + uses: actions/setup-node@v3 + with: + node-version: '18.x' + cache: yarn + - name: Install dependencies + run: yarn install --frozen-lockfile + - name: ESLint + # Disallow warnings and always throw errors. + run: yarn lint --max-warnings 0 + - name: Validate Grommet icons types + run: | + yarn fix-grommet-icons-types + git diff --exit-code + - name: Validate TypeScript + run: yarn checkTs diff --git a/.github/workflows/build-test.yaml b/.github/workflows/ci-test.yml similarity index 64% rename from .github/workflows/build-test.yaml rename to .github/workflows/ci-test.yml index cb9fa2e146..9f5e0651e9 100644 --- a/.github/workflows/build-test.yaml +++ b/.github/workflows/ci-test.yml @@ -1,57 +1,53 @@ -name: Build and test +# NOTE: This name appears in GitHub's Checks API and in workflow's status badge. +name: ci-test +# Trigger the workflow when: on: + # A push occurs to one of the matched branches. push: - branches: [stable, master] + branches: + - master + - stable/* + # Or when a pull request event occurs for a pull request against one of the + # matched branches. pull_request: - branches: [stable, master] + branches: + - master + - stable/* -# disable secrets.GITHUB_TOKEN permissions +# Explicitly disable secrets.GITHUB_TOKEN permissions. permissions: {} jobs: yarn_cache: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Use Node.js 18.x + - name: Checkout code + uses: actions/checkout@v4 + - name: Set up Node.js 18 uses: actions/setup-node@v3 id: yarn-cache with: node-version: 18 - cache: 'yarn' + cache: yarn - if: steps.yarn-cache.outputs.cache-hit != 'true' run: yarn install --frozen-lockfile - build: - needs: [yarn_cache] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Use Node.js 18.x - uses: actions/setup-node@v3 - with: - node-version: 18 - cache: 'yarn' - - run: yarn install --frozen-lockfile - - run: yarn lint --max-warnings 0 - - run: | - yarn fix-grommet-icons-types - git diff --exit-code - - run: yarn checkTs - - run: yarn build - jest: + # NOTE: This name appears in GitHub's Checks API. + name: jest needs: [yarn_cache] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Use Node.js 18.x + - name: Checkout code + uses: actions/checkout@v4 + - name: Set up Node.js 18 uses: actions/setup-node@v3 with: - node-version: 18 - cache: 'yarn' - - run: yarn install --frozen-lockfile + node-version: '18.x' + cache: yarn + - name: Install dependencies + run: yarn install --frozen-lockfile - run: yarn test --coverage - name: 'Upload coverage report' uses: actions/upload-artifact@v3 @@ -61,16 +57,20 @@ jobs: retention-days: 5 playwright: + # NOTE: This name appears in GitHub's Checks API. + name: playwright needs: [yarn_cache] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Use Node.js 18.x + - name: Checkout code + uses: actions/checkout@v4 + - name: Set up Node.js 18 uses: actions/setup-node@v3 with: - node-version: 18 - cache: 'yarn' - - run: yarn install --frozen-lockfile + node-version: '18.x' + cache: yarn + - name: Install dependencies + run: yarn install --frozen-lockfile - run: REACT_APP_E2E_TEST=1 yarn build:ext - run: REACT_APP_E2E_TEST=1 yarn start:prod & - name: Install playwright's npm dependencies @@ -92,16 +92,20 @@ jobs: retention-days: 5 cypress: + # NOTE: This name appears in GitHub's Checks API. + name: cypress needs: [yarn_cache] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Use Node.js 18.x + - name: Checkout code + uses: actions/checkout@v4 + - name: Set up Node.js 18 uses: actions/setup-node@v3 with: - node-version: 18 - cache: 'yarn' - - run: yarn install --frozen-lockfile + node-version: '18.x' + cache: yarn + - name: Install dependencies + run: yarn install --frozen-lockfile - run: docker-compose pull - uses: satackey/action-docker-layer-caching@v0.0.11 # Ignore the failure of a step and avoid terminating the job. @@ -118,10 +122,13 @@ jobs: retention-days: 5 upload-coverage: + # NOTE: This name appears in GitHub's Checks API. + name: coverage needs: [cypress, jest] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Checkout code + uses: actions/checkout@v4 - name: Download coverage reports uses: actions/download-artifact@v3 - uses: codecov/codecov-action@v3 diff --git a/README.md b/README.md index 4732afe89a..e0a0cc9c7b 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,11 @@ # Oasis Wallet +[![CI build status][github-ci-build-badge]][github-ci-build-link] +[![CI test status][github-ci-test-badge]][github-ci-test-link] +[![CI lint status][github-ci-lint-badge]][github-ci-lint-link] [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![codecov](https://codecov.io/gh/oasisprotocol/oasis-wallet-web/branch/master/graph/badge.svg)](https://codecov.io/gh/oasisprotocol/oasis-wallet-web) [![Renovate enabled](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovatebot.com/) -[![Build status](https://github.com/oasisprotocol/oasis-wallet-web/actions/workflows/build-test.yaml/badge.svg)](https://github.com/oasisprotocol/oasis-wallet-web/actions) -[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FEsya%2Foasis-wallet.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2FEsya%2Foasis-wallet?ref=badge_shield) > :warning: **NEVER use the private keys and mnemonics given as example in this repository.** @@ -208,3 +209,9 @@ Adding a new language: [useTranslation hook]: https://react.i18next.com/latest/usetranslation-hook [English translation.json]: src/locales/en/translation.json [i18n.ts]: src/locales/i18n.ts +[github-ci-build-badge]: https://github.com/oasisprotocol/oasis-wallet-web/actions/workflows/ci-build.yml/badge.svg +[github-ci-build-link]: https://github.com/oasisprotocol/oasis-wallet-web/actions?query=workflow:ci-build+branch:master +[github-ci-test-badge]: https://github.com/oasisprotocol/oasis-wallet-web/actions/workflows/ci-test.yml/badge.svg +[github-ci-test-link]: https://github.com/oasisprotocol/oasis-wallet-web/actions?query=workflow:ci-test+branch:master +[github-ci-lint-badge]: https://github.com/oasisprotocol/oasis-wallet-web/actions/workflows/ci-lint.yml/badge.svg +[github-ci-lint-link]: https://github.com/oasisprotocol/oasis-wallet-web/actions?query=workflow:ci-lint+branch:master \ No newline at end of file