Skip to content
This repository was archived by the owner on May 21, 2025. It is now read-only.

Commit df29449

Browse files
authored
Fix GitHub Actions service (#275)
* Fix GitHub Actions service * Bump version * Add a GitHub Actions workflow * Lint later * Install requirements * log * more logging * Set some env variables * log * set env in the action * will it run * one test * Use the write SHA * black * Maybe checkout v2 * Fixes * All the things * Maybe token like this * Try now * Cleanup * black * Use coverage < 5 * Update requirements too * Run coverage? * Pin to 4.5.4
1 parent 4cbedcd commit df29449

File tree

8 files changed

+54
-19
lines changed

8 files changed

+54
-19
lines changed

.github/workflows/build-test.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Python package
5+
6+
on:
7+
push:
8+
branches: [ master ]
9+
pull_request:
10+
branches: [ master ]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
python-version: [3.5, 3.6, 3.7]
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
with:
23+
ref: ${{ github.event.pull_request.head.sha }}
24+
- name: Set up Python ${{ matrix.python-version }}
25+
uses: actions/setup-python@v2
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
- name: Install dependencies
29+
run: |
30+
python -m pip install --upgrade pip
31+
pip install -r tests/requirements.txt
32+
- name: Test
33+
run: |
34+
make reinstall
35+
make test
36+
- name: Upload coverage reports to Codecov
37+
run: |
38+
codecov
39+
env: # Or as an environment variable
40+
super_secret: ${{ secrets.CODECOV_TOKEN }}

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### `2.1.6`
2+
3+
- [#275](https://github.com/codecov/codecov-python/pull/275) Fix GitHub Actions implementation
4+
15
### `2.1.5`
26

37
- [#273](https://github.com/codecov/codecov-python/pull/273) Implement retries on Codecov API calls

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ reinstall:
99
python setup.py install
1010

1111
test:
12-
py.test tests/test.py
12+
py.test tests/test.py --cov=codecov
1313

1414
format:
1515
black . --check

codecov/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ def main(*argv, **kwargs):
805805
# https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables
806806
query.update(
807807
dict(
808-
service="github",
808+
service="github-actions",
809809
build=os.getenv("GITHUB_RUN_ID"),
810810
commit=os.getenv("GITHUB_SHA"),
811811
slug=os.getenv("GITHUB_REPOSITORY"),

codecov/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
__license__ = "Apache 2.0"
66
__title__ = "codecov"
77
__url__ = "https://github.com/codecov/codecov-python"
8-
__version__ = "2.1.5"
8+
__version__ = "2.1.6"

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
packages=["codecov"],
4141
include_package_data=True,
4242
zip_safe=True,
43-
install_requires=["requests>=2.7.9", "coverage"],
43+
install_requires=["requests>=2.7.9", "coverage==4.5.4"],
4444
entry_points={"console_scripts": ["codecov=codecov:main"]},
4545
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*",
4646
)

tests/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
coverage>=4.4.0
1+
coverage==4.5.4
22
ddt
33
mock
44
pytest>=4.6.0

tests/test.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -878,23 +878,14 @@ def test_ci_gitlab(self):
878878
)
879879
def test_ci_github(self):
880880
self.set_env(
881-
GITHUB_REF="master",
882-
GITHUB_RUN_ID="1399372237",
883-
GITHUB_REPOSITORY="owner/repo",
884-
GITHUB_ACTION="6de813bb999760c81f96f3cf5dbdcd51cead172f",
885-
GITHUB_SHA="d653b934ed59c1a785cc1cc79d08c9aaa4eba73b",
886-
HOME="/",
887-
CODECOV_TOKEN="token",
888-
CODECOV_NAME="name",
881+
HOME="/", CODECOV_TOKEN="token", CODECOV_NAME="name",
889882
)
890883
self.fake_report()
891884
res = self.run_cli()
892-
self.assertEqual(res["query"]["service"], "github")
893-
self.assertEqual(
894-
res["query"]["commit"], "d653b934ed59c1a785cc1cc79d08c9aaa4eba73b"
895-
)
896-
self.assertEqual(res["query"]["build"], "1399372237")
897-
self.assertEqual(res["query"]["slug"], "owner/repo")
885+
self.assertEqual(res["query"]["service"], "github-actions")
886+
self.assertEqual(res["query"]["commit"], os.getenv("GITHUB_SHA"))
887+
self.assertEqual(res["query"]["build"], os.getenv("GITHUB_RUN_ID"))
888+
self.assertEqual(res["query"]["slug"], os.getenv("GITHUB_REPOSITORY"))
898889
self.assertEqual(res["codecov"].token, "token")
899890
self.assertEqual(res["codecov"].name, "name")
900891

0 commit comments

Comments
 (0)