diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index a2a610db1..f485274df 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -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/codeclimate-action@v2.7.5 + 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 diff --git a/.gitignore b/.gitignore index d09c31668..bd6c431dc 100644 --- a/.gitignore +++ b/.gitignore @@ -46,6 +46,7 @@ htmlcov/ .cache nosetests.xml coverage.xml +coverage_html *.cover .hypothesis/ .pytest_cache/ diff --git a/noxfile.py b/noxfile.py index a29919649..94d4aaade 100644 --- a/noxfile.py +++ b/noxfile.py @@ -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())) @@ -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() @@ -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)