Split functional & unit tests into reusable workflows#228
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if: ${{ needs.prepare-unit.outputs.matrix != '' }} | ||
| name: Unit test - PHP ${{ matrix.php }}${{ matrix.coverage && ' (with coverage)' || '' }} ${{ startsWith( matrix.os, 'windows' ) && '(Windows)' || '' }} ${{ startsWith( matrix.os, 'macos' ) && '(macOS)' || '' }} | ||
| name: Unit | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: ${{ fromJson(needs.prepare-unit.outputs.matrix) }} | ||
| runs-on: ${{ matrix.os || 'ubuntu-22.04' }} | ||
|
|
||
| continue-on-error: ${{ matrix.php == 'nightly' }} | ||
|
|
||
| steps: | ||
| - name: Check out source code | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
|
|
||
| - name: Set up PHP environment | ||
| uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2 | ||
| with: | ||
| php-version: '${{ matrix.php }}' | ||
| ini-values: zend.assertions=1, error_reporting=-1, display_errors=On | ||
| extensions: zip | ||
| coverage: ${{ matrix.coverage && 'xdebug' || 'none' }} | ||
| tools: composer,cs2pr | ||
| env: | ||
| COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Install Composer dependencies & cache dependencies | ||
| uses: "ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda" # v3 | ||
| env: | ||
| COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }} | ||
| with: | ||
| # Bust the cache at least once a month - output format: YYYY-MM. | ||
| custom-cache-suffix: $(date -u "+%Y-%m") | ||
|
|
||
| # PHPUnit 10+ may fail a test run when the "old" configuration format is used. | ||
| # Luckily, there is a build-in migration tool since PHPUnit 9.3. | ||
| - name: Migrate PHPUnit configuration for PHPUnit 10+ | ||
| if: ${{ matrix.php >= 8.2 || matrix.php == 'nightly' }} | ||
| continue-on-error: true | ||
| run: composer phpunit -- --migrate-configuration | ||
|
|
||
| - name: Setup problem matcher to provide annotations for PHPUnit | ||
| run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" | ||
|
|
||
| - name: Run PHPUnit with coverage | ||
| if: ${{ matrix.coverage }} | ||
| run: | | ||
| composer phpunit -- --coverage-clover build/logs/unit-coverage.xml | ||
|
|
||
| - name: Run PHPUnit | ||
| if: ${{ ! matrix.coverage }} | ||
| # For example TestBehatTags.php in wp-cli-tests depends on the db type. | ||
| env: | ||
| WP_CLI_TEST_DBTYPE: 'sqlite' | ||
| run: | | ||
| composer phpunit | ||
|
|
||
| - name: Upload code coverage report | ||
| if: ${{ matrix.coverage }} | ||
| uses: codecov/codecov-action@1af58845a975a7985b0beb0cbe6fbbb71a41dbad # v5.5.3 | ||
| with: | ||
| directory: build/logs | ||
| flags: unit | ||
| token: ${{ secrets.CODECOV_TOKEN }} | ||
| uses: ./.github/workflows/reusable-unit.yml | ||
| secrets: inherit | ||
| with: | ||
| php: ${{ matrix.php }} | ||
| coverage: ${{ matrix.coverage }} | ||
| os: ${{ matrix.os }} |
There was a problem hiding this comment.
The caller job name was reduced to a constant (Unit). With a matrix strategy, this makes it difficult to identify which PHP/OS combination failed from the job list. Consider including the matrix values in name: here (you can still reference matrix.* even when the job uses a reusable workflow).
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.