Skip to content

Commit 3dc9c66

Browse files
authored
Fix codecov to work on PRs, and be used as a required check (#298)
* pull_request_target should allow PR jobs to use secrets, enabling codecov uplaods * try to fix it * try again * run on the test environment * and again
1 parent 4f5365d commit 3dc9c66

1 file changed

Lines changed: 7 additions & 13 deletions

File tree

.github/workflows/ci-test.yml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ name: Test
33
on:
44
pull_request:
55
branches: [master]
6+
pull_request_target:
7+
branches: [master]
68
push:
79
branches: [master]
810
schedule:
@@ -16,7 +18,10 @@ concurrency:
1618

1719
jobs:
1820
pytester:
21+
# run on both push & normal PR
22+
if: github.event_name == 'push' || github.event_name == 'pull_request'
1923
runs-on: ${{ matrix.os }}
24+
environment: test
2025
strategy:
2126
fail-fast: false
2227
matrix:
@@ -144,25 +149,14 @@ jobs:
144149
if: matrix.backend == 'redis'
145150
run: pytest -m redis --cov=cachier --cov-report=term --cov-report=xml:cov.xml
146151

147-
- name: Upload coverage to Codecov (non-PRs)
148-
if: github.event_name != 'pull_request' # pushes, scheduled, etc.
152+
- name: Upload coverage to Codecov (non PRs)
149153
continue-on-error: true
150154
uses: codecov/codecov-action@v5
151155
with:
152156
fail_ci_if_error: true
153157
token: ${{ secrets.CODECOV_TOKEN }} # required
154158
flags: ${{ matrix.backend }}
155-
156-
# We need a separate step for PRs because PRs do not have access to
157-
# secrets; hence, provide the token will give it an empty value,
158-
# resulting in an authentication error.
159-
- name: Upload coverage to Codecov (PRs)
160-
if: github.event_name == 'pull_request' # PRs only
161-
continue-on-error: true
162-
uses: codecov/codecov-action@v5
163-
with:
164-
fail_ci_if_error: true
165-
flags: ${{ matrix.backend }}
159+
override_pr: ${{ github.event.pull_request.number }}
166160

167161
testing-guardian:
168162
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)