Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to add codecov. #15

Merged
merged 6 commits into from
Oct 29, 2024
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
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Codecov
on:
push:
branches: [ "*" ]
jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'

- name: Install dependencies
run: npm install

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

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }} # Required if the repo is private
files: ./coverage/lcov.info # Path to the lcov report
flags: unittests # Optional: Flag for specific test type
name: codecov-umbrella # Optional: Custom name for coverage report
fail_ci_if_error: true # Optional: Fail CI if upload fails
Empty file added .gitignore
Empty file.
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"devDependencies": {
"@vitest/coverage-v8": "^2.1.4",
"vitest": "^2.1.4"
},
"scripts": {
"test": "vitest"
}
}
7 changes: 7 additions & 0 deletions tests/sample.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { describe, it, expect } from 'vitest';

describe('Sample Test', () => {
it('should pass', () => {
expect(true).toBe(true);
});
});
13 changes: 13 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { defineConfig } from 'vite';
import { configDefaults } from 'vitest/config';

export default defineConfig({
test: {
include: ['tests/**/*.test.ts'], // Adjust this to your test file location
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'lcov'],
reportsDirectory: './coverage',
},
},
});
Loading