Skip to content

setup(coverage): add per-package test coverage reporting via codecov #82

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

JakobJingleheimer
Copy link
Member

Resolves #80

@JakobJingleheimer JakobJingleheimer requested a review from Copilot June 3, 2025 17:01
@JakobJingleheimer JakobJingleheimer added the github_actions Pull requests that update GitHub Actions code label Jun 3, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds per-package test coverage reporting via Codecov by updating the CI workflow and introducing a Codecov configuration.

  • Introduces a new CI step to upload coverage reports to Codecov.
  • Adds .github/codecov.yml to define coverage thresholds, flags, and comment behavior.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
.github/workflows/ci.yml Added “Upload coverage” step using codecov/codecov-action
.github/codecov.yml New Codecov config with per-package flags and status settings

Comment on lines +103 to +105
with:
directory: ./recipes
files: ./coverage.lcov
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
with:
directory: ./recipes
files: ./coverage.lcov
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./recipes
files: ./coverage.lcov

@AugustinMauroy
Copy link
Member

AugustinMauroy commented Jun 4, 2025

you I'll need to add token in the repo secret (action)
you can get it here: https://app.codecov.io/gh/nodejs/userland-migrations/new

@AugustinMauroy
Copy link
Member

can we have badge for each recipes ?

@JakobJingleheimer JakobJingleheimer marked this pull request as draft June 4, 2025 09:28
@JakobJingleheimer
Copy link
Member Author

This is blocked by node's handling of the --test flag, which makes nesting commands impossible because earlier flags get appended to the end of the subsequent command, and --test must be last but also must be set in the most subsequent command, creating a paradox:

CLI → root pjson → recipe pjson

In order for recipe pjson's test command to be runnable on its own (what recipe authors will expect / want), --test must be specified in recipe pjson. That causes root pjson's passed args to be appended to recipe pjson, and CLI's flags to get appended after that, super breaking recipe pjson when run in CI.

This could be fixed in node with either:

@AugustinMauroy
Copy link
Member

other solution (done on nodejs/nodejs.org) having one test:coverage script by recipes and on root doing something like turbo test:coverage to run all test from each recipes independently so we will have N .lcov file.

@JakobJingleheimer
Copy link
Member Author

That's what this currently does, just via npm --workspaces instead of turbo

@AugustinMauroy
Copy link
Member

oh right

"start": "node --no-warnings --experimental-import-meta-resolve --experimental-strip-types ./src/workflow.ts",
"test": "node --no-warnings --experimental-import-meta-resolve --experimental-test-module-mocks --experimental-test-snapshots --experimental-strip-types --import='../../test/snapshots.ts' --test --experimental-test-coverage --test-coverage-include='src/**/*' --test-coverage-exclude='**/*.test.ts' './**/*.test.ts'"
"start": "node --no-warnings --experimental-import-meta-resolve ./src/workflow.ts",
"test": "node --no-warnings --experimental-import-meta-resolve --experimental-test-module-mocks --experimental-test-snapshots --import='../../test/snapshots.ts' --test-coverage-include='src/**/*' --test-coverage-exclude='**/*.test.ts' --test './**/*.test.ts'"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"test": "node --no-warnings --experimental-import-meta-resolve --experimental-test-module-mocks --experimental-test-snapshots --import='../../test/snapshots.ts' --test-coverage-include='src/**/*' --test-coverage-exclude='**/*.test.ts' --test './**/*.test.ts'"
"test": "node --no-warnings --experimental-import-meta-resolve --experimental-test-module-mocks --experimental-test-snapshots --import='../../test/snapshots.ts' --test-reporter=spec --test-reporter-destination=stdout --test './**/*.test.ts'",
"test:coverage": "node --no-warnings --experimental-import-meta-resolve --experimental-test-module-mocks --experimental-test-snapshots --import='../../test/snapshots.ts' --test-reporter=lcov --test-reporter-destination=./coverage.lcov --test-reporter=spec --test-reporter-destination=stdout --test-coverage-include='src/**/*' --test-coverage-exclude='**/*.test.ts' --test './**/*.test.ts'"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and run test:coverage on CI

Copy link
Member Author

@JakobJingleheimer JakobJingleheimer Jun 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we could brute-force it like this. But that doesn't allow recipe authors to set extra flags / enable other features they may need.

I think better to just wait a couple weeks for the config options PR to land.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both can work. I like to "hard-code" lcov output (I had done that on all of my packages) but other way can work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
github_actions Pull requests that update GitHub Actions code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

report code coverage
2 participants