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

Supporting coverage plugins #419

Open
phrfpeixoto opened this issue May 29, 2024 · 6 comments
Open

Supporting coverage plugins #419

phrfpeixoto opened this issue May 29, 2024 · 6 comments

Comments

@phrfpeixoto
Copy link

Is there any way to support coverage plugins?

My .coveragerc file uses the django_coverage_plugin plugin

[run]
relative_files = True
branch = True
plugins = django_coverage_plugin

And I get this error when running the workflow:

Traceback (most recent call last):
  File "/workdir/coverage_comment/subprocess.py", line 22, in run
    return subprocess.run(
           ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '('coverage', 'json', '-o', '-')' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/workdir/coverage_comment/main.py", line 44, in main
    exit_code = action(
                ^^^^^^^
  File "/workdir/coverage_comment/main.py", line 96, in action
    return process_pr(
           ^^^^^^^^^^^
  File "/workdir/coverage_comment/main.py", line 127, in process_pr
    _, coverage = coverage_module.get_coverage_info(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workdir/coverage_comment/coverage.py", line 99, in get_coverage_info
    subprocess.run("coverage", "json", "-o", "-", path=coverage_path)
  File "/workdir/coverage_comment/subprocess.py", line 36, in run
    raise SubProcessError("\n".join([exc.stderr, exc.stdout])) from exc
coverage_comment.subprocess.SubProcessError: Traceback (most recent call last):
  File "/usr/local/bin/coverage", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.12/site-packages/coverage/cmdline.py", line 970, in main
    status = CoverageScript().command_line(argv)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/coverage/cmdline.py", line 704, in command_line
    self.coverage.load()
  File "/usr/local/lib/python3.12/site-packages/coverage/control.py", line 501, in load
    self._init()
  File "/usr/local/lib/python3.12/site-packages/coverage/control.py", line [34](https://github.com/myollie/olliemain/actions/runs/9292185517/job/25572489665?pr=10274#step:13:35)3, in _init
    self._plugins = Plugins.load_plugins(self.config.plugins, self.config, self._debug)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/coverage/plugin_support.py", line 55, in load_plugins
    __import__(module)
ModuleNotFoundError: No module named 'django_coverage_plugin'
@ewjoachim
Copy link
Member

it makes sense, as coverage doesn't run in your env but in the action's own dockerized env.

This caused #370 in the past, and the only way forward I'd see would be doing #347 (which is likely quite some work).

Do you have a better idea?

@phrfpeixoto
Copy link
Author

The best option would be to allow custom package installation, through one of the options set on the action.
The entrypoint script would check for that, and install them on demand.

@ewjoachim
Copy link
Member

This would probably lead to a slower action start for users of this feature. It's not a problem per se, but let's keep that in mind.

Also, I imagine we'd soon have people requesting the ability to install custom apt packages because they need them for the python packages etc.

I wonder if there could be a way to select a custom base image instead...

@phrfpeixoto
Copy link
Author

That's actually a good call. Why don't we update the base image to include the top 10 most used coverage.py plugins?

@ewjoachim
Copy link
Member

Do you want to compare the current base image with, say, what it would be if we installed the plugins advertised in the coverage lib? I'm ok going this way this if this doesn't add more than 30% to the size of the image (gotta put the threshold somewhere).

(haha we're featured on that page, I didn't know that 😅)

@phrfpeixoto
Copy link
Author

I'll try to have a look on that this weekend.

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