Skip to content
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

bazel coverage failure 0.9.0 -> 0.10.0 #74

Open
rajukrishnamurthy opened this issue Feb 2, 2025 · 2 comments
Open

bazel coverage failure 0.9.0 -> 0.10.0 #74

rajukrishnamurthy opened this issue Feb 2, 2025 · 2 comments

Comments

@rajukrishnamurthy
Copy link

Hi I'm attempting to upgrade rules_opa from 0.9.0 to 0.10.0. It looks like coverage support was added in 0.10.0, however, I can't seem to make it work. The tests without coverage are passing, but with coverage, I'm getting:

% bazel coverage --combined_report=lcov  //my_project:opa_lib_test
INFO: Build option --instrumentation_filter has changed, discarding analysis cache.
INFO: Analyzed target //my_project:opa_lib_test (0 packages loaded, 3783 targets configured).
INFO: Found 1 test target...
FAIL: //my_project:opa_lib_test (see /tmp/bazel_cache/execroot/videoamp/bazel-out/darwin_arm64-fastbuild/testlogs/my_project/opa_lib_test/test.log)
INFO: From Testing //my_project:opa_lib_test:
==================== Test output for //my_project:opa_lib_test:
Traceback (most recent call last):
  File "/tmp/bazel_cache/sandbox/darwin-sandbox/11969/execroot/videoamp/bazel-out/darwin_arm64-fastbuild/bin/my_project/opa_lib_test_test.sh.runfiles/rules_opa/tools/opa_coverage.py", line 109, in <module>
    main(sys.argv)
  File "/tmp/bazel_cache/sandbox/darwin-sandbox/11969/execroot/videoamp/bazel-out/darwin_arm64-fastbuild/bin/my_project/opa_lib_test_test.sh.runfiles/rules_opa/tools/opa_coverage.py", line 87, in main
    result = CoverageReport.from_dict(json.loads(proc.stdout))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/bazel_cache/sandbox/darwin-sandbox/11969/execroot/videoamp/bazel-out/darwin_arm64-fastbuild/bin/my_project/opa_lib_test_test.sh.runfiles/rules_opa/tools/opa_coverage.py", line 63, in from_dict
    files={
          ^
  File "/tmp/bazel_cache/sandbox/darwin-sandbox/11969/execroot/videoamp/bazel-out/darwin_arm64-fastbuild/bin/my_project/opa_lib_test_test.sh.runfiles/rules_opa/tools/opa_coverage.py", line 64, in <dictcomp>
    file: CoverageFile.from_dict(report)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/bazel_cache/sandbox/darwin-sandbox/11969/execroot/videoamp/bazel-out/darwin_arm64-fastbuild/bin/my_project/opa_lib_test_test.sh.runfiles/rules_opa/tools/opa_coverage.py", line 49, in from_dict
    coverage=float(data.get("coverage")),
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: float() argument must be a string or a real number, not 'NoneType'

I've tried this on several architectures, and we're still on bazel 6.2.1 which might be the problem.

@ffortier
Copy link
Contributor

ffortier commented Feb 2, 2025

Hello, which version of opa do you use?

I'm managed to get a working setup with bazel 6.2.1 in this repo using the legacy WORKSPACE setup and the current default 0.65.0. You can check the branch bazel-6.2.1-coverage and run bazel coverage //examples/... --combined_report=lcov. It works.

Can you reproduce your issue in github with a minimal setup that I can look at?

@rajukrishnamurthy
Copy link
Author

Hi, we're just using the default, so 0.65.0.

Our setup is pretty involved, but I will give it a stab later this week.

Just taking a quick look at your WORKSPACE file was curious if you think the versions of rules_python or protobuf would matter? For rules_python, we're on 0.39 with python 3.11 as the default. protobuf is pretty old 27.x. I'm the process of upgrading those, so perhaps this is something that is self correcting. Also, we don't pull in rules_cc or llvm, but I doubt that would make any difference.

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

No branches or pull requests

2 participants