-
Notifications
You must be signed in to change notification settings - Fork 326
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
Try to implement coverage action instead of using codecov. #1756
Changes from all commits
c57a058
427e7b0
c2e406d
95057df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Post coverage comment | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["continuous-integration"] | ||
types: | ||
- completed | ||
|
||
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 | ||
actions: read | ||
steps: | ||
- name: Post comment | ||
uses: py-cov-action/python-coverage-comment-action@v3 | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GITHUB_PR_RUN_ID: ${{ github.event.workflow_run.id }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,6 +94,20 @@ jobs: | |
nox -s compile | ||
- name: Run tests | ||
run: pytest -m "not a11y" --color=yes --cov --cov-report=xml | ||
env: | ||
COVERAGE_FILE: ".coverage.${{ matrix.python-version }}.${{ matrix.os }}.${{ matrix.sphinx-version }}" | ||
- name: Store coverage file | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: coverage-${{ matrix.python-version }}-${{ matrix.os }}-${{ matrix.sphinx-version }} | ||
path: .coverage.${{ matrix.python-version }}.${{ matrix.os }}.${{ matrix.sphinx-version }} | ||
- name: Upload to Codecov | ||
if: matrix.python-version == '3.12' && matrix.os == 'ubuntu-latest' && matrix.sphinx-version == 'dev' | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
fail_ci_if_error: true | ||
env: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||
|
||
# note I am setting this on top of the Python cache as I could not find | ||
# how to set the hash key on the python one | ||
|
@@ -112,6 +126,38 @@ jobs: | |
nox -s a11y | ||
continue-on-error: true | ||
|
||
coverage: | ||
name: Collect Coverage | ||
runs-on: ubuntu-latest | ||
needs: run-pytest | ||
# run both on previous step success and failure | ||
if: "!cancelled()" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm assuming we want coverage even if tests are failing, but not if workflow is cancelled. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes absolute sense as we have the concurrency setting enabled |
||
permissions: | ||
pull-requests: write | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/download-artifact@v4 | ||
id: download | ||
with: | ||
pattern: coverage-* | ||
merge-multiple: true | ||
|
||
- name: Coverage comment | ||
id: coverage_comment | ||
uses: py-cov-action/python-coverage-comment-action@v3 | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
MERGE_COVERAGE_FILES: true | ||
|
||
- name: Store Pull Request comment to be posted | ||
uses: actions/upload-artifact@v4 | ||
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true' | ||
with: | ||
name: python-coverage-comment-action | ||
path: python-coverage-comment-action.txt | ||
|
||
# Build our site on the 3 major OSes and check for Sphinx warnings | ||
build-site: | ||
needs: [lint] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to the names to be unique for collection of all the results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now are only really looking at the coverage for Python 3.12 but I prefer collecting across this.