Skip to content
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
17 changes: 17 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ jobs:
with:
pattern: coverage-data-*
merge-multiple: true

- name: "Get coverage data & fail if it's <80%"
run: |
# if we decide to check cov across versions and combine
Expand All @@ -216,13 +217,29 @@ jobs:

# report again and fail if under 80%.
python -Im coverage report --fail-under=80

- name: "Upload HTML report if check failed 📤"
uses: actions/upload-artifact@v4
with:
name: html-report
path: htmlcov
if: ${{ failure() }}

# seems we need to call this from the main CI workflow first
- name: "Coverage comment 💬"
uses: py-cov-action/python-coverage-comment-action@v3
id: coverage_comment
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: "Store Pull Request comment to be posted 📤"
uses: actions/upload-artifact@v3
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true'
with:
# leave default names
name: python-coverage-comment-action
path: python-coverage-comment-action.txt

profiling:
needs: [build-site, run-pytest]
runs-on: ubuntu-latest
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
test:
name: "Run tests & display coverage"
runs-on: ubuntu-latest
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
permissions:
pull-requests: write
contents: write # needed to edit the comment vs opening multiple ones
Expand All @@ -22,13 +23,7 @@ jobs:
route: GET /repos/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "Check if the trigger was a PR event"
run: |
TRIGGER_EVENT=$(echo '${{ steps.get-run.outputs.data }}' | jq -r '.event')
if [[ "$TRIGGER_EVENT" != "pull_request" ]]; then
echo "Workflow was not triggered by a PR, skipping coverage comment."
exit 78 # Exiting with a neutral status
fi

# this needs the .coverage file so we download from the CI workflow artifacts
- name: "Download coverage data 📥"
uses: actions/download-artifact@v4
Expand All @@ -37,6 +32,10 @@ jobs:
merge-multiple: true
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}

- name: "Check downloaded files"
run: ls -R

- name: "Post coverage comment"
uses: py-cov-action/python-coverage-comment-action@v3
with:
Expand Down
8 changes: 5 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ labels =

# general tox env configuration
# these can be run with any py3{9,12} version
# tox run -e py39-lint
# tox run -e py39-lint
[testenv]
deps =
lint: pre-commit
Expand All @@ -41,9 +41,11 @@ commands =
# example tox run -e py39-profile-docs -- -o profile.svg -n 100
profile-docs: python ./tools/profile.py {posargs}

# tests can be ran with or without coverage (see examples below), it is recommended to run compile before running tests (see examples below),
# tests can be ran with or without coverage (see examples below),
# it is recommended to run compile before running tests (see examples below),
# tox run -e compile,py39-tests
# if you want to skip the assets compilation step you can run the tests without `compile`
# if you want to skip the assets compilation step you can run the tests without
#`compile`, for example:
# tox run -e py39-tests
# run tests with a specific Sphinx version
# tox run -e compile,py39-sphinx61-tests
Expand Down