diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c58a1213..37e00628 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -92,15 +92,18 @@ jobs: python-version: ${{ matrix.python.action }} - name: Install dependencies - run: python -m pip install --upgrade pip nox codecov coverage[toml] + run: python -m pip install --upgrade pip nox - uses: twisted/python-info-action@v1 - run: nox --python ${{ matrix.python.action }} -e ${{ matrix.task.nox }} -- --use-wheel dist/*.whl - - name: Codecov - run: | - codecov -n "GitHub Actions - ${{ matrix.task.name}} - ${{ matrix.os.name }} ${{ matrix.python.name }}" + - name: Upload coverage data + uses: actions/upload-artifact@v3 + with: + name: coverage-data + path: .coverage.* + if-no-files-found: ignore test-windows: @@ -133,15 +136,12 @@ jobs: python-version: ${{ matrix.python.action }} - name: Install dependencies - run: python -m pip install --upgrade pip nox codecov coverage[toml] + run: python -m pip install --upgrade pip nox - uses: twisted/python-info-action@v1 - run: nox --python ${{ matrix.python.action }} -e ${{ matrix.task.nox }} -- --use-wheel dist/*.whl - - name: Codecov - run: | - codecov -n "GitHub Actions - ${{ matrix.task.name}} - ${{ matrix.os.name }} ${{ matrix.python.name }}" check: name: ${{ matrix.task.name}} - ${{ matrix.python.name }} @@ -231,6 +231,42 @@ jobs: password: ${{ secrets.PYPI_TOKEN }} verbose: true + coverage: + name: Combine & check coverage. + needs: test-linux + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + # Use latest Python, so it understands all syntax. + python-version: 3.11 + + - run: python -Im pip install --upgrade coverage[toml] + + - uses: actions/download-artifact@v3 + with: + name: coverage-data + + - name: Combine coverage & fail if it's <100%. + run: | + python -Im coverage combine + python -Im coverage html --skip-covered --skip-empty + + # Report and write to summary. + python -Im coverage report | sed 's/^/ /' >> $GITHUB_STEP_SUMMARY + + # Report again and fail if under 100%. + python -Im coverage report --fail-under=100 + + - name: Upload HTML report if check failed. + uses: actions/upload-artifact@v3 + with: + name: html-report + path: htmlcov + if: ${{ failure() }} + # This is a meta-job to simplify PR CI enforcement configuration in GitHub. # Inside the GitHub config UI you only configure this job as required. # All the extra requirements are defined "as code" as part of the `needs` @@ -247,6 +283,7 @@ jobs: - build - test-linux - test-windows + - coverage - check - pypi-publish steps: diff --git a/noxfile.py b/noxfile.py index 607f89f9..f32539d2 100644 --- a/noxfile.py +++ b/noxfile.py @@ -37,8 +37,6 @@ def tests(session: nox.Session) -> None: if os.environ.get("CI") != "true": session.notify("coverage_report") - else: - session.run("coverage", "combine") @nox.session diff --git a/src/towncrier/newsfragments/497.misc b/src/towncrier/newsfragments/497.misc new file mode 100644 index 00000000..e69de29b diff --git a/src/towncrier/test/test_git.py b/src/towncrier/test/test_git.py new file mode 100644 index 00000000..e4f807af --- /dev/null +++ b/src/towncrier/test/test_git.py @@ -0,0 +1,15 @@ +# Copyright (c) Amber Brown, 2015 +# See LICENSE for details. + + +from twisted.trial.unittest import TestCase + +from towncrier import _git + + +class TestGit(TestCase): + def test_empty_remove(self): + """ + If remove_files gets an empty list, it returns gracefully. + """ + _git.remove_files([])