Skip to content

Commit

Permalink
Fix coverage gen by not using importlib + add cov uploads to codeclimate
Browse files Browse the repository at this point in the history
  • Loading branch information
FasterSpeeding committed Sep 6, 2021
1 parent 4f4b8c1 commit 6f5136f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 7 deletions.
42 changes: 38 additions & 4 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,55 @@ jobs:
python -m pip install -r nox-requirements.txt
- name: Run tests
run: |
python -m nox -s test
# mv .coverage ./.coverage.${{ matrix.os }}.${{ matrix.python-version }}

# - name: Archive coverage
# uses: actions/upload-artifact@v2
# with:
# name: coverage
# path: ./.coverage.${{ matrix.os }}.${{ matrix.python-version }}
# if-no-files-found: error

upload-coverage:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9

- name: install prerequisites
run: |
python -m pip install --upgrade pip wheel
python -m pip install -r nox-requirements.txt
- name: Record coverage
run: |
python -m nox -s test-coverage
mv .coverage ./.coverage.${{ matrix.os }}.${{ matrix.python-version }}
- name: Upload coverage
if: github.event_name == 'push'
uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageLocations: .coverage.xml:coverage.py

- name: Archive coverage
uses: actions/upload-artifact@v2
with:
name: coverage
path: ./.coverage.${{ matrix.os }}.${{ matrix.python-version }}
path: ./coverage_html
if-no-files-found: error

# TODO: this needs to be finished at one point
# TODO: Switch over to this style once https://github.com/nedbat/coveragepy/issues/1002 is fixed
# upload-coverage:
# needs: test
# if: Never()
# if: github.event_name == 'push'
# runs-on: ubuntu-latest

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ htmlcov/
.cache
nosetests.xml
coverage.xml
coverage_html
*.cover
.hypothesis/
.pytest_cache/
Expand Down
7 changes: 4 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def cleanup(session: nox.Session) -> None:
# Remove directories
from nox.logger import logger

for raw_path in ["./dist", "./docs", "./.nox", "./.pytest_cache", "./hikari_tanjun.egg-info"]:
for raw_path in ["./dist", "./docs", "./.nox", "./.pytest_cache", "./hikari_tanjun.egg-info", "./coverage_html"]:
path = pathlib.Path(raw_path)
try:
shutil.rmtree(str(path.absolute()))
Expand All @@ -113,7 +113,7 @@ def cleanup(session: nox.Session) -> None:
logger.info(f"[ OK ] Removed '{raw_path}'") # type: ignore

# Remove individual files
for raw_path in ["./.coverage"]:
for raw_path in ["./.coverage", "./coverage_html.xml"]:
path = pathlib.Path(raw_path)
try:
path.unlink()
Expand Down Expand Up @@ -211,7 +211,8 @@ def test(session: nox.Session) -> None:
def test_coverage(session: nox.Session) -> None:
install_requirements(session, ".[tests]")
# TODO: can import-mode be specified in the config.
session.run("pytest", "--cov=tanjun", "--import-mode", "importlib")
# https://github.com/nedbat/coveragepy/issues/1002
session.run("pytest", "--cov=tanjun", "--cov-report", "html:coverage_html", "--cov-report", "xml:coverage.xml")


@nox.session(name="type-check", reuse_venv=True)
Expand Down

0 comments on commit 6f5136f

Please sign in to comment.