Skip to content

Commit

Permalink
Merge pull request #470 from huwshimi/add-coverage-reporter
Browse files Browse the repository at this point in the history
chore(ci): add UI test coverage reporter
  • Loading branch information
huwshimi authored Nov 20, 2024
2 parents 8d43266 + ed4ebda commit 92425ed
Show file tree
Hide file tree
Showing 6 changed files with 459 additions and 209 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/ui-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Report UI Coverage
on:
workflow_run:
workflows: ["UI"]
types:
- completed
jobs:
report:
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: "Report Coverage"
uses: davelosert/vitest-coverage-report-action@v2
with:
working-directory: "./ui"
name: "UI Test Coverage"
13 changes: 12 additions & 1 deletion .github/workflows/ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ on:
push:
branches:
- main
paths:
- 'ui/**'
pull_request:
branches:
- main
paths:
- 'ui/**'
jobs:
lint:
name: Lint
Expand All @@ -27,6 +31,8 @@ jobs:
test:
name: Test
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
matrix:
node-version: [20.x]
Expand All @@ -40,7 +46,12 @@ jobs:
cache-dependency-path: ui/yarn.lock
- name: Install
run: yarn --cwd ui install --immutable
- run: yarn --cwd ui test-js
- run: yarn --cwd ui test-js --coverage.enabled true
- name: "Upload Coverage"
uses: actions/upload-artifact@v4
with:
name: coverage
path: coverage
build:
name: Build
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion ui/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,6 @@ dist/
/test-results/
/playwright-report/
/playwright/.cache/
coverage

haproxy-local.cfg
haproxy-local.cfg
3 changes: 2 additions & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"@typescript-eslint/eslint-plugin": "7.3.1",
"@typescript-eslint/parser": "7.3.1",
"@vitejs/plugin-react": "^4.2.1",
"@vitest/coverage-v8": "2.1.5",
"autoprefixer": "10.4.19",
"axios-mock-adapter": "2.0.0",
"babel-plugin-transform-es2015-modules-commonjs": "6.26.2",
Expand All @@ -77,7 +78,7 @@
"vite": "5.2.8",
"vite-plugin-html": "3.2.2",
"vite-tsconfig-paths": "4.3.2",
"vitest": "1.2.1"
"vitest": "2.1.5"
},
"lint-staged": {
"src/**/*.{json,jsx,ts,tsx}": [
Expand Down
6 changes: 6 additions & 0 deletions ui/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ export default defineConfig((configEnv) =>
viteConfig({ ...configEnv, mode: "development" }),
defineConfig({
test: {
coverage: {
exclude: ["src/test/**", "**/*.d.ts"],
include: ["src/**/*.[jt]s?(x)"],
reporter: ["text", "json-summary", "json", "cobertura"],
reportOnFailure: true,
},
environment: "happy-dom",
globals: true,
include: ["./src/**/*.{test,spec}.{ts,tsx}"],
Expand Down
Loading

0 comments on commit 92425ed

Please sign in to comment.