Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

Commit

Permalink
Fix GitHub Actions service (#275)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
thomasrockhu committed Jun 13, 2020
1 parent 4cbedcd commit df29449
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 19 deletions.
40 changes: 40 additions & 0 deletions .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 }}
4 changes: 4 additions & 0 deletions 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
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion codecov/__init__.py
Expand Up @@ -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"),
Expand Down
2 changes: 1 addition & 1 deletion codecov/__version__.py
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -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"],

This comment has been minimized.

Copy link
@nedbat

nedbat Jun 14, 2020

Why pin coverage here? And with no mention in the changelog?

entry_points={"console_scripts": ["codecov=codecov:main"]},
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*",
)
2 changes: 1 addition & 1 deletion tests/requirements.txt
@@ -1,4 +1,4 @@
coverage>=4.4.0
coverage==4.5.4
ddt
mock
pytest>=4.6.0
Expand Down
19 changes: 5 additions & 14 deletions tests/test.py
Expand Up @@ -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")

Expand Down

0 comments on commit df29449

Please sign in to comment.