ci: Fix and improve tests workflow (fix: #15380) #258
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: UI tests | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
branches: | |
- 'dev' | |
paths: | |
- '.github/workflows/tests-on-pr.yml' | |
- 'ui/**/*.js' | |
- 'ui/package.json' | |
- 'ui/dev/package.json' | |
jobs: | |
build: | |
permissions: | |
contents: read # to fetch code (actions/checkout) | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ui | |
# Check if the build cache exists, and if it does, do nothing else. | |
# Otherwise, run the build and cache it. | |
name: Build the UI package | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 14 | |
cache: 'yarn' | |
- name: Install dependencies | |
run: yarn install --focus | |
- name: Build the package | |
run: yarn build | |
- name: Upload build artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ui-build | |
path: ui/dist | |
tests: | |
# If the build pipeline doesn't succeed, we don't need to run tests at all | |
needs: build | |
permissions: | |
contents: read # to fetch code (actions/checkout) | |
actions: read # to correctly identify workflow run (cypress-io/github-action) | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ui | |
strategy: | |
fail-fast: false | |
matrix: | |
browser: [chrome, firefox] | |
name: Tests on ${{ matrix.browser }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 14 | |
cache: 'yarn' | |
- name: Install dependencies | |
run: yarn install --focus | |
- name: Download build artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: ui-build | |
path: ui/dist | |
- name: Run tests in ${{ matrix.browser }} browser | |
uses: cypress-io/github-action@v5 | |
with: | |
install: false | |
command: yarn test:component:run --browser ${{ matrix.browser }} --reporter json --reporter-option output=dist/test-results/${{ matrix.browser }}.json | |
working-directory: ui | |
# Upload required artifacts to be used in tests-on-pr-report.yml | |
- name: Upload test results | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-results-${{ matrix.browser }} | |
path: ui/dist/test-results/${{ matrix.browser }}.json | |
- name: Upload GitHub Actions event data | |
uses: actions/upload-artifact@v3 | |
with: | |
name: event-data | |
path: ${{ github.event_path }} |