Skip to content

Commit

Permalink
fix: correctly support parallel execution on CircleCI (#336)
Browse files Browse the repository at this point in the history
Co-authored-by: Elijah Shaw-Rutschman <elijahr@gmail.com>
  • Loading branch information
Frank-Colson and elijahr authored Nov 11, 2021
1 parent 495ddd4 commit 2610885
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
8 changes: 5 additions & 3 deletions coveralls/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,11 @@ def load_config_from_buildkite():

@staticmethod
def load_config_from_circle():
pr = os.environ.get('CI_PULL_REQUEST', '').split('/')[-1] or None
number = os.environ.get('CIRCLE_WORKFLOW_ID')
return 'circle-ci', os.environ.get('CIRCLE_BUILD_NUM'), number, pr
number = os.environ.get(
'CIRCLE_WORKFLOW_ID') or os.environ.get('CIRCLE_BUILD_NUM')
pr = (os.environ.get('CI_PULL_REQUEST') or "").split("/")[-1] or None
job = os.environ.get('CIRCLE_NODE_INDEX') or None
return 'circleci', job, number, pr

def load_config_from_github(self):
# Github tokens and standard Coveralls tokens are almost but not quite
Expand Down
2 changes: 2 additions & 0 deletions docs/usage/tox.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ CircleCI
All variables:

- ``CIRCLECI``
- ``CIRCLE_WORKFLOW_ID``
- ``CIRCLE_BUILD_NUM``
- ``CIRCLE_BRANCH``
- ``CIRCLE_NODE_INDEX``
- ``CI_PULL_REQUEST``

Github Actions
Expand Down
18 changes: 15 additions & 3 deletions tests/api/configuration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,24 @@ def test_buildkite_no_config_no_pr(self):
'CIRCLE_BUILD_NUM': '888',
'CI_PULL_REQUEST': 'https://github.com/org/repo/pull/9999'},
clear=True)
def test_circleci_no_config(self):
def test_circleci_singular_no_config(self):
cover = Coveralls(repo_token='xxx')
assert cover.config['service_name'] == 'circle-ci'
assert cover.config['service_job_id'] == '888'
assert cover.config['service_name'] == 'circleci'
assert cover.config['service_number'] == '888'
assert cover.config['service_pull_request'] == '9999'

@mock.patch.dict(
os.environ,
{'CIRCLECI': 'True',
'CIRCLE_WORKFLOW_ID': '0ea2c0f7-4e56-4a94-bf77-bfae6bdbf80a',
'CIRCLE_NODE_INDEX': '15'},
clear=True)
def test_circleci_parallel_no_config(self):
cover = Coveralls(repo_token='xxx')
assert cover.config['service_name'] == 'circleci'
assert cover.config['service_number'] == '0ea2c0f7-4e56-4a94-bf77-bfae6bdbf80a'
assert cover.config['service_job_id'] == '15'

@mock.patch.dict(
os.environ,
{'GITHUB_ACTIONS': 'true',
Expand Down

0 comments on commit 2610885

Please sign in to comment.