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

Using for Python code and coverage.py #4

Closed
aodj opened this issue Aug 18, 2019 · 19 comments
Closed

Using for Python code and coverage.py #4

aodj opened this issue Aug 18, 2019 · 19 comments

Comments

@aodj
Copy link

aodj commented Aug 18, 2019

I was just looking into this for use in the GitHub actions beta, and covering my Python code, but it looks like the coverage tooling for Python doesn't support lcov output (ie running coverage.py via pytest-cov on pytest unittests).

I know that the coveralls Python library can interface with the coveralls.io API, so I'm curious what the suggested solution might be.

Any ideas?

@nickmerwin
Copy link
Member

Hi @aodj, could you try the steps described here:

https://github.com/coveralls-clients/coveralls-python/blob/master/docs/usage/multilang.rst

e.g.:

coveralls --output=coverage.json
coveralls-lcov -v -n coverage.info > coverage.json

Then use "./coverage.json" as the path-to-lcov input for the Coveralls Action.

Let me know how it goes, thanks!

@aodj aodj changed the title Using for Python code an coverage.py Using for Python code and coverage.py Aug 20, 2019
@aodj
Copy link
Author

aodj commented Aug 20, 2019

I'll give it a try, but is installing and running a Ruby gem the only option here? I've previously used a workflow on Travis that simply invokes the coveralls tool which uploads the output from coverage.py, which is nice since it's simply a case of installing an extra Python lib.

@aodj
Copy link
Author

aodj commented Aug 20, 2019

I think I'm missing something; the coveralls-lcov tool doesn't output LCOV formatted data. It consumes LCOV data to output json Looking at the coveralls Python library, is it not possible to use the api/v1/jobs endpoint since that appears to consume the more common JSON format instead of LCOV:

@aodj
Copy link
Author

aodj commented Sep 1, 2019

Any more thoughts on using the action with Python?

@aodj
Copy link
Author

aodj commented Sep 9, 2019

Just to keep this ticket up-to-date I gave up with this action, and just used the coveralls Python package. Workflow for reference.

@aodj aodj closed this as completed Sep 9, 2019
@mikkokotila
Copy link

@aodj dead simple approach solves the issue. Which raises an important question; how come the official version from the company itself, does not work?

@hakonanes
Copy link

However, running just coveralls on a pull_request event does not prompt Coveralls.io to later on to add a comment to the PR, even though it is enabled in the Coveralls.io settings?

@abhinavsingh
Copy link

This probably should be re-opened or at-least put instructions for Python integration upfront in README.

abhinavsingh added a commit to abhinavsingh/proxy.py that referenced this issue Oct 13, 2019
abhinavsingh added a commit to abhinavsingh/proxy.py that referenced this issue Oct 13, 2019
@jvesely
Copy link

jvesely commented Oct 28, 2019

Running just coveralls in github actions reports branch HEAD. I ended up with:

    - name: Coveralls
      run: |
        CI_BRANCH=${GITHUB_REF#"ref/heads"} coveralls
      shell: bash

@hakonanes, There's also CI_PULL_REQUEST env var that you can set to something from ${{ github.event }} context or parse it out of the file at $GITHUB_EVENT_PATH

@ly-cultureiq
Copy link

if nickmerwin/node-coveralls#243 gets merged - i have a simple pr to add pytest and coverage.py support

wjt added a commit to flathub-infra/flatpak-external-data-checker that referenced this issue Dec 6, 2019
We cannot easily use the official GitHub Action from
https://github.com/marketplace/actions/coveralls-github-action because
it expects its input to be in LCOV format, which is not what coverage.py
emits. See coverallsapp/github-action#4 for
more discussion about this.

If coverallsapp/github-action#25 were merged to
support the Cobertura XML format, then `coverage xml` could be used to
generate that format. Since it's not, it's simplest to just install the
Python client for coveralls from PyPI.
wjt added a commit to flathub-infra/flatpak-external-data-checker that referenced this issue Dec 18, 2019
We cannot easily use the official GitHub Action from
https://github.com/marketplace/actions/coveralls-github-action because
it expects its input to be in LCOV format, which is not what coverage.py
emits. See coverallsapp/github-action#4 for
more discussion about this.

If coverallsapp/github-action#25 were merged to
support the Cobertura XML format, then `coverage xml` could be used to
generate that format. Since it's not, it's simplest to just install the
Python client for coveralls from PyPI.
wjt added a commit to flathub-infra/flatpak-external-data-checker that referenced this issue Dec 18, 2019
We cannot easily use the official GitHub Action from
https://github.com/marketplace/actions/coveralls-github-action because
it expects its input to be in LCOV format, which is not what coverage.py
emits. See coverallsapp/github-action#4 for
more discussion about this.

If coverallsapp/github-action#25 were merged to
support the Cobertura XML format, then `coverage xml` could be used to
generate that format. Since it's not, it's simplest to just install the
Python client for coveralls from PyPI.
wjt added a commit to flathub-infra/flatpak-external-data-checker that referenced this issue Dec 18, 2019
We cannot easily use the official GitHub Action from
https://github.com/marketplace/actions/coveralls-github-action because
it expects its input to be in LCOV format, which is not what coverage.py
emits. See coverallsapp/github-action#4 for
more discussion about this.

If coverallsapp/github-action#25 were merged to
support the Cobertura XML format, then `coverage xml` could be used to
generate that format. Since it's not, it's simplest to just install the
Python client for coveralls from PyPI.
benbovy added a commit to xarray-contrib/xarray-simlab that referenced this issue Dec 30, 2019
barthalion pushed a commit to flathub-infra/flatpak-external-data-checker that referenced this issue Jan 2, 2020
We cannot easily use the official GitHub Action from
https://github.com/marketplace/actions/coveralls-github-action because
it expects its input to be in LCOV format, which is not what coverage.py
emits. See coverallsapp/github-action#4 for
more discussion about this.

If coverallsapp/github-action#25 were merged to
support the Cobertura XML format, then `coverage xml` could be used to
generate that format. Since it's not, it's simplest to just install the
Python client for coveralls from PyPI.
@bboe
Copy link

bboe commented Jan 5, 2020

For anyone following this issue, I was able to get parallel builds to work with python-coveralls coveralls-python (https://github.com/coveralls-clients/coveralls-python) and using this action just for the parallel-finish step.

See my workflow modification here: praw-dev/prawtools@bb0e00b

Note getting this to work does depend on the changes here: https://github.com/coveralls-clients/coveralls-python/pull/216/files

Edit: thanks for the correction @agonholm

@agronholm
Copy link

agronholm commented Jan 6, 2020

Just to un-confused others reading this: @bboe did not actually use python-coveralls (which is a separate client for coveralls.io), but a modified version of coveralls-python (available as coveralls on the PyPI).

This combination worked for me too. Let's hope the PR gets merged.

benbovy added a commit to xarray-contrib/xarray-simlab that referenced this issue Mar 12, 2020
* add test workflow

* fix lint workflow triggered twice

* fix env file not found

* pytest output in colors

* custom matrix builds

* add xarray-dev and attrs-dev to test matrix

* add coveralls

* fix if line

* try fix coverage data sent to coveralls

* use python-coveralls instead of the github action

see
coverallsapp/github-action#4 (comment)

* run coveralls only for py37 environment

* build only docs on travis

* install pytest-cov and converalls using conda

* try fix coveralls command not found

* add doc workflow

* switch to codecov

* add codecov config

* codecov comment still shown?

* use codecov action

* update badges

* update release notes

* remove travis yaml

* gitignore mypy cache
@agronholm
Copy link

@bboe has your PR actually been merged? I tried with coveralls 2.0.0 and, unlike your version, it didn't work without using the coveralls token instead of the github token due to the 422 Unprocessable Entity error which is mentioned in the docs. And then, trying to use the official action to finish the parallel build, it fails due to an error like No build matching CI build number 111541185 found.

@agronholm
Copy link

I'm getting the same error even with the exact same version I used to use before, so I'm guessing something has changed upstream. Now I have absolutely no clue how to get this to work.

@casperdcl
Copy link

casperdcl commented Nov 15, 2020

looks like https://github.com/AndreMiras/coveralls-python-action is a viable replacement for coverallsapp/github-action (and AndreMiras/coveralls-python-action#5 will even allow parallel builds).

jamadden added a commit to gevent/gevent that referenced this issue Nov 24, 2020
per coverallsapp/github-action#4 (comment)

The PyPI CLI doesn't work.

Python 2 with coveralls 1.11 just produces a 422 error.
Python 3 with 2.2 produces an error on a retry after a 422.

  File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/coveralls/cli.py", line 85, in main
    result = coverallz.wear()
  File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/coveralls/api.py", line 225, in wear
    self.config['service_job_id'], random.randint(0, sys.maxsize))
KeyError: 'service_job_id'
lukpueh added a commit to lukpueh/tuf that referenced this issue Dec 15, 2020
TODO:
Needs more troubleshooting:
- Official coveralls action does not seem to work well for Python
coverallsapp/github-action#4
coverallsapp/github-action#30
- Official coveralls cli triggers 500 on coveralls.io
- Inofficial coveralls action seems to correctly talk to the API
  but has issues finding the coverage data in the tests folder,
  or the corresponding code.
  https://github.com/AndreMiras/coveralls-python-action
lukpueh added a commit to lukpueh/tuf that referenced this issue Dec 16, 2020
TODO:
Needs more troubleshooting:
- Official coveralls action does not seem to work well for Python
coverallsapp/github-action#4
coverallsapp/github-action#30
- Official coveralls cli triggers 500 on coveralls.io
- Inofficial coveralls action seems to correctly talk to the API
  but has issues finding the coverage data in the tests folder,
  or the corresponding code.
  https://github.com/AndreMiras/coveralls-python-action
lukpueh added a commit to lukpueh/tuf that referenced this issue Dec 16, 2020
TODO:
Needs more troubleshooting:
- Official coveralls action does not seem to work well for Python
coverallsapp/github-action#4
coverallsapp/github-action#30
- Official coveralls cli triggers 500 on coveralls.io
- Inofficial coveralls action seems to correctly talk to the API
  but has issues finding the coverage data in the tests folder,
  or the corresponding code.
  https://github.com/AndreMiras/coveralls-python-action
lukpueh added a commit to lukpueh/tuf that referenced this issue Dec 16, 2020
Does not work yet!

TODO:
Troubleshoot
- Official coveralls action does not seem to work well for Python
  coverallsapp/github-action#4
  coverallsapp/github-action#30
- Inofficial coveralls action seems to correctly talk to the API
  but has issues finding the coverage data in the tests folder,
  or rather the corresponding code.
  https://github.com/AndreMiras/coveralls-python-action
- Official coveralls cli tool (see travis) triggers 500 on coveralls.io
lukpueh added a commit to lukpueh/tuf that referenced this issue Dec 23, 2020
Re-add coverage publishing on coveralls.io, formerly performed by
Travis CI (prior to theupdateframework#1242), using the coveralls cli tool according
to the documentation:
https://coveralls-python.readthedocs.io/en/latest/usage/configuration.html#github-actions-gotcha

**Considered alternatives:**
- Official coveralls GitHub action, which does not seem to work
  well for Python:
  coverallsapp/github-action#4
  coverallsapp/github-action#30

- Inofficial fork of that action, which seems to work better
  but had issues finding the coverage data in the tests folder,
  or the covered code respectively.
  https://github.com/AndreMiras/coveralls-python-action

Besides aforementioned issues of these actions the use of cli tools
from curated package managers seems slightly preferable over
actions from the GitHub Marketplace (see theupdateframework#1246).

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
rht added a commit to rht/QuantEcon.py that referenced this issue Jan 1, 2021
rht added a commit to rht/QuantEcon.py that referenced this issue Jan 1, 2021
rht added a commit to rht/QuantEcon.py that referenced this issue Jan 1, 2021
rht added a commit to rht/QuantEcon.py that referenced this issue Jan 1, 2021
rht added a commit to rht/QuantEcon.py that referenced this issue Jan 1, 2021
rht added a commit to rht/QuantEcon.py that referenced this issue Jan 1, 2021
mmcky added a commit to QuantEcon/QuantEcon.py that referenced this issue Jan 2, 2021
* creating test.yml

still need to add test changes for this to work

* testing addition of coveralls

* add coveralls token

* edit token

* edit token 2

* migrate to GitHub Actions secrets

* remove duplicate testing on push and PR

* Test new Coveralls set up

Using similar set up as to [here](https://github.com/marketplace/actions/coveralls-github-action)

* removing `flag-name` input

* Remove .coveralls.yml

* GA: Remove Python 3.6 from the build matrix

Otherwise, scipy returns this error during installation:
RuntimeError: Python version >= 3.7 required.

* GA: Use nose to run the tests

* Use AndreMiras' version of Coveralls action

According to coverallsapp/github-action#4 (comment),
this version works, unlike the official https://github.com/marketplace/actions/coveralls-github-action.

* Remove .travis.yml

* Add relative_files = True in .coveragerc

* GA: Ignore Python 3.7 on Windows

* Remove unused coveralls lib

* Remove pytest

* Add comment for running performance test

Co-authored-by: Harvey Thompson <58153750+Harveyt47@users.noreply.github.com>
Co-authored-by: Matt McKay <mamckay@gmail.com>
lukpueh added a commit to lukpueh/tuf that referenced this issue Jan 13, 2021
Re-add coverage publishing on coveralls.io, formerly performed by
Travis CI (prior to theupdateframework#1242), using the coveralls cli tool according
to the documentation:
https://coveralls-python.readthedocs.io/en/latest/usage/configuration.html#github-actions-gotcha

**Considered alternatives:**
- Official coveralls GitHub action, which does not seem to work
  well for Python:
  coverallsapp/github-action#4
  coverallsapp/github-action#30

- Inofficial fork of that action, which seems to work better
  but had issues finding the coverage data in the tests folder,
  or the covered code respectively.
  https://github.com/AndreMiras/coveralls-python-action

Besides aforementioned issues of these actions the use of cli tools
from curated package managers seems slightly preferable over
actions from the GitHub Marketplace (see theupdateframework#1246).

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
@willronchetti
Copy link

Did something change recently? This workflow was working with coveralls as of 12/14/2020 (build), yet now it does not?

Submitting coverage to coveralls.io...
Could not submit coverage: 422 Client Error: Unprocessable Entity for url: https://coveralls.io/api/v1/jobs
resubmitting with id None-4337388734212009414
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/coveralls/api.py", line 252, in wear
    response.raise_for_status()
  File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/requests/models.py", line 943, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 422 Client Error: Unprocessable Entity for url: https://coveralls.io/api/v1/jobs

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/coveralls/cli.py", line 85, in main
    result = coverallz.wear()
  File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/coveralls/api.py", line 255, in wear
    raise CoverallsException('Could not submit coverage: {}'.format(e))
coveralls.exception.CoverallsException: Could not submit coverage: 422 Client Error: Unprocessable Entity for url: https://coveralls.io/api/v1/jobs

thenewguy added a commit to thenewguy/django-randomfields that referenced this issue Feb 11, 2021
MVrachev pushed a commit to MVrachev/tuf that referenced this issue Feb 24, 2021
Re-add coverage publishing on coveralls.io, formerly performed by
Travis CI (prior to theupdateframework#1242), using the coveralls cli tool according
to the documentation:
https://coveralls-python.readthedocs.io/en/latest/usage/configuration.html#github-actions-gotcha

**Considered alternatives:**
- Official coveralls GitHub action, which does not seem to work
  well for Python:
  coverallsapp/github-action#4
  coverallsapp/github-action#30

- Inofficial fork of that action, which seems to work better
  but had issues finding the coverage data in the tests folder,
  or the covered code respectively.
  https://github.com/AndreMiras/coveralls-python-action

Besides aforementioned issues of these actions the use of cli tools
from curated package managers seems slightly preferable over
actions from the GitHub Marketplace (see theupdateframework#1246).

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
eseifert added a commit to eseifert/madam that referenced this issue Jan 4, 2022
manu-18l added a commit to manu-18l/xarray-contrib that referenced this issue Jan 7, 2022
* add test workflow

* fix lint workflow triggered twice

* fix env file not found

* pytest output in colors

* custom matrix builds

* add xarray-dev and attrs-dev to test matrix

* add coveralls

* fix if line

* try fix coverage data sent to coveralls

* use python-coveralls instead of the github action

see
coverallsapp/github-action#4 (comment)

* run coveralls only for py37 environment

* build only docs on travis

* install pytest-cov and converalls using conda

* try fix coveralls command not found

* add doc workflow

* switch to codecov

* add codecov config

* codecov comment still shown?

* use codecov action

* update badges

* update release notes

* remove travis yaml

* gitignore mypy cache
Cyberboss pushed a commit to Cyberboss/coveralls-action that referenced this issue Sep 16, 2022
@scottgigante
Copy link

This works for me:

    - name: Coveralls
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        COVERALLS_SERVICE_NAME: github
      run: |
        coveralls

@afinetooth
Copy link
Member

afinetooth commented Mar 8, 2023

Hi @scottgigante.

Just FYI for anyone else reading:

You are correct about those environment variables. Due to the nature of GitHub App authentication, the Coveralls GitHub Action is the only Coveralls integration that must use the repo's GitHub token, rather than its Coveralls-assigned repo token, to identify the repo to the Coveralls API. The way to "trick" GitHub Actions into doing the same for other integrations is to pass COVERALLS_SERVICE_NAME=github, which is the reserved value for the Coveralls GitHub Action.

In other words, the Coveralls API thinks you're using the Coveralls GitHub Action and uses the GitHub token to ID your repo.

Note that v2.X will soon support python and other coverage formats due to using a different underlying integration, the Coveralls Universal Coverage Reporter.

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