diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml new file mode 100644 index 00000000..05b442a9 --- /dev/null +++ b/.github/workflows/build-test.yml @@ -0,0 +1,40 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Python package + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.5, 3.6, 3.7] + + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r tests/requirements.txt + - name: Test + run: | + make reinstall + make test + - name: Upload coverage reports to Codecov + run: | + codecov + env: # Or as an environment variable + super_secret: ${{ secrets.CODECOV_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ac93e00..aa695dda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### `2.1.6` + +- [#275](https://github.com/codecov/codecov-python/pull/275) Fix GitHub Actions implementation + ### `2.1.5` - [#273](https://github.com/codecov/codecov-python/pull/273) Implement retries on Codecov API calls diff --git a/Makefile b/Makefile index 0b0a1ba2..7eae04f4 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ reinstall: python setup.py install test: - py.test tests/test.py + py.test tests/test.py --cov=codecov format: black . --check diff --git a/codecov/__init__.py b/codecov/__init__.py index 046f4cef..3308d1b9 100644 --- a/codecov/__init__.py +++ b/codecov/__init__.py @@ -805,7 +805,7 @@ def main(*argv, **kwargs): # https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables query.update( dict( - service="github", + service="github-actions", build=os.getenv("GITHUB_RUN_ID"), commit=os.getenv("GITHUB_SHA"), slug=os.getenv("GITHUB_REPOSITORY"), diff --git a/codecov/__version__.py b/codecov/__version__.py index 0ff00ce8..8344be9c 100644 --- a/codecov/__version__.py +++ b/codecov/__version__.py @@ -5,4 +5,4 @@ __license__ = "Apache 2.0" __title__ = "codecov" __url__ = "https://github.com/codecov/codecov-python" -__version__ = "2.1.5" +__version__ = "2.1.6" diff --git a/setup.py b/setup.py index 4d418234..60414316 100644 --- a/setup.py +++ b/setup.py @@ -40,7 +40,7 @@ packages=["codecov"], include_package_data=True, zip_safe=True, - install_requires=["requests>=2.7.9", "coverage"], + install_requires=["requests>=2.7.9", "coverage==4.5.4"], entry_points={"console_scripts": ["codecov=codecov:main"]}, python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*", ) diff --git a/tests/requirements.txt b/tests/requirements.txt index 953f4978..b6f891ef 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,4 +1,4 @@ -coverage>=4.4.0 +coverage==4.5.4 ddt mock pytest>=4.6.0 diff --git a/tests/test.py b/tests/test.py index 2188dac3..de4af8e8 100644 --- a/tests/test.py +++ b/tests/test.py @@ -878,23 +878,14 @@ def test_ci_gitlab(self): ) def test_ci_github(self): self.set_env( - GITHUB_REF="master", - GITHUB_RUN_ID="1399372237", - GITHUB_REPOSITORY="owner/repo", - GITHUB_ACTION="6de813bb999760c81f96f3cf5dbdcd51cead172f", - GITHUB_SHA="d653b934ed59c1a785cc1cc79d08c9aaa4eba73b", - HOME="/", - CODECOV_TOKEN="token", - CODECOV_NAME="name", + HOME="/", CODECOV_TOKEN="token", CODECOV_NAME="name", ) self.fake_report() res = self.run_cli() - self.assertEqual(res["query"]["service"], "github") - self.assertEqual( - res["query"]["commit"], "d653b934ed59c1a785cc1cc79d08c9aaa4eba73b" - ) - self.assertEqual(res["query"]["build"], "1399372237") - self.assertEqual(res["query"]["slug"], "owner/repo") + self.assertEqual(res["query"]["service"], "github-actions") + self.assertEqual(res["query"]["commit"], os.getenv("GITHUB_SHA")) + self.assertEqual(res["query"]["build"], os.getenv("GITHUB_RUN_ID")) + self.assertEqual(res["query"]["slug"], os.getenv("GITHUB_REPOSITORY")) self.assertEqual(res["codecov"].token, "token") self.assertEqual(res["codecov"].name, "name")