πmnemonic, πButtonGroup, e2e tests #343
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI (on PRs and master branch) | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
branches: [master] | |
env: | |
IS_PR_WITH_PERCY: ${{ github.event_name == 'pull_request' && !contains(github.event.pull_request.title, 'SKIP_PERCY') && !contains(github.event.pull_request.body, 'SKIP_PERCY') }} | |
IS_PR_JUST_MERGED: ${{ github.ref_name == 'master' && contains(github.event.head_commit.message, 'Merge pull request') && !contains(github.event.head_commit.message, 'SKIP_PERCY') }} | |
jobs: | |
install_and_cache_dependencies: | |
if: "!contains(github.event.head_commit.message, 'SKIP_CI')" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout ποΈ | |
uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 16.16.0 | |
cache: yarn | |
- name: Install Dependencies π§ | |
run: yarn install --immutable | |
build_and_test: | |
runs-on: ubuntu-latest | |
needs: install_and_cache_dependencies | |
steps: | |
- name: Log Interesting Info βΉοΈ | |
run: | | |
echo "The job is triggered by a ${{ github.event_name }} event." | |
echo "This job is now running on a ${{ runner.os }} server hosted by GitHub!" | |
- name: Checkout ποΈ | |
uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 16.16.0 | |
cache: yarn | |
- name: Install Dependencies π§ | |
run: yarn install --immutable | |
- name: Type Check Κ¦ | |
run: yarn run type-check | |
- name: Linting π΅ | |
run: yarn run lint | |
- name: Formatting π | |
run: yarn run format:check | |
- name: Build π¨ | |
run: yarn run build:public | |
- name: Run Tests (Cypress excluded) β | |
run: yarn run test | |
- name: "Cancel build on failure" | |
if: failure() | |
uses: andymckay/[email protected] | |
cypress_tests: | |
needs: install_and_cache_dependencies | |
strategy: | |
fail-fast: true | |
matrix: | |
group: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | |
runs-on: ubuntu-latest # note: macos doesn't have docker installed! | |
container: cypress/browsers:node16.16.0-chrome107-ff107-edge | |
env: | |
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} | |
CYPRESS_parallel: true | |
steps: | |
- name: Log Interesting Info βΉοΈ | |
run: | | |
echo "The job is triggered by a ${{ github.event_name }} event." | |
echo "This job is now running on a ${{ runner.os }} server hosted by GitHub!" | |
- name: Checkout ποΈ | |
uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 16.16.0 | |
cache: yarn | |
- name: Install Dependencies π§ | |
run: yarn install --immutable | |
# For now, e2e tests are run in the same job. | |
# Could be split into two jobs later on when there are enough e2e tests for it to be worth it. | |
- name: Build example-app π¨ | |
run: yarn workspace jui-example-app run build | |
- name: Run Cypress Tests β | |
if: ${{ env.IS_PR_JUST_MERGED == 'true' || env.IS_PR_WITH_PERCY == 'true' }} | |
env: | |
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} | |
# Without this, we would need to "finalize" percy build explicitly. More info: https://docs.percy.io/docs/parallel-test-suites | |
PERCY_PARALLEL_TOTAL: 20 # component and e2e, each 10 | |
# Percy's nonce is supposed to be set to run id by default, but it's not. Plus, appending run_number makes it more reliable in case of rerunning | |
PERCY_PARALLEL_NONCE: ${{ github.run_id }}-${{ github.run_number }} | |
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} | |
run: | | |
yarn run cypress:component --record --parallel | |
yarn workspace jui-example-app run serve & | |
yarn run cypress:e2e --record --parallel | |
- name: Run Cypress Tests (without percy) β | |
if: ${{ !(env.IS_PR_JUST_MERGED == 'true' || env.IS_PR_WITH_PERCY == 'true') }} | |
env: | |
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} | |
run: | | |
yarn run cypress:component --record --parallel | |
yarn workspace jui-example-app run serve & | |
yarn run cypress:e2e --record --parallel | |
- uses: actions/upload-artifact@v2 | |
name: Upload Cypress screenshots if tests failed π€ | |
if: failure() | |
with: | |
name: cypress-screenshots | |
path: | | |
packages/jui/**/__image_snapshots__ | |
packages/jui/cypress/videos | |
packages/jui/cypress/screenshots | |
# just because there is no way to add a required status check based on a matrix job. In order to avoid adding | |
# individual status check for each parallel job. Based on this suggestion: | |
# https://github.com/orgs/community/discussions/26822#discussioncomment-5122101 | |
succeeded: | |
name: Succeeded | |
if: ${{ always() }} | |
runs-on: ubuntu-latest | |
needs: [build_and_test, cypress_tests] | |
steps: | |
- run: exit 1 | |
# see https://stackoverflow.com/a/67532120/4907315 | |
if: >- | |
${{ | |
contains(needs.*.result, 'failure') | |
|| contains(needs.*.result, 'cancelled') | |
}} |