Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push github actions coverage information from tags #284

Merged
merged 5 commits into from May 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion coveralls/git.py
Expand Up @@ -32,7 +32,10 @@ def git_branch():
branch = None
if os.environ.get('GITHUB_ACTIONS'):
github_ref = os.environ.get('GITHUB_REF')
if github_ref.startswith('refs/heads/'):
if (
github_ref.startswith('refs/heads/')
or github_ref.startswith('refs/tags/')
):
# E.g. in push events.
branch = github_ref.split('/', 2)[-1]
else:
Expand Down
12 changes: 11 additions & 1 deletion tests/git_test.py
Expand Up @@ -125,6 +125,16 @@ def test_gitinfo_github_pr(self):
'GITHUB_SHA': 'bb0e00166b28f49db04d6a8b8cb4bddb5afa529f',
'GITHUB_HEAD_REF': ''
}, clear=True)
def test_gitinfo_github_nopr(self):
def test_gitinfo_github_branch(self):
git_info = coveralls.git.git_info()
assert git_info['git']['branch'] == 'master'

@mock.patch.dict(os.environ, {
'GITHUB_ACTIONS': 'true',
'GITHUB_REF': 'refs/tags/v1.0',
'GITHUB_SHA': 'bb0e00166b28f49db04d6a8b8cb4bddb5afa529f',
'GITHUB_HEAD_REF': ''
}, clear=True)
def test_gitinfo_github_tag(self):
git_info = coveralls.git.git_info()
assert git_info['git']['branch'] == 'v1.0'