Skip to content

Commit

Permalink
fix(ci): PR testing & reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
rstoenescu committed Apr 24, 2024
1 parent 272b92b commit d7d445f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests-on-pr-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
run_id: context.payload.workflow_run.id,
});
const resultArtifacts = artifacts.filter(({ name }) => name.startsWith('test-results-'));
const resultArtifacts = artifacts.filter(({ name }) => name.startsWith('test-results'));
for (const artifact of resultArtifacts) {
const { data: artifactData } = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
Expand Down Expand Up @@ -70,5 +70,5 @@ jobs:
commit: ${{ github.event.workflow_run.head_sha }}
event_file: event-data/event.json
event_name: ${{ github.event.workflow_run.event }}
files: 'test-results/*/*.xml'
files: 'test-results/*.json'
check_name: 'UI Tests Results'
40 changes: 9 additions & 31 deletions .github/workflows/tests-on-pr.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: UI tests

on:
workflow_dispatch:

pull_request:
types: [opened, synchronize]
branches:
Expand All @@ -9,7 +11,7 @@ on:
- '.github/workflows/tests-on-pr.yml'
- 'ui/**/*.js'
- 'ui/package.json'
- 'ui/dev/package.json'
- 'ui/playground/package.json'

jobs:
build:
Expand Down Expand Up @@ -63,7 +65,7 @@ jobs:

permissions:
contents: read # to fetch code (actions/checkout)
actions: read # to correctly identify workflow run (cypress-io/github-action)
actions: read # to correctly identify workflow run

runs-on: ubuntu-latest

Expand All @@ -73,10 +75,8 @@ jobs:

strategy:
fail-fast: false
matrix:
browser: [chrome, firefox]

name: Tests on ${{ matrix.browser }}
name: Tests
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -93,25 +93,6 @@ jobs:
- name: Install dependencies
run: pnpm i

# We have to cache Cypress binary as well (https://on.cypress.io/not-installed-ci-error)
- name: Get Cypress version
id: cypress-version
working-directory: ui
run: |
echo "CYPRESS_VERSION=$(pnpm why cypress --depth 0 --json | jq -r '.[0].devDependencies.cypress.version')" > $GITHUB_OUTPUT
- name: Cache Cypress binary
id: cypress-cache
uses: actions/cache@v4
with:
# https://docs.cypress.io/guides/references/advanced-installation#Skipping-installation
path: ~/.cache/Cypress
key: cypress-cache-${{ steps.cypress-version.outputs.CYPRESS_VERSION }}
restore-keys: |
cypress-cache-
- name: Install Cypress
if: steps.cypress-cache.outputs.cache-hit != 'true'
run: pnpm cypress install

- name: Download UI build artifact
uses: actions/download-artifact@v4
with:
Expand All @@ -124,13 +105,10 @@ jobs:
name: vite-plugin-build
path: vite-plugin/dist

- name: Run tests in ${{ matrix.browser }} browser
uses: cypress-io/github-action@v6
env:
CYPRESS_JUNIT_RESULTS_FILENAME: test-results/${{ matrix.browser }}/[hash].xml
- name: Run tests
with:
install: false
command: pnpm test:component:run --browser ${{ matrix.browser }}
command: pnpm test:workflow
working-directory: ui

# Upload required artifacts to be used in tests-on-pr-report.yml
Expand All @@ -139,8 +117,8 @@ jobs:
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.browser }}
path: ui/dev/test-results
name: test-results
path: ui/testing/test-results

- name: Upload GitHub Actions event data
if: ${{ always() }}
Expand Down
1 change: 1 addition & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"lint": "eslint --ext .js,.cjs,.mjs,.vue ./ --fix --report-unused-disable-directives",
"format:types": "prettier --write \"types/**/*.{d.ts,ts,json}\"",
"test": "pnpm --filter quasar-ui-test test",
"test:workflow": "pnpm --filter quasar-ui-test test:workflow",
"test:watch": "pnpm --filter quasar-ui-test test:watch",
"test:watch:ui": "pnpm --filter quasar-ui-test test:watch:ui",
"test:specs": "node ./testing/specs/script.js",
Expand Down
1 change: 1 addition & 0 deletions ui/testing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"scripts": {
"test": "vitest run",
"test:workflow": "vitest run --reporter=json --outputFile=./test-results/vitest.json",
"test:watch": "vitest watch",
"test:watch:ui": "vitest watch --ui",
"coverage": "vitest run --coverage"
Expand Down

0 comments on commit d7d445f

Please sign in to comment.