Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions .github/workflows/vitest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ on:

permissions:
contents: read
# `davelosert/vitest-coverage-report-action` writes a PR comment with the
# coverage diff; needs write access on pull-requests for that.
pull-requests: write
Comment thread
nowgnuesLee marked this conversation as resolved.

jobs:
check-changes:
Expand Down Expand Up @@ -80,8 +83,14 @@ jobs:
run: pnpm run lint
- name: Run relay-compiler
run: pnpm run relay
- name: Run Vitest
run: pnpm run vitest
- name: Run Vitest with coverage
run: pnpm exec vitest run --coverage
- name: Report coverage on PR
if: always()
uses: davelosert/vitest-coverage-report-action@v2
with:
working-directory: ./react
name: react-coverage

backend-ai-ui-vitest:
needs: check-changes
Expand Down Expand Up @@ -119,8 +128,14 @@ jobs:
run: pnpm run lint
- name: Run relay-compiler
run: cd ../.. && pnpm run relay
- name: Run Vitest
run: pnpm run vitest
- name: Run Vitest with coverage
run: pnpm exec vitest run --coverage
- name: Report coverage on PR
if: always()
uses: davelosert/vitest-coverage-report-action@v2
with:
working-directory: ./packages/backend.ai-ui
name: backend-ai-ui-coverage

root-vitest:
needs: check-changes
Expand Down Expand Up @@ -150,5 +165,10 @@ jobs:
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --merge-git-branch-lockfiles --no-frozen-lockfile
- name: Run Vitest
run: pnpm run vitest
- name: Run Vitest with coverage
run: pnpm exec vitest run --coverage
- name: Report coverage on PR
if: always()
uses: davelosert/vitest-coverage-report-action@v2
with:
name: root-coverage
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"tslib": "^2.8.1",
"typescript": "~5.5.4",
"vitest": "^4.1.4",
"@vitest/coverage-v8": "^4.1.4",
"webpack": "catalog:",
"webpack-cli": "^6.0.1",
"workbox-expiration": "^7.4.0",
Expand Down
5 changes: 4 additions & 1 deletion packages/backend.ai-ui/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,7 @@ storybook-static
.vscode/*
!.vscode/settings.json.sample

dist
dist

# vitest coverage output
/coverage
3 changes: 2 additions & 1 deletion packages/backend.ai-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@
"vite-plugin-dts": "^4.5.4",
"vite-plugin-relay-lite": "^0.11.0",
"vite-plugin-svgr": "^4.5.0",
"vitest": "^4.1.4"
"vitest": "^4.1.4",
"@vitest/coverage-v8": "^4.1.4"
},
"type": "module"
}
19 changes: 19 additions & 0 deletions packages/backend.ai-ui/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,24 @@ export default defineConfig({
],
include: ['src/**/*.{test,spec}.{ts,tsx}'],
exclude: ['**/node_modules/**', '**/dist/**', '**/__generated__/**'],

// Coverage settings — see comment in `react/vitest.config.ts`. The
// `davelosert/vitest-coverage-report-action` GitHub Action consumes the
// `json-summary` reporter to post a PR comment with line/branch/function/
// statement coverage diffs.
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'json-summary', 'html'],
reportsDirectory: 'coverage',
include: ['src/**/*.{ts,tsx}'],
exclude: [
'src/**/*.{test,spec}.{ts,tsx}',
'src/**/*.stories.{ts,tsx}',
'src/__generated__/**',
'src/**/__generated__/**',
'src/index.ts',
'src/locale/**',
],
},
},
});
3 changes: 2 additions & 1 deletion react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
"vite-plugin-node-polyfills": "^0.24.0",
"vite-plugin-pwa": "^1.2.0",
"vite-plugin-svgr": "^4.5.0",
"vitest": "^4.1.4"
"vitest": "^4.1.4",
"@vitest/coverage-v8": "^4.1.4"
}
}
20 changes: 20 additions & 0 deletions react/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,25 @@ export default defineConfig({
],
include: ['src/**/*.{test,spec}.{ts,tsx}'],
exclude: ['**/node_modules/**', '**/build/**', '**/__generated__/**'],

// Coverage settings: V8 provider is the fastest (Node's built-in V8
// inspector with no Babel transform). `json-summary` is what
// `davelosert/vitest-coverage-report-action` consumes for the PR comment;
// `text` keeps a console summary; `html` lets developers open
// `coverage/index.html` locally for inline drill-down.
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'json-summary', 'html'],
reportsDirectory: 'coverage',
include: ['src/**/*.{ts,tsx}'],
exclude: [
'src/**/*.{test,spec}.{ts,tsx}',
'src/**/*.stories.{ts,tsx}',
'src/__generated__/**',
'src/**/__generated__/**',
'src/index.tsx',
'src/reportWebVitals.ts',
],
},
},
});
15 changes: 15 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,20 @@ export default defineConfig({
"react/**",
"packages/**",
],

// Coverage settings — see comment in `react/vitest.config.ts`. Same
// reporters and provider so the `davelosert/vitest-coverage-report-action`
// PR comment shape is consistent across the three workspaces.
coverage: {
provider: "v8",
reporter: ["text", "json", "json-summary", "html"],
reportsDirectory: "coverage",
include: ["{src,scripts}/**/*.{ts,js,cjs}"],
exclude: [
"{src,scripts}/**/*.{test,spec}.ts",
"src/wsproxy/**",
"src/lib/backend.ai-client-node.*",
],
},
},
});
Loading