From 5c1b3460deca9a364e8c78fb092bacbe172bd252 Mon Sep 17 00:00:00 2001 From: Peter Odding Date: Sat, 31 Oct 2015 13:19:28 +0100 Subject: [PATCH 1/3] Try to add proper support for AppVeyor --- coveralls/api.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/coveralls/api.py b/coveralls/api.py index 60687963..b0eb1219 100644 --- a/coveralls/api.py +++ b/coveralls/api.py @@ -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' + if os.environ.get('APPVEYOR_REPO_BRANCH'): + # Enable Coveralls.git_info() to report the proper branch name. + os.environ['CI_BRANCH'] = os.environ['APPVEYOR_REPO_BRANCH'] else: is_travis_or_circle = False self.config['service_name'] = file_config.get('service_name') or self.default_client From 1b1fffe7f8c249adc80fb9ea2814095e596c8b05 Mon Sep 17 00:00:00 2001 From: Peter Odding Date: Sat, 31 Oct 2015 15:23:43 +0100 Subject: [PATCH 2/3] Improve/cleanup AppVeyor support --- coveralls/api.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/coveralls/api.py b/coveralls/api.py index b0eb1219..4553d74b 100644 --- a/coveralls/api.py +++ b/coveralls/api.py @@ -59,9 +59,9 @@ def __init__(self, token_required=True, **kwargs): elif os.environ.get('APPVEYOR'): is_travis_or_circle = False self.config['service_name'] = file_config.get('service_name', None) or 'appveyor' - if os.environ.get('APPVEYOR_REPO_BRANCH'): - # Enable Coveralls.git_info() to report the proper branch name. - os.environ['CI_BRANCH'] = os.environ['APPVEYOR_REPO_BRANCH'] + 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 @@ -210,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] From bd717bc4435e427770645d36b14675641d87b2e0 Mon Sep 17 00:00:00 2001 From: Peter Odding Date: Sat, 31 Oct 2015 15:24:10 +0100 Subject: [PATCH 3/3] Add test for AppVeyor support --- tests/test_api.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test_api.py b/tests/test_api.py index fc10c16e..306bb909 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -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):