From 811ec08e5bdaef714bc0e3fc64ab5a45cc081538 Mon Sep 17 00:00:00 2001 From: Rhuan Barreto Date: Wed, 6 May 2026 22:52:24 +0200 Subject: [PATCH 1/5] ci: add Codecov coverage reporting Generate lcov coverage reports via Bun's built-in --coverage flag and upload them to Codecov on every PR validation run. Uses a validate:coverage script variant so local bun run validate stays fast (no coverage overhead). Signed-off-by: Rhuan Barreto --- .github/workflows/code-pull-request.yml | 9 ++++++++- bunfig.toml | 2 ++ codecov.yml | 25 +++++++++++++++++++++++++ package.json | 4 +++- 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 codecov.yml diff --git a/.github/workflows/code-pull-request.yml b/.github/workflows/code-pull-request.yml index fa57b2cb..ba8312b6 100644 --- a/.github/workflows/code-pull-request.yml +++ b/.github/workflows/code-pull-request.yml @@ -56,7 +56,14 @@ jobs: } - name: Validate id: validate - run: bun run validate + run: bun run validate:coverage + - name: Upload coverage to Codecov + if: always() && steps.validate.outcome == 'success' + uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: coverage/lcov.info + fail_ci_if_error: false - name: Save Bun Cache uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5 if: steps.validate.outcome == 'success' && steps.restore-bun-cache.outputs.cache-hit != 'true' diff --git a/bunfig.toml b/bunfig.toml index 888d3843..df76c1e4 100644 --- a/bunfig.toml +++ b/bunfig.toml @@ -6,3 +6,5 @@ saveTextLockfile = true [test] preload = ["./tests/preload.ts"] +coverageReporter = ["lcov", "text"] +coverageDir = "coverage" diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..d82e50f2 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,25 @@ +codecov: + require_ci_to_pass: true + +coverage: + status: + project: + default: + target: auto + threshold: 1% + patch: + default: + target: 80% + +comment: + layout: "header, diff, flags, components" + behavior: default + require_changes: true + require_base: false + require_head: true + +ignore: + - "docs/**" + - "scripts/**" + - "tests/**" + - ".archgate/**" diff --git a/package.json b/package.json index 78ff734d..e9ca9473 100644 --- a/package.json +++ b/package.json @@ -50,9 +50,11 @@ "lint": "oxlint --deny-warnings .", "postinstall": "node scripts/postinstall.cjs", "test": "bun test --timeout 60000", + "test:coverage": "bun test --timeout 60000 --coverage", "test:watch": "bun test --watch --timeout 60000", "typecheck": "tsc --build", - "validate": "bun run lint && bun run typecheck && bun run format:check && bun run test && bun run check && bun run build:check" + "validate": "bun run lint && bun run typecheck && bun run format:check && bun run test && bun run check && bun run build:check", + "validate:coverage": "bun run lint && bun run typecheck && bun run format:check && bun run test:coverage && bun run check && bun run build:check" }, "devDependencies": { "@commander-js/extra-typings": "14.0.0", From 55297f1105965dfb4a994ac24b7660f6cbf800db Mon Sep 17 00:00:00 2001 From: Rhuan Barreto Date: Wed, 6 May 2026 22:57:21 +0200 Subject: [PATCH 2/5] ci: add Codecov test analytics via JUnit XML reports Generate JUnit XML test results alongside lcov coverage using Bun's built-in --reporter=junit flag. Upload to Codecov Test Analytics for test run time tracking and flaky test detection. Signed-off-by: Rhuan Barreto --- .github/workflows/code-pull-request.yml | 8 ++++++++ package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/code-pull-request.yml b/.github/workflows/code-pull-request.yml index ba8312b6..cd26145f 100644 --- a/.github/workflows/code-pull-request.yml +++ b/.github/workflows/code-pull-request.yml @@ -64,6 +64,14 @@ jobs: token: ${{ secrets.CODECOV_TOKEN }} files: coverage/lcov.info fail_ci_if_error: false + - name: Upload test results to Codecov + if: always() && steps.validate.outcome != 'skipped' + uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: coverage/junit.xml + report-type: test_results + fail_ci_if_error: false - name: Save Bun Cache uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5 if: steps.validate.outcome == 'success' && steps.restore-bun-cache.outputs.cache-hit != 'true' diff --git a/package.json b/package.json index e9ca9473..2bfbab58 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "lint": "oxlint --deny-warnings .", "postinstall": "node scripts/postinstall.cjs", "test": "bun test --timeout 60000", - "test:coverage": "bun test --timeout 60000 --coverage", + "test:coverage": "bun test --timeout 60000 --coverage --reporter=junit --reporter-outfile=coverage/junit.xml", "test:watch": "bun test --watch --timeout 60000", "typecheck": "tsc --build", "validate": "bun run lint && bun run typecheck && bun run format:check && bun run test && bun run check && bun run build:check", From 011e5ad94d9550e46b7f91b734c2b17b6af533bd Mon Sep 17 00:00:00 2001 From: Rhuan Barreto Date: Wed, 6 May 2026 23:00:05 +0200 Subject: [PATCH 3/5] ci: run validation workflow on push to main Codecov needs a baseline coverage report on the main branch to compute diffs on PRs. Add push trigger to the validation workflow so coverage is uploaded after each merge to main. Signed-off-by: Rhuan Barreto --- .github/workflows/code-pull-request.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/code-pull-request.yml b/.github/workflows/code-pull-request.yml index cd26145f..09b397b2 100644 --- a/.github/workflows/code-pull-request.yml +++ b/.github/workflows/code-pull-request.yml @@ -1,6 +1,9 @@ name: Validate on: + push: + branches: + - main pull_request: types: [opened, edited, synchronize, reopened] branches: From 3af07dbb9178c2c049f01fae2385b077e756cad3 Mon Sep 17 00:00:00 2001 From: Rhuan Barreto Date: Wed, 6 May 2026 23:00:42 +0200 Subject: [PATCH 4/5] Revert "ci: run validation workflow on push to main" This reverts commit 011e5ad94d9550e46b7f91b734c2b17b6af533bd. Signed-off-by: Rhuan Barreto --- .github/workflows/code-pull-request.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/code-pull-request.yml b/.github/workflows/code-pull-request.yml index 09b397b2..cd26145f 100644 --- a/.github/workflows/code-pull-request.yml +++ b/.github/workflows/code-pull-request.yml @@ -1,9 +1,6 @@ name: Validate on: - push: - branches: - - main pull_request: types: [opened, edited, synchronize, reopened] branches: From 1599263b6dd12f9fc4c8585a73b6af30c6e26e3f Mon Sep 17 00:00:00 2001 From: Rhuan Barreto Date: Wed, 6 May 2026 23:01:13 +0200 Subject: [PATCH 5/5] ci: upload coverage and test results from release workflow The release workflow runs validation on push to main. Add coverage and test results uploads here so Codecov has a baseline report on the main branch for computing PR diffs. Signed-off-by: Rhuan Barreto --- .github/workflows/release.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e830be24..377997db 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -152,7 +152,22 @@ jobs: run: bun install --frozen-lockfile - name: Validate id: validate - run: bun run validate + run: bun run validate:coverage + - name: Upload coverage to Codecov + if: always() && steps.validate.outcome == 'success' + uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: coverage/lcov.info + fail_ci_if_error: false + - name: Upload test results to Codecov + if: always() && steps.validate.outcome != 'skipped' + uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: coverage/junit.xml + report-type: test_results + fail_ci_if_error: false - name: Ensure main is up-to-date before release run: git pull --rebase origin main - name: Release