Skip to content

Commit

Permalink
add github action to vitest coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Bricks666 committed Jul 2, 2024
1 parent 20b5354 commit 0fe349c
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/report-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Report Coverage

on:
workflow_run:
workflows: ["Run tests"]
types:
- completed

jobs:
report-coverage:
runs-on: ubuntu-latest

permissions:
pull-requests: write

steps:
- name: "Download Branch Coverage Artifacts"
uses: actions/download-artifact@v4
with:
name: coverage-${{ github.head_ref }}
path: coverage

- name: "Download Main Coverage Artifacts"
- uses: actions/download-artifact@v4
with:
name: coverage-main
path: coverage-main

- name: "Report Coverage"
uses: davelosert/vitest-coverage-report-action@v2
with:
json-summary-compare-path: coverage-main/coverage-summary.json
43 changes: 43 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Run tests

on:
push:
branches: ['main', 'develop']
pull_request:

jobs:
test:
runs-on: ubuntu-latest

permissions:
contents: read

strategy:
matrix:
branch:
- ${{ github.head_ref }}
- 'main'

steps:
- uses: actions/checkout@v4
with:
ref: ${{ matrix.branch }}

- name: Install Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'

- name: Install deps
- run: npm ci

- name: Run tests
- run: npm test:coverage

- name: 'Upload Coverage'
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.branch }}
path: coverage
10 changes: 10 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ export default defineConfig({
include: ['./src/**/*.spec.{ts,tsx}'],
clearMocks: true,
globals: true,
coverage: {
reporter: ['text', 'json-summary', 'json'],
reportOnFailure: true,
thresholds: {
lines: 60,
branches: 60,
functions: 60,
statements: 60,
},
},
},
resolve: {
alias: {
Expand Down

0 comments on commit 0fe349c

Please sign in to comment.