Update ci.yml #71
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Codecov CI with Vitest | |
| on: [push, pull_request] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: 18 | |
| - name: Clean install vitest 3.x directly (force fresh state) | |
| run: | | |
| rm -rf node_modules package-lock.json | |
| npm install vitest@latest | |
| - name: Add vitest-junit reporter (built-in, no extra install needed) | |
| run: | | |
| echo "{}" > package.json | |
| npm install vitest@latest | |
| - name: Install dependencies (optional if you have others) | |
| run: npm install | |
| - name: Create vitest config (if not checked in already) | |
| run: | | |
| mkdir -p test | |
| echo "import { defineConfig } from 'vitest/config' | |
| export default defineConfig({ | |
| test: { | |
| coverage: { | |
| reporters: ['text', 'json', 'html', 'lcov'], | |
| reportDir: 'coverage' | |
| }, | |
| reporters: [ | |
| 'default', | |
| ['junit', { outputFile: 'junit.xml' }] | |
| ] | |
| } | |
| })" > vitest.config.ts | |
| - name: Run tests with coverage | |
| run: npm run test || true # Don't fail the build if tests fail (Codecov still collects) | |
| - name: Upload code coverage to Codecov | |
| uses: codecov/codecov-action@v5 | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }} | |
| - name: Upload test results to Codecov | |
| if: ${{ !cancelled() }} | |
| uses: codecov/test-results-action@v1 | |
| with: | |
| token: ${{ secrets.CODECOV_ORG_TOKEN }} |