Skip to content

Commit

Permalink
feat(api): support pull requests on buildkite (#197)
Browse files Browse the repository at this point in the history
https://buildkite.com/docs/pipelines/environment-variables says that
the pull request is available via BUILDKITE_PULL_REQUEST, which is
either the number for a pull request, or "false" for a
non-pull-request.
  • Loading branch information
huonw authored and TheKevJames committed Mar 20, 2019
1 parent d9e27fe commit 2700e3e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
5 changes: 4 additions & 1 deletion coveralls/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ def load_config_from_appveyor():

@staticmethod
def load_config_from_buildkite():
return 'buildkite', os.environ.get('BUILDKITE_JOB_ID'), None
pr = os.environ.get('BUILDKITE_PULL_REQUEST')
if pr == 'false':
pr = None
return 'buildkite', os.environ.get('BUILDKITE_JOB_ID'), pr

@staticmethod
def load_config_from_circle():
Expand Down
13 changes: 12 additions & 1 deletion tests/api/configuration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,22 @@ def test_appveyor_no_config(self):
assert cover.config['service_pull_request'] == '1234'

@mock.patch.dict(os.environ, {'BUILDKITE': 'True',
'BUILDKITE_JOB_ID': '1234567'}, clear=True)
'BUILDKITE_JOB_ID': '1234567',
'BUILDKITE_PULL_REQUEST': '1234'}, clear=True)
def test_buildkite_no_config(self):
cover = Coveralls(repo_token='xxx')
assert cover.config['service_name'] == 'buildkite'
assert cover.config['service_job_id'] == '1234567'
assert cover.config['service_pull_request'] == '1234'

@mock.patch.dict(os.environ, {'BUILDKITE': 'True',
'BUILDKITE_JOB_ID': '1234567',
'BUILDKITE_PULL_REQUEST': 'false'}, clear=True)
def test_buildkite_no_config_no_pr(self):
cover = Coveralls(repo_token='xxx')
assert cover.config['service_name'] == 'buildkite'
assert cover.config['service_job_id'] == '1234567'
assert 'service_pull_request' not in cover.config

@mock.patch.dict(
os.environ,
Expand Down

0 comments on commit 2700e3e

Please sign in to comment.