ci: fix test workflow with corepack and yarn version management #10
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: Tests | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
types: [opened, synchronize, reopened] | |
branches: | |
- master | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [14.x, 16.x, 18.x] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'yarn' | |
- name: Enable Corepack | |
run: corepack enable | |
- name: Ensure correct Yarn version | |
run: corepack prepare [email protected] --activate | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile | |
- name: Install Playwright browsers | |
run: yarn playwright install --with-deps | |
- name: Run unit tests | |
id: unit-test | |
run: yarn test:coverage | |
- name: Upload coverage | |
uses: codecov/codecov-action@v5 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
fail_ci_if_error: true | |
- name: Run e2e tests | |
id: e2e-test | |
run: yarn test:e2e | |
- name: Report Status | |
if: always() | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const unitStatus = '${{ steps.unit-test.outcome }}' | |
const e2eStatus = '${{ steps.e2e-test.outcome }}' | |
const status = unitStatus === 'success' && e2eStatus === 'success' ? 'success' : 'failure' | |
core.setOutput('status', status) |