Skip to content

2024 12

2024 12 #387

Workflow file for this run

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 typecheck
- 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
- 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: 15 # 10 for component tests, 5 for e2e
# 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 }}-${{ github.run_attempt }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
run: yarn run cypress:component --record --parallel --group component
- 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 --group component
cypress_tests_e2e:
needs: install_and_cache_dependencies
strategy:
fail-fast: true
matrix:
group: [1, 2, 3, 4, 5]
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: 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: 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: 15 # 10 for component tests, 5 for e2e
# 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 }}-${{ github.run_attempt }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
run: |
yarn workspace jui-example-app run serve &
yarn run cypress:e2e --record --parallel --group e2e
- 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 workspace jui-example-app run serve &
yarn run cypress:e2e --record --parallel --group e2e
# 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, cypress_tests_e2e]
steps:
- run: exit 1
# see https://stackoverflow.com/a/67532120/4907315
if: >-
${{
contains(needs.*.result, 'failure')
|| contains(needs.*.result, 'cancelled')
}}