Skip to content

Commit

Permalink
Merge pull request #21 from cameronbrill/cb/better-pr-reviews
Browse files Browse the repository at this point in the history
report test coverage in a PR
  • Loading branch information
cameronbrill authored Mar 10, 2024
2 parents aa8dbe1 + 68266ca commit 376514a
Show file tree
Hide file tree
Showing 33 changed files with 660 additions and 19 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,21 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
self: Mergeability

actionlint:
name: lint github actions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: reviewdog/action-actionlint@v1


yarn-check:
name: yarn ${{ matrix.command }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
command: ["lint:ci", "format:ci", "build:scss", "build:ts", "test"]
command: ["lint:ci", "format:ci", "build:scss", "build:ts", "test:coverage"]
steps:
- uses: actions/checkout@v4

Expand All @@ -42,3 +50,12 @@ jobs:
run: yarn ${{ matrix.command }}
env:
FORCE_COLOR: 2
CONDITION: always()
CONDITION2: ${{ matrix.command == 'test:coverage' }}
CONDITION3: ${{ matrix.command == 'test:coverage' }} && always()
- name: 'Report Coverage'
if: matrix.command == 'test:coverage' && always()
uses: davelosert/vitest-coverage-report-action@v2
with:
json-summary-path : './src/__tests__/coverage/coverage-summary.json'

4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
.pnp.js

# testing
/coverage
vitest.config.mts.timestamp-*.mjs
vitest.config.ts.timestamp-*.mjs
html/
src/__tests__/coverage

# production
/build
Expand Down
326 changes: 325 additions & 1 deletion .pnp.cjs

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"vitest.explorer",
"wallabyjs.wallaby-vscode",
"file-icons.file-icons",
"usernamehw.errorlens"
"usernamehw.errorlens",
"ryanluker.vscode-coverage-gutters"
]
}
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
},
"typescript.tsdk": ".yarn/sdks/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true,
"[typescript]": {
"editor.defaultFormatter": "Jota0222.multi-formatter",
"multiFormatter.formatterList": ["biomejs.biome", "esbenp.prettier-vscode"]
},
"[typescriptreact]": {
"editor.defaultFormatter": "Jota0222.multi-formatter",
"multiFormatter.formatterList": ["biomejs.biome", "esbenp.prettier-vscode"]
Expand All @@ -16,5 +20,5 @@
"vitest.watchOnStartup": true,
"vitest.showFailMessages": true,
"vitest.enable": true,
"vitest.commandLine": "yarn test:watch"
"vitest.commandLine": "yarn test:coverage:watch"
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 2 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"ignore": [
".prettierrc.js",
".yarn/*",
"vitest.config.mts"
"vitest.config.mts",
"src/__tests__/coverage/*"
]
},
"linter": {
Expand Down
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
"format": "yarn _conc 'yarn:format:ts:biome' 'yarn:format:ts:imports'",
"format:fix": "yarn format:ts:fix:biome && yarn format:ts:fix:imports",
"test": "vitest run",
"test:watch": "vitest",
"test:coverage": "yarn test --coverage",
"test:watch": "vitest watch",
"test:coverage:watch": "yarn test:watch --coverage",
"test:ui:watch": "vitest watch --ui",
"test:coverage:ui:watch": "yarn test:ui:watch --coverage",
"build:ts": "next build",
"build:ts:watch": "next dev",
"build:scss": "yarn typed-scss-modules src --banner '// This file is automatically generated. Do not edit.'",
Expand Down Expand Up @@ -80,6 +84,8 @@
"@types/lodash": "^4",
"@types/node": "20.11.19",
"@vitejs/plugin-react": "^4.2.1",
"@vitest/coverage-istanbul": "^1.3.1",
"@vitest/ui": "^1.3.1",
"@yarnpkg/sdks": "^3.1.0",
"concurrently": "^8.2.2",
"eslint": "^8.56.0",
Expand Down
36 changes: 29 additions & 7 deletions vitest.config.mts
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
import { defineConfig } from 'vitest/config'
import react from '@vitejs/plugin-react'
import { configDefaults, defineConfig } from "vitest/config";
import react from "@vitejs/plugin-react";

export default defineConfig({
plugins: [react()],
test: {
environment: 'jsdom',
globals:true,
setupFiles: "src/setupTests.ts"
environment: "jsdom",
globals: true,
setupFiles: "src/setupTests.ts",
reporters: ["default", "html", "json"],
coverage: {
exclude: [
...(configDefaults.coverage.exclude || []),
"html/**",
"build/**/*",
".yarn/**/*",
"next.config.js",
"**/.{idea,git,cache,output,temp,yarn}/**",
],
provider: "istanbul",
reporter: ["json", "text", "html", "json-summary", "lcov"],
reportsDirectory: "./src/__tests__/coverage",
reportOnFailure: true,
thresholds: {
autoUpdate: true,
statements: 9,
branches: 5,
functions: 8.57,
lines: 9.37,
},
},
},
})
});
Loading

0 comments on commit 376514a

Please sign in to comment.