Skip to content

fix: Add COVERAGE_RCFILE to accept customized .coveragerc #2846

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

nlou9
Copy link

@nlou9 nlou9 commented Apr 30, 2025

Revisit this closed issue, #1217.
We still face the same issue. Inspired by the comments in the issue thread, we add a COVERAGE_RCFILE environment variable to be able to pass the customized .coveragerc file.

In our own project, we patched this way, and it resolved our issue.

py_test(
    name = "test_utils",
    srcs = ["test_utils.py"],
    data = ["//:.coveragerc"],
    env = {
        "COVERAGE_RCFILE": "$(location //:.coveragerc)",
    },
    deps = [
        ":conftest",
        "//tests/data",
    ],
)

@nlou9 nlou9 marked this pull request as ready for review April 30, 2025 19:34
@nlou9 nlou9 requested review from rickeylev and aignas as code owners April 30, 2025 19:34
@aignas
Copy link
Collaborator

aignas commented May 15, 2025

I see that you are continuously pushing updates to this PR and thought I'd give a few thoughts about the possibility to merge this.

The things that I think this feature would need are:

  • Supporting bootstrap=script code paths in the same way.
  • Having extra documentation in the docs folder about this feature.
  • Copying the referenced file so that the srcs can be populated by rules_python. This is to ensure that coverage report is correct. I am not sure how exactly this could work from the user point of view.
  • CHANGELOG updates once we have the design above done/ready.

Open questions about the interface:

  • Should we have something like --@rules_python//python/config:coveragerc label flag instead of env variables? I personally would prefer that and users could use transitions to force a particular coveragerc value if needed.

There are probably a few other things that are missing in my quick analysis, so happy to hear other thoughts about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants