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

CircleCI unable to submit coverage without COVERALLS_REPO_TOKEN #206

Closed
ArmaanT opened this issue Oct 15, 2019 · 5 comments
Closed

CircleCI unable to submit coverage without COVERALLS_REPO_TOKEN #206

ArmaanT opened this issue Oct 15, 2019 · 5 comments

Comments

@ArmaanT
Copy link
Contributor

ArmaanT commented Oct 15, 2019

When used in CircleCI, coveralls-python is unable to submit code coverage when COVERALLS_REPO_TOKEN is not set. There seems to be a conflict between the documentation in this package and the official documentation about whether or not the COVERALLS_REPO_TOKEN environment variable needs to be set when using CircleCI. I just want to clarify if the environment variable is needed.

Here's a link to a CircleCI build that can't submit coverage and here are the outputs of coveralls and coveralls debug in that job:

coveralls:

Submitting coverage to coveralls.io...
Could not submit coverage: 422 Client Error: Unprocessable Entity for url: https://coveralls.io/api/v1/jobs
Traceback (most recent call last):
  File "/home/circleci/coveralls-test/.venv/lib/python3.7/site-packages/coveralls/api.py", line 177, in wear
    response.raise_for_status()
  File "/home/circleci/coveralls-test/.venv/lib/python3.7/site-packages/requests/models.py", line 940, 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 "/home/circleci/coveralls-test/.venv/lib/python3.7/site-packages/coveralls/cli.py", line 77, in main
    result = coverallz.wear()
  File "/home/circleci/coveralls-test/.venv/lib/python3.7/site-packages/coveralls/api.py", line 180, 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

coveralls debug:

Missing .coveralls.yml file. Using only env variables.
Testing coveralls-python...
{"source_files": [{"name": "double/__init__.py", "source": "", "coverage": []}, {"name": "double/double.py", "source": "def double (input: int) -> int:\n    return 2 * input\n", "coverage": [1, 1]}, {"name": "tests/__init__.py", "source": "", "coverage": []}, {"name": "tests/test_double.py", "source": "from unittest import TestCase\n\nfrom double.double import double\n\n\nclass DoubleTests(TestCase):\n    def test_double(self):\n        self.assertEqual(4, double(2))\n", "coverage": [1, null, 1, null, null, 1, 1, 1]}], "git": {"branch": "master", "head": {"id": "3445c8f15661bfced994606daf8935529d8be2c0", "author_name": "Armaan Tobaccowalla", "author_email": "[email protected]", "committer_name": "Armaan Tobaccowalla", "committer_email": "[email protected]", "message": "Configure coverage"}, "remotes": [{"name": "origin", "url": "[email protected]:ArmaanT/coveralls_test.git"}]}, "config_file": ".coveragerc", "service_name": "circle-ci", "service_job_id": "4"}
==
Reporting 4 files
==

double/__init__.py - 0/0
double/double.py - 2/2
tests/__init__.py - 0/0
tests/test_double.py - 5/8
@TheKevJames
Copy link
Owner

Interesting! Thanks for flagging this @ArmaanT

Coveralls' docs used to say the token was only necessary when running outside of Circle or Travis, but it looks like that's changed over the years -- now I see:

The option repo_token (found on your repository’s page on Coveralls) is used to specify which project on Coveralls your project maps to. This is only needed for private repos and should be kept secret – anyone could use it to submit coverage data on your repo’s behalf.

Looks like we need to update our docs to mirror theirs -- maybe change ours to something like:

"If coveralls-python is being run on CircleCI or TravisCI for a public repo, it will automatically set the token for communication with coveralls.io."

If you'd like to submit a PR, that would be fantastic!

@jvesely
Copy link

jvesely commented Nov 10, 2019

I see the same problem even with public repository;

#!/bin/bash -eo pipefail
. venv/bin/activate
coveralls
Submitting coverage to coveralls.io...
Could not submit coverage: 422 Client Error: Unprocessable Entity for url: https://coveralls.io/api/v1/jobs
Traceback (most recent call last):
  File "/home/circleci/repo/venv/lib/python3.6/site-packages/coveralls/api.py", line 177, in wear
    response.raise_for_status()
  File "/home/circleci/repo/venv/lib/python3.6/site-packages/requests/models.py", line 940, 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 "/home/circleci/repo/venv/lib/python3.6/site-packages/coveralls/cli.py", line 77, in main
    result = coverallz.wear()
  File "/home/circleci/repo/venv/lib/python3.6/site-packages/coveralls/api.py", line 180, 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
Exited with code 1

Is there anything I can check that circle-ci should provide?

@ArmaanT
Copy link
Contributor Author

ArmaanT commented Nov 11, 2019

I took another look at the official docs and packages for other languages, and it seems like Coveralls only supports Travis without an explicitly defined repo_token. I think for CircleCI you would need to define the token for each repo.

@TheKevJames
Copy link
Owner

TheKevJames commented Dec 3, 2019

Just switched this repo over to submitting via CircleCI instead of Travis and the above was indeed reproducible until I set the token manually. Looks like everyone's docs are wrong here! I'll submit a docs update to address this momentarily -- thanks for flagging this, folks!

ArturKlauser pushed a commit to ArturKlauser/coveralls-python that referenced this issue Dec 3, 2019
Looks like the Coverall docs here are out-of-date -- Coveralls no longer
supports submitting results from CircleCI without an explicit repo token
set.

Fixes TheKevJames#206
@solancer
Copy link

I was facing the same issue on Github actions, adding --service=gihtub in front of the coveralls command fixed it for me

name: Coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: coveralls --service=github

yuekui added a commit to yuekui/django-safedelete that referenced this issue Apr 14, 2021
Gagaro pushed a commit to makinacorpus/django-safedelete that referenced this issue Apr 27, 2021
* SET related objects after deleting

* default_app_config was deprecated since Django 1.7

* Explicitly set transform to repr

* No need to set overall repo token

Ref: TheKevJames/coveralls-python#206
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

4 participants