Skip to content

Commit

Permalink
ci: Add coverage report to the GitHub Actions summary (#20)
Browse files Browse the repository at this point in the history
Co-authored-by: Mark Walker <theshow@gmail.com>
  • Loading branch information
zerolab and marksweb committed Dec 20, 2023
1 parent 6ea198b commit 508a2d8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
24 changes: 17 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

env:
FORCE_COLOR: "1" # Make tools pretty.
TOX_TESTENV_PASSENV: FORCE_COLOR
PIP_DISABLE_PIP_VERSION_CHECK: "1"
PIP_NO_PYTHON_VERSION_WARNING: "1"
# Keep in sync with .pre-commit-config.yaml/default_language_version/python.
PYTHON_LATEST: "3.12"

jobs:
tests:
name: Python ${{ matrix.python-version }}
Expand All @@ -33,8 +41,8 @@ jobs:

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade 'tox>=4.0.0rc3'
python -Im pip install --upgrade pip setuptools wheel
python -Im pip install --upgrade 'tox>=4.7'
- name: Run tox targets for ${{ matrix.python-version }}
run: tox run -f py$(echo ${{ matrix.python-version }} | tr -d .)
Expand All @@ -54,10 +62,10 @@ jobs:

- uses: actions/setup-python@v5
with:
python-version: '3.12'
python-version: ${{env.PYTHON_LATEST}}

- name: Install dependencies
run: python -m pip install --upgrade coverage[toml]
run: python -Im pip install --upgrade coverage[toml]

- name: Download data
uses: actions/download-artifact@v4
Expand All @@ -68,9 +76,11 @@ jobs:

- name: Combine coverage and fail if it's <100%
run: |
python -m coverage combine
python -m coverage html --skip-covered --skip-empty
python -m coverage report
python -Im coverage combine
python -Im coverage html --skip-covered --skip-empty
python -Im coverage report
echo "## Coverage summary" >> $GITHUB_STEP_SUMMARY
python -Im coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
- name: Upload HTML report
if: ${{ failure() }}
Expand Down
4 changes: 4 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ deps = -r requirements/{envname}.txt
package = wheel
set_env =
PYTHONDEVMODE = 1

pass_env =
FORCE_COLOR
NO_COLOR

0 comments on commit 508a2d8

Please sign in to comment.