Skip to content

Commit f67c036

Browse files
authored
Fix code coverage workflow (#2393)
#2378 --- Main fix: - CI.yml's "coverage comment" step stopped working when `persist_credentials: false` was added, added a workaround because `persist_credentials` is a security feature. --- - Removed a duplicate step "Coverage comment" because is already defined above in CI.yml. - This removed code was tied to coverage.yml (deleted too), that did not ever trigger because github.event.name is a typo instead of github.event_name, so the trigger condition was never met. - Removed some pin comments that are not in sync with the versions.
1 parent a5b3600 commit f67c036

2 files changed

Lines changed: 10 additions & 66 deletions

File tree

.github/workflows/CI.yml

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ jobs:
112112
include-hidden-files: true
113113

114114
- name: "Upload Playwright traces, if any 🐾"
115-
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v4.7.0.1
115+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
116116
if: ${{ failure() }}
117117
with:
118118
name: playwright-traces-${{ matrix.os }}-${{ matrix.python-version }}
@@ -165,9 +165,17 @@ jobs:
165165
path: htmlcov
166166
if: ${{ failure() }}
167167

168+
# persist-credentials: false above strips the git credential helper, but
169+
# python-coverage-comment-action relies on `git push` to save coverage data.
170+
# Re-inject the token into the remote URL so git can authenticate.
171+
- name: "Restore git credentials for coverage data push"
172+
run: git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
173+
env:
174+
GITHUB_TOKEN: ${{ github.token }}
175+
168176
# seems we need to call this from the main CI workflow first
169177
- name: "Coverage comment 💬"
170-
uses: py-cov-action/python-coverage-comment-action@63f52f4fbbffada6e8dee8ec432de7e01df9ba79 # 3.38.0
178+
uses: py-cov-action/python-coverage-comment-action@63f52f4fbbffada6e8dee8ec432de7e01df9ba79
171179
id: coverage_comment
172180
with:
173181
GITHUB_TOKEN: ${{ github.token }}
@@ -206,22 +214,3 @@ jobs:
206214
name: profile-results
207215
path: docbuild_profile.svg
208216
if-no-files-found: ignore
209-
210-
# Calling the coverage-comment action from the main CI workflow
211-
# we might want to pin the SHA once merged
212-
coverage-comment:
213-
# Important: make sure to update the SHA after making any changes to the coverage workflow
214-
# removing pin to test changes
215-
uses: ./.github/workflows/coverage.yml
216-
needs: [coverage]
217-
# ensures this runs even if the coverage step does not continue - e.g. the
218-
# default coverage action will fail at first for external PRs, this is a workaround
219-
# to ensure the comment is posted
220-
if: ${{ github.event.name == 'pull_request'}}
221-
with:
222-
# this is the workflow run ID of the `CI.yml` workflow
223-
workflow_run_id: ${{ github.event.workflow_run.id }}
224-
permissions:
225-
contents: write
226-
pull-requests: write
227-
actions: read

.github/workflows/coverage.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)