diff options
author | wbond <will@wbond.net> | 2019-09-12 21:24:46 -0400 |
---|---|---|
committer | wbond <will@wbond.net> | 2019-09-13 06:41:24 -0400 |
commit | 93647b43b0c98b5f552d1a4188a8bb8f5cd401ea (patch) | |
tree | 7e065fbd97ea92a2bf3e9365e9188609cac8da12 /dev | |
parent | bba5d621c393b86e6fb0838e631ccea252852189 (diff) | |
download | asn1crypto-93647b43b0c98b5f552d1a4188a8bb8f5cd401ea.tar.gz |
Add GitHub Actions support to coverage uploader
Diffstat (limited to 'dev')
-rw-r--r-- | dev/coverage.py | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/dev/coverage.py b/dev/coverage.py index 86e1b64..4332f9d 100644 --- a/dev/coverage.py +++ b/dev/coverage.py @@ -112,7 +112,8 @@ def _env_info(): :return: A two-element tuple of unicode strings. The first is the name of the environment, the second the root of the repo. The environment name - will be one of: "ci-travis", "ci-circle", "ci-appveyor", "local" + will be one of: "ci-travis", "ci-circle", "ci-appveyor", + "ci-github-actions", "local" """ if os.getenv('CI') == 'true' and os.getenv('TRAVIS') == 'true': @@ -124,6 +125,9 @@ def _env_info(): if os.getenv('CI') == 'true' and os.getenv('CIRCLECI') == 'true': return ('ci-circle', os.getcwdu() if sys.version_info < (3,) else os.getcwd()) + if os.getenv('GITHUB_ACTIONS') == 'true': + return ('ci-github-actions', os.getenv('GITHUB_WORKSPACE')) + return ('local', package_root) @@ -191,6 +195,30 @@ def _codecov_submit(): 'build_url': os.getenv('CIRCLE_BUILD_URL'), } + elif env_name == 'ci-github-actions': + branch = '' + tag = '' + ref = os.getenv('GITHUB_REF', '') + if ref.startswith('refs/tags/'): + tag = ref[10:] + elif ref.startswith('refs/heads/'): + branch = ref[11:] + + impl = _plat.python_implementation() + major, minor = _plat.python_version_tuple()[0:2] + build_name = '%s %s %s.%s' % (_platform_name(), impl, major, minor) + + query = { + 'service': 'custom', + 'token': json_data['token'], + 'branch': branch, + 'tag': tag, + 'slug': os.getenv('GITHUB_REPOSITORY'), + 'commit': os.getenv('GITHUB_SHA'), + 'build_url': 'https://github.com/wbond/oscrypto/commit/%s/checks' % os.getenv('GITHUB_SHA'), + 'name': 'GitHub Actions %s on %s' % (build_name, os.getenv('RUNNER_OS')) + } + else: if not os.path.exists(os.path.join(root, '.git')): print('git repository not found, not submitting coverage data') @@ -623,8 +651,9 @@ def _execute(params, cwd, retry=None): if code != 0: if retry: stderr_str = stderr.decode('utf-8') - if isinstance(retry, Pattern) and retry.search(stderr_str) is not None: - return _execute(params, cwd, retry) + if isinstance(retry, Pattern): + if retry.search(stderr_str) is not None: + return _execute(params, cwd, retry) elif retry in stderr_str: return _execute(params, cwd, retry) e = OSError('subprocess exit code for "%s" was %d: %s' % (' '.join(params), code, stderr)) |