diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 42fd2819..fb3be40a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,3 +45,29 @@ jobs: - name: Test run: npm run test + + coverage: + runs-on: ubuntu-latest + name: Report coverage to Codecov + steps: + - name: Checkout + uses: actions/checkout@v2 + + - uses: actions/setup-node@v2 + with: + node-version: '16' + + - name: Setup + run: npm i -g pnpm + + - name: Install + run: pnpm i + + - name: Build + run: npm run build + + - name: Coverage test + run: npm run test:coverage + + - name: Upload coverage to Codecov # https://github.com/codecov/codecov-action + uses: codecov/codecov-action@v1 diff --git a/.gitignore b/.gitignore index cf2f7015..a2e04d27 100644 --- a/.gitignore +++ b/.gitignore @@ -105,4 +105,5 @@ dist # lib/ -temp/ \ No newline at end of file +temp/ +coverage/ \ No newline at end of file diff --git a/README.md b/README.md index 93ef0ce2..15553d58 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,8 @@ A Vite plugin that runs TypeScript, VLS, vue-tsc and other checkers in worker thread. -![npm version](https://img.shields.io/npm/v/vite-plugin-checker) ![downloads/month](https://img.shields.io/npm/dm/vite-plugin-checker) [![Unit Test](https://github.com/fi3ework/vite-plugin-checker/actions/workflows/ci.yml/badge.svg)](https://github.com/fi3ework/vite-plugin-checker/actions/workflows/ci.yml) +[![npm version](https://img.shields.io/npm/v/vite-plugin-checker)](https://www.npmjs.com/package/vite-plugin-checker) [![downloads/month](https://img.shields.io/npm/dm/vite-plugin-checker)](https://www.npmtrends.com/vite-plugin-checker) [![Unit Test](https://github.com/fi3ework/vite-plugin-checker/actions/workflows/ci.yml/badge.svg)](https://github.com/fi3ework/vite-plugin-checker/actions/workflows/ci.yml) +![codecov](https://codecov.io/gh/fi3ework/vite-plugin-checker/branch/master/graph/badge.svg) ## Features diff --git a/jest.config.js b/jest.config.js index 21a652f1..a1ee7e10 100644 --- a/jest.config.js +++ b/jest.config.js @@ -5,6 +5,8 @@ module.exports = { globalTeardown: './scripts/jestGlobalTeardown.js', setupFilesAfterEnv: ['./scripts/jestPerTestSetup.ts'], testTimeout: process.env.CI ? 60000 : 60000, + collectCoverage: true, + collectCoverageFrom: ['packages/*/src/**/*.ts'], transform: { '^.+\\.ts$': 'ts-jest', }, diff --git a/package.json b/package.json index 598b0dd3..4efb37e9 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "dev": "pnpm -r --filter ./packages --parallel run dev", "build": "pnpm -r --filter ./packages run build", "lint": "eslint --ext .js,.ts packages/*/src/**", - "test": "jest --runInBand", + "test": "jest --runInBand --coverage=false", + "test:coverage": "jest --runInBand", "changelog": "pnpm -r --filter ./packages run changelog", "test:watch": "jest -w", "type-check": "pnpm -r --parallel --filter ./packages exec -- tsc --noEmit -p tsconfig.build.json",