Changeset 59287 for trunk/.github/workflows/test-coverage.yml
- Timestamp:
- 10/24/2024 03:07:06 PM (7 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/.github/workflows/test-coverage.yml
r59208 r59287 25 25 workflow_dispatch: 26 26 27 # Cancels all previous workflow runs for pull requests that have not completed. 28 concurrency: 29 # The concurrency group contains the workflow name and the branch name for pull requests 30 # or the commit hash for any other events. 31 group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} 32 cancel-in-progress: true 33 27 34 # Disable permissions for all available scopes by default. 28 35 # Any needed permissions should be configured at the job level. … … 36 43 37 44 jobs: 38 # Runs the PHPUnit tests for WordPress.39 45 # 40 # Performs the following steps: 41 # - Sets environment variables. 42 # - Checks out the repository. 43 # - Sets up Node.js. 44 # - Sets up PHP. 45 # - Installs Composer dependencies. 46 # - Installs npm dependencies 47 # - Logs general debug information about the runner. 48 # - Logs Docker debug information (about the Docker installation within the runner). 49 # - Starts the WordPress Docker container. 50 # - Logs the running Docker containers. 51 # - Logs debug information about what's installed within the WordPress Docker containers. 52 # - Install WordPress within the Docker container. 53 # - Run the PHPUnit tests as a single site. 54 # - Ensures version-controlled files are not modified or deleted. 55 # - Upload the single site code coverage report to Codecov.io. 56 # - Run the PHPUnit tests as a multisite installation. 57 # - Ensures version-controlled files are not modified or deleted. 58 # - Upload the multisite code coverage report to Codecov.io. 46 # Creates a PHPUnit test jobs for generating code coverage reports. 47 # 59 48 test-coverage-report: 60 name: ${{ matrix.multisite && 'Multisite' || 'Single site' }} report (${{ matrix.format }})61 runs-on: ubuntu-latest49 name: ${{ matrix.multisite && 'Multisite' || 'Single site' }} report 50 uses: WordPress/wordpress-develop/.github/workflows/reusable-phpunit-tests-v3.yml@trunk 62 51 permissions: 63 52 contents: read 64 timeout-minutes: 12065 53 if: ${{ github.repository == 'WordPress/wordpress-develop' }} 66 54 strategy: … … 68 56 matrix: 69 57 multisite: [ false, true ] 70 format: [ clover, html ] 71 72 steps: 73 - name: Configure environment variables 74 run: | 75 echo "PHP_FPM_UID=$(id -u)" >> $GITHUB_ENV 76 echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV 77 78 - name: Checkout repository 79 uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 80 with: 81 show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} 82 83 - name: Set up Node.js 84 uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 85 with: 86 node-version-file: '.nvmrc' 87 cache: npm 88 89 ## 90 # This allows Composer dependencies to be installed using a single step. 91 # 92 # Since the tests are currently run within the Docker containers where the PHP version varies, 93 # the same PHP version needs to be configured for the action runner machine so that the correct 94 # dependency versions are installed and cached. 95 ## 96 - name: Set up PHP 97 uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1 98 with: 99 php-version: '7.4' 100 coverage: none 101 102 # Since Composer dependencies are installed using `composer update` and no lock file is in version control, 103 # passing a custom cache suffix ensures that the cache is flushed at least once per week. 104 - name: Install Composer dependencies 105 uses: ramsey/composer-install@57532f8be5bda426838819c5ee9afb8af389d51a # v3.0.0 106 with: 107 custom-cache-suffix: $(/bin/date -u --date='last Mon' "+%F") 108 109 - name: Install npm Dependencies 110 run: npm ci 111 112 - name: Log debug information 113 run: | 114 echo "$GITHUB_REF" 115 echo "$GITHUB_EVENT_NAME" 116 npm --version 117 node --version 118 curl --version 119 git --version 120 composer --version 121 locale -a 122 123 - name: Docker debug information 124 run: | 125 docker -v 126 127 - name: Start Docker environment 128 run: | 129 npm run env:start 130 131 - name: Log running Docker containers 132 run: docker ps -a 133 134 - name: WordPress Docker container debug information 135 run: | 136 docker compose run --rm mysql mysql --version 137 docker compose run --rm php php --version 138 docker compose run --rm php php -m 139 docker compose run --rm php php -i 140 docker compose run --rm php locale -a 141 142 - name: Install WordPress 143 run: npm run env:install 144 145 - name: Run tests as a single site 146 if: ${{ ! matrix.multisite }} 147 run: npm run test:php -- --verbose -c phpunit.xml.dist --coverage-${{ 'html' == matrix.format && 'html' || 'clover' }} wp-code-coverage-single-${{ github.sha }}${{ 'clover' == matrix.format && '.xml' || '' }} 148 149 - name: Ensure version-controlled files are not modified during the tests 150 run: git diff --exit-code 151 152 - name: Upload single site report to Codecov 153 if: ${{ ! matrix.multisite && matrix.format == 'clover' && github.event_name != 'pull_request' }} 154 uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0 155 with: 156 token: ${{ secrets.CODECOV_TOKEN }} 157 file: wp-code-coverage-single-${{ github.sha }}${{ 'clover' == matrix.format && '.xml' || '' }} 158 flags: single,php 159 fail_ci_if_error: true 160 161 - name: Upload single site HTML report as artifact 162 if: ${{ ! matrix.multisite && matrix.format == 'html' }} 163 uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 164 with: 165 name: wp-code-coverage-single-${{ github.sha }} 166 path: wp-code-coverage-single-${{ github.sha }} 167 overwrite: true 168 169 - name: Run tests as a multisite install 170 if: ${{ matrix.multisite }} 171 run: npm run test:php -- --verbose -c tests/phpunit/multisite.xml --coverage-${{ 'html' == matrix.format && 'html' || 'clover' }} wp-code-coverage-multisite-${{ github.sha }}${{ 'clover' == matrix.format && '.xml' || '' }} 172 173 - name: Ensure version-controlled files are not modified during the tests 174 run: git diff --exit-code 175 176 - name: Upload multisite report to Codecov 177 if: ${{ matrix.multisite && matrix.format == 'clover' && github.event_name != 'pull_request' }} 178 uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0 179 with: 180 token: ${{ secrets.CODECOV_TOKEN }} 181 file: wp-code-coverage-multisite-${{ github.sha }}${{ 'clover' == matrix.format && '.xml' || '' }} 182 flags: multisite,php 183 fail_ci_if_error: true 184 185 - name: Upload multisite HTML report as artifact 186 if: ${{ matrix.multisite && matrix.format == 'html' }} 187 uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 188 with: 189 name: wp-code-coverage-multisite-${{ github.sha }} 190 path: wp-code-coverage-multisite-${{ github.sha }} 191 overwrite: true 58 coverage-report: [ true ] 59 with: 60 php: '8.3' 61 multisite: ${{ matrix.multisite }} 62 coverage-report: ${{ matrix.coverage-report }} 63 secrets: 64 CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} 192 65 193 66 slack-notifications:
Note: See TracChangeset
for help on using the changeset viewer.