From 30915555fa2fe8d68edf32cdb813d995ab381274 Mon Sep 17 00:00:00 2001 From: MT Date: Tue, 29 Oct 2024 10:19:38 +0100 Subject: [PATCH 1/6] Try to add codecov. --- .circleci/config.yml | 23 +++++++++++++++++++++++ .github/workflows/ci.yml | 20 ++++++++++++++++++++ .gitignore | 0 3 files changed, 43 insertions(+) create mode 100644 .circleci/config.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .gitignore diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..bbf5e5f --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,23 @@ +version: 2.1 +orbs: + codecov: codecov/codecov@3 + +jobs: + build: + docker: + - image: cimg/node:current + steps: + - checkout + - run: + name: Install dependencies + command: npm install + - run: + name: Run tests and collect coverage + command: npm run test + - codecov/upload + +workflow: + version: 2.1 + build-test: + jobs: + - build \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..91c661b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,20 @@ +name: Workflow for Codecov example-typescript +on: [push, pull_request] +jobs: + run: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Node 18 + uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Install dependencies + run: npm install + - name: Run tests and collect coverage + run: npm run test + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 From 5f5a6bcb969a239f9ce17efe50b7ea03210d97a3 Mon Sep 17 00:00:00 2001 From: MT Date: Tue, 29 Oct 2024 10:32:58 +0100 Subject: [PATCH 2/6] Try to add codecov. --- .circleci/config.yml | 23 ----------------------- .github/workflows/ci.yml | 33 ++++++++++++++++++++++----------- package.json | 6 ++++++ vite.config.ts | 12 ++++++++++++ 4 files changed, 40 insertions(+), 34 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 package.json create mode 100644 vite.config.ts diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index bbf5e5f..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,23 +0,0 @@ -version: 2.1 -orbs: - codecov: codecov/codecov@3 - -jobs: - build: - docker: - - image: cimg/node:current - steps: - - checkout - - run: - name: Install dependencies - command: npm install - - run: - name: Run tests and collect coverage - command: npm run test - - codecov/upload - -workflow: - version: 2.1 - build-test: - jobs: - - build \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 91c661b..356e408 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,20 +1,31 @@ name: Workflow for Codecov example-typescript -on: [push, pull_request] +on: + push: + branches: [ "*" ] jobs: - run: + test: runs-on: ubuntu-latest + steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Set up Node 18 + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Node.js uses: actions/setup-node@v3 with: - node-version: 18 + node-version: '18' + - name: Install dependencies run: npm install - - name: Run tests and collect coverage - run: npm run test + + - name: Run tests and generate coverage + run: npm run test -- --coverage + - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4 - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file + 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 \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..658b1c2 --- /dev/null +++ b/package.json @@ -0,0 +1,6 @@ +{ + "devDependencies": { + "@vitest/coverage-v8": "^2.1.4", + "vitest": "^2.1.4" + } +} diff --git a/vite.config.ts b/vite.config.ts new file mode 100644 index 0000000..38b1692 --- /dev/null +++ b/vite.config.ts @@ -0,0 +1,12 @@ +import { defineConfig } from 'vite'; +import { configDefaults } from 'vitest/config'; + +export default defineConfig({ + test: { + coverage: { + provider: 'v8', + reporter: ['text', 'json', 'lcov'], + reportsDirectory: './coverage', // default path for coverage output + }, + }, +}); \ No newline at end of file From f8dba3ab4e9e9c77359f5103c9d7132939bd49ac Mon Sep 17 00:00:00 2001 From: MT Date: Tue, 29 Oct 2024 10:35:44 +0100 Subject: [PATCH 3/6] Try to add codecov. --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index 658b1c2..acf5827 100644 --- a/package.json +++ b/package.json @@ -2,5 +2,8 @@ "devDependencies": { "@vitest/coverage-v8": "^2.1.4", "vitest": "^2.1.4" + }, + "scripts": { + "test": "vitest --coverage" } } From aa595209229bea7cc9a8b9e671b7ed6087107160 Mon Sep 17 00:00:00 2001 From: MT Date: Tue, 29 Oct 2024 10:36:54 +0100 Subject: [PATCH 4/6] Try to add codecov. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index acf5827..702ae26 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,6 @@ "vitest": "^2.1.4" }, "scripts": { - "test": "vitest --coverage" + "test": "vitest" } } From 1137fc43c798706d3a3c0c4bce1f291de13b9488 Mon Sep 17 00:00:00 2001 From: MT Date: Tue, 29 Oct 2024 10:40:25 +0100 Subject: [PATCH 5/6] Try to add codecov. --- tests/sample.test.ts | 7 +++++++ vite.config.ts | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 tests/sample.test.ts diff --git a/tests/sample.test.ts b/tests/sample.test.ts new file mode 100644 index 0000000..631ca0d --- /dev/null +++ b/tests/sample.test.ts @@ -0,0 +1,7 @@ +import { describe, it, expect } from 'vitest'; + +describe('Sample Test', () => { + it('should pass', () => { + expect(true).toBe(true); + }); +}); diff --git a/vite.config.ts b/vite.config.ts index 38b1692..7d1fc13 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -3,10 +3,11 @@ 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', // default path for coverage output + reportsDirectory: './coverage', }, }, }); \ No newline at end of file From 4bcf5894ac40e6df715edb51a2fd51649dc55db1 Mon Sep 17 00:00:00 2001 From: MT Date: Tue, 29 Oct 2024 10:47:31 +0100 Subject: [PATCH 6/6] Try to add codecov. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 356e408..a030ea8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: Workflow for Codecov example-typescript +name: Codecov on: push: branches: [ "*" ]