-
Notifications
You must be signed in to change notification settings - Fork 177
Fix Codecov badge by adding OIDC permission for tokenless upload #856
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
base: master
Are you sure you want to change the base?
Changes from all commits
11caf1f
1497fe7
fa58b7e
5e6556a
91881c2
ba3d8a2
07a7398
e6bcc88
2513a33
3d9317b
367f804
68452bd
e8a9180
683a838
83f5ee5
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 |
|---|---|---|
|
|
@@ -65,6 +65,9 @@ jobs: | |
| test-php: | ||
| name: Test PHP ${{ matrix.php }} ${{ matrix.wp != '' && format( ' (WP {0}) ', matrix.wp ) || '' }} | ||
| runs-on: ubuntu-24.04 | ||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
| strategy: | ||
| matrix: | ||
| php: | ||
|
|
@@ -120,21 +123,31 @@ jobs: | |
| - name: Composer install | ||
| run: | | ||
| rm composer.lock || true # We need to install fresh. | ||
| npm run composer install | ||
| # The composer.json platform override (php: 7.2.24) installs PHPUnit 8.5, which does | ||
| # not support code coverage on PHP 8. Use --ignore-platform-req=php on PHP 8+ so | ||
| # Composer installs PHPUnit 9.6, which supports coverage on PHP 8.x. | ||
| if [[ "${WP_ENV_PHP_VERSION}" == 8.* ]]; then | ||
| npm run composer -- install --ignore-platform-req=php | ||
| else | ||
| npm run composer install | ||
| fi | ||
|
Comment on lines
+126
to
+133
|
||
|
|
||
| - name: Versions | ||
| run: | | ||
| npm run env run cli php -- -v | ||
| npm run env run cli wp core version | ||
|
|
||
| - name: Test | ||
| run: npm run test | ||
| run: | | ||
| npm run env run tests-cli --env-cwd=wp-content/plugins/two-factor -- mkdir -p tests/logs | ||
| npm run test | ||
|
|
||
| - name: Upload code coverage report | ||
| if: ${{ matrix.php == '8.3' && matrix.wp == 'latest' }} | ||
| if: ${{ matrix.php == '8.3' && matrix.wp == 'latest' && hashFiles('tests/logs/clover.xml') != '' }} | ||
| uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de | ||
| with: | ||
| file: tests/logs/clover.xml | ||
| use_oidc: true | ||
| files: tests/logs/clover.xml | ||
| flags: phpunit | ||
| fail_ci_if_error: false | ||
|
|
||
|
|
||
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.
id-token: writeis granted at the job level, which means every matrix run (and every step in those runs) can mint OIDC tokens. Since only the Codecov upload needs OIDC, consider moving coverage upload into a separate job (or otherwise restricting when it runs, e.g., only on trusted push events) so untrusted PR code paths don’t receiveid-token: writeunnecessarily.