diff --git a/.github/workflows/report-coverage.yml b/.github/workflows/report-coverage.yml new file mode 100644 index 00000000..118f1f0e --- /dev/null +++ b/.github/workflows/report-coverage.yml @@ -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 diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 00000000..980d8b6e --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -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 diff --git a/vitest.config.ts b/vitest.config.ts index 235ff94f..534cb25a 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -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: {