Skip to content

Commit 4083546

Browse files
committed
GH Actions/unit-tests: don't run code coverage in forks
The `unit-tests` workflow runs code coverage for pushes to `main` and pull requests, but wasn't limited to this repo. This resulted in failing builds for contributors who have actions enabled on their fork. The reason for the failure is that they don't have access to the `CODECOV_TOKEN`. This commit changes the conditions on when to run the tests normally and when to run with code coverage to take the organisation where the repo lives into account. That should prevent the failing builds in forks.
1 parent afcb17e commit 4083546

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

.github/workflows/unit-tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,15 @@ jobs:
135135
run: composer lint -- --checkstyle | cs2pr
136136

137137
- name: Run the unit tests without code coverage
138-
if: ${{ matrix.coverage == false }}
138+
if: ${{ matrix.coverage == false || github.repository_owner != 'WordPress' }}
139139
run: composer run-tests
140140

141141
- name: Run the unit tests with code coverage
142-
if: ${{ matrix.coverage == true }}
142+
if: ${{ matrix.coverage == true && github.repository_owner == 'WordPress' }}
143143
run: composer coverage
144144

145145
- name: Send coverage report to Codecov
146-
if: ${{ success() && matrix.coverage == true }}
146+
if: ${{ success() && matrix.coverage == true && github.repository_owner == 'WordPress' }}
147147
uses: codecov/codecov-action@v5
148148
with:
149149
files: ./build/logs/clover.xml

0 commit comments

Comments
 (0)