Skip to content

Commit

Permalink
Merge pull request #97 from xolox/master
Browse files Browse the repository at this point in the history
Improve support for AppVeyor CI
  • Loading branch information
coagulant committed Nov 6, 2015
2 parents f7888c6 + bd717bc commit 1a62ce2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
11 changes: 10 additions & 1 deletion coveralls/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ def __init__(self, token_required=True, **kwargs):
self.config['service_job_id'] = os.environ.get('CIRCLE_BUILD_NUM')
if os.environ.get('CI_PULL_REQUEST', None):
self.config['service_pull_request'] = os.environ.get('CI_PULL_REQUEST').split('/')[-1]
elif os.environ.get('APPVEYOR'):
is_travis_or_circle = False
self.config['service_name'] = file_config.get('service_name', None) or 'appveyor'
self.config['service_job_id'] = os.environ.get('APPVEYOR_BUILD_ID')
if os.environ.get('APPVEYOR_PULL_REQUEST_NUMBER'):
self.config['service_pull_request'] = os.environ['APPVEYOR_PULL_REQUEST_NUMBER']
else:
is_travis_or_circle = False
self.config['service_name'] = file_config.get('service_name') or self.default_client
Expand Down Expand Up @@ -204,7 +210,10 @@ def git_info(self):
'committer_email': gitlog('%ce'),
'message': gitlog('%s'),
},
'branch': os.environ.get('CIRCLE_BRANCH') or os.environ.get('CI_BRANCH') or os.environ.get('TRAVIS_BRANCH', rev),
'branch': (os.environ.get('CIRCLE_BRANCH') or
os.environ.get('APPVEYOR_REPO_BRANCH') or
os.environ.get('CI_BRANCH') or
os.environ.get('TRAVIS_BRANCH', rev)),
#origin git@github.com:coagulant/coveralls-python.git (fetch)
'remotes': [{'name': line.split()[0], 'url': line.split()[1]}
for line in run_command('git', 'remote', '-v').splitlines() if '(fetch)' in line]
Expand Down
9 changes: 9 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ def test_circleci_no_config(self):
assert cover.config['service_job_id'] == '888'
assert cover.config['service_pull_request'] == '9999'

@patch.dict(os.environ, {'APPVEYOR': 'True',
'APPVEYOR_BUILD_ID': '1234567',
'APPVEYOR_PULL_REQUEST_NUMBER': '1234'}, clear=True)
def test_appveyor_no_config(self):
cover = Coveralls(repo_token='xxx')
assert cover.config['service_name'] == 'appveyor'
assert cover.config['service_job_id'] == '1234567'
assert cover.config['service_pull_request'] == '1234'


class Git(GitBasedTest):

Expand Down

0 comments on commit 1a62ce2

Please sign in to comment.