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

Add in coverage reporting #87

Merged
merged 1 commit into from
Sep 6, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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