-
Notifications
You must be signed in to change notification settings - Fork 46
Updated ubuntu and actions in GH workflow #219
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
Changes from 1 commit
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 | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,35 +1,47 @@ | ||||||||||||||||||||||||||||||||||||
| name: CI-coverage | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| on: [ push ] | ||||||||||||||||||||||||||||||||||||
| on: [ push, pull_request ] | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||||||||
| contents: read | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||||||
| test-php: | ||||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-20.04 | ||||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||||
| strategy: | ||||||||||||||||||||||||||||||||||||
| fail-fast: true | ||||||||||||||||||||||||||||||||||||
| matrix: | ||||||||||||||||||||||||||||||||||||
| php-versions: [ "7.4", "8.0", "8.4" ] | ||||||||||||||||||||||||||||||||||||
| phpunit-versions: [ "9" ] | ||||||||||||||||||||||||||||||||||||
| php-version: [ "7.4", "8.0", "8.4" ] | ||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||
| - uses: actions/checkout@v2 | ||||||||||||||||||||||||||||||||||||
| - uses: php-actions/composer@v6 | ||||||||||||||||||||||||||||||||||||
| - uses: actions/checkout@v5 | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| - name: Set up PHP | ||||||||||||||||||||||||||||||||||||
| uses: shivammathur/setup-php@v2 | ||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||
| php_version: "${{ matrix.php-versions }}" | ||||||||||||||||||||||||||||||||||||
| dev: yes | ||||||||||||||||||||||||||||||||||||
| interaction: no | ||||||||||||||||||||||||||||||||||||
| - name: PHPUnit Tests php | ||||||||||||||||||||||||||||||||||||
| uses: php-actions/phpunit@v2 | ||||||||||||||||||||||||||||||||||||
| php-version: "${{ matrix.php-version }}" | ||||||||||||||||||||||||||||||||||||
| extensions: curl, json | ||||||||||||||||||||||||||||||||||||
| coverage: xdebug | ||||||||||||||||||||||||||||||||||||
| tools: composer:v2 | ||||||||||||||||||||||||||||||||||||
| ini-values: xdebug.mode=coverage | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| - name: Validate Composer files | ||||||||||||||||||||||||||||||||||||
| run: composer validate --strict | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| - name: Install dependencies | ||||||||||||||||||||||||||||||||||||
| uses: ramsey/composer-install@v3 | ||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||
| version: "${{ matrix.phpunit-versions }}" | ||||||||||||||||||||||||||||||||||||
| php_version: "${{ matrix.php-versions }}" | ||||||||||||||||||||||||||||||||||||
| php_extensions: xdebug | ||||||||||||||||||||||||||||||||||||
| bootstrap: vendor/autoload.php | ||||||||||||||||||||||||||||||||||||
| configuration: phpunit.xml | ||||||||||||||||||||||||||||||||||||
| args: --coverage-clover=coverage.xml --exclude-group local-only | ||||||||||||||||||||||||||||||||||||
| composer-options: --no-interaction --prefer-dist | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| - name: Run PHPUnit | ||||||||||||||||||||||||||||||||||||
| run: vendor/bin/phpunit --configuration phpunit.xml --coverage-clover=coverage.xml --exclude-group local-only | ||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||
| XDEBUG_MODE: coverage | ||||||||||||||||||||||||||||||||||||
| - name: Upload to Codecov | ||||||||||||||||||||||||||||||||||||
| uses: codecov/codecov-action@v1 | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
|
Comment on lines
+35
to
+39
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. 🛠️ Refactor suggestion Run coverage only on PHP 8.4 to speed up the matrix Currently you collect coverage on all PHP versions. Use a small shell wrapper to only enable coverage on 8.4 and run plain tests elsewhere. - - name: Run PHPUnit
- run: vendor/bin/phpunit --configuration phpunit.xml --coverage-clover=coverage.xml --exclude-group local-only
- env:
- XDEBUG_MODE: coverage
+ - name: Run PHPUnit
+ run: |
+ if [[ "${{ matrix.php-version }}" == "8.4" ]]; then
+ XDEBUG_MODE=coverage vendor/bin/phpunit --configuration phpunit.xml --coverage-clover=coverage.xml --exclude-group local-only
+ else
+ vendor/bin/phpunit --configuration phpunit.xml --exclude-group local-only
+ fi📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||
| - name: Upload coverage to Codecov | ||||||||||||||||||||||||||||||||||||
| if: matrix.php-version == '8.4' | ||||||||||||||||||||||||||||||||||||
| uses: codecov/codecov-action@v4 | ||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||
| token: ${{ secrets.CODECOV_TOKEN }} | ||||||||||||||||||||||||||||||||||||
| file: ./coverage.xml | ||||||||||||||||||||||||||||||||||||
| files: ./coverage.xml | ||||||||||||||||||||||||||||||||||||
| disable_search: true | ||||||||||||||||||||||||||||||||||||
| fail_ci_if_error: true | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
+40
to
+47
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. 🛠️ Refactor suggestion Prevent failures on forked PRs; gate Codecov upload by event On pull_request from forks, CODECOV_TOKEN is not available. With fail_ci_if_error: true, the workflow can fail the PR. Gate the upload to push events (or when the token exists). - - name: Upload coverage to Codecov
- if: matrix.php-version == '8.4'
+ - name: Upload coverage to Codecov
+ if: github.event_name == 'push' && matrix.php-version == '8.4'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
disable_search: true
- fail_ci_if_error: true
+ fail_ci_if_error: trueAlternatively, if you want uploads on PRs from the same repo, use:
📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||
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.
🛠️ Refactor suggestion
Enable Xdebug/coverage only on the coverage job; drop redundant json extension
Apply:
- name: Set up PHP uses: shivammathur/setup-php@v2 with: php-version: "${{ matrix.php-version }}" - extensions: curl, json - coverage: xdebug + extensions: curl + coverage: ${{ matrix.php-version == '8.4' && 'xdebug' || 'none' }} tools: composer:v2 - ini-values: xdebug.mode=coverageThen adjust the PHPUnit step (see below) to only enable coverage on 8.4.
🤖 Prompt for AI Agents