diff --git a/coveralls/api.py b/coveralls/api.py index 8c2084be..0f1eb40d 100644 --- a/coveralls/api.py +++ b/coveralls/api.py @@ -91,25 +91,33 @@ def load_config_from_travis(): pr = os.environ.get('TRAVIS_PULL_REQUEST') return 'travis-ci', os.environ.get('TRAVIS_JOB_ID'), pr + @staticmethod + def load_config_from_semaphore(): + pr = os.environ.get('PULL_REQUEST_NUMBER') + return 'semaphore-ci', os.environ.get('SEMAPHORE_BUILD_NUMBER'), pr + @staticmethod def load_config_from_unknown(): return 'coveralls-python', None, None def load_config_from_ci_environment(self): if os.environ.get('APPVEYOR'): - return self.load_config_from_appveyor() - if os.environ.get('BUILDKITE'): - return self.load_config_from_buildkite() - if os.environ.get('CIRCLECI'): + name, job, pr = self.load_config_from_appveyor() + elif os.environ.get('BUILDKITE'): + name, job, pr = self.load_config_from_buildkite() + elif os.environ.get('CIRCLECI'): self._token_required = False - return self.load_config_from_circle() - if os.environ.get('JENKINS_HOME'): - return self.load_config_from_jenkins() - if os.environ.get('TRAVIS'): + name, job, pr = self.load_config_from_circle() + elif os.environ.get('JENKINS_HOME'): + name, job, pr = self.load_config_from_jenkins() + elif os.environ.get('TRAVIS'): self._token_required = False - return self.load_config_from_travis() - - return self.load_config_from_unknown() + name, job, pr = self.load_config_from_travis() + elif os.environ.get('SEMAPHORE'): + name, job, pr = self.load_config_from_semaphore() + else: + name, job, pr = self.load_config_from_unknown() + return (name, job, pr) def load_config_from_environment(self): coveralls_host = os.environ.get('COVERALLS_HOST') diff --git a/coveralls/git.py b/coveralls/git.py index 5b05e722..f08710c7 100644 --- a/coveralls/git.py +++ b/coveralls/git.py @@ -62,6 +62,7 @@ def git_info(): os.environ.get('CIRCLE_BRANCH') or os.environ.get('GIT_BRANCH') or os.environ.get('TRAVIS_BRANCH') or + os.environ.get('BRANCH_NAME') or run_command('git', 'rev-parse', '--abbrev-ref', 'HEAD')) head = { 'id': gitlog('%H'), diff --git a/docs/usage/tox.rst b/docs/usage/tox.rst index c2b9d32f..8001225d 100644 --- a/docs/usage/tox.rst +++ b/docs/usage/tox.rst @@ -83,4 +83,17 @@ All variables: - ``TRAVIS_BRANCH`` - ``TRAVIS_PULL_REQUEST`` + +SemaphoreCI +------- +:: + + passenv = SEMAPHORE SEMAPHORE_BUILD_NUMBER BRANCH_NAME PULL_REQUEST_NUMBER + +All variables: + +- ``SEMAPHORE`` +- ``SEMAPHORE_BUILD_NUMBER`` +- ``BRANCH_NAME`` +- ``PULL_REQUEST_NUMBER`` .. _tox: https://tox.readthedocs.io/en/latest/ diff --git a/tests/api/configuration_test.py b/tests/api/configuration_test.py index eec60d38..db7f23b9 100644 --- a/tests/api/configuration_test.py +++ b/tests/api/configuration_test.py @@ -116,6 +116,17 @@ def test_travis_no_config(self): assert cover.config['service_job_id'] == '777' assert 'repo_token' not in cover.config + @mock.patch.dict(os.environ, + {'SEMAPHORE': 'True', + 'SEMAPHORE_BUILD_NUMBER': '888', + 'PULL_REQUEST_NUMBER': '9999'}, + clear=True) + def test_semaphore_no_config(self): + cover = Coveralls(repo_token='xxx') + assert cover.config['service_name'] == 'semaphore-ci' + assert cover.config['service_job_id'] == '888' + assert cover.config['service_pull_request'] == '9999' + @mock.patch.dict(os.environ, {'COVERALLS_SERVICE_NAME': 'xxx'}, clear=True) def test_service_name_from_env(self): cover = Coveralls(repo_token='yyy')