Changeset 58076 for trunk/.github/workflows/performance.yml
- Timestamp:
- 05/02/2024 01:57:49 PM (14 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/.github/workflows/performance.yml
r57918 r58076 67 67 # - Install WordPress Importer plugin. 68 68 # - Import mock data. 69 # - Deactivate WordPress Importer plugin. 69 70 # - Update permalink structure. 71 # - Install additional languages. 72 # - Disable external HTTP requests. 73 # - Disable cron. 74 # - List defined constants. 70 75 # - Install MU plugin. 71 76 # - Run performance tests (current commit). 72 # - Print performance tests results. 73 # - Check out target commit (target branch or previous commit). 74 # - Switch Node.js versions if necessary. 75 # - Install npm dependencies. 76 # - Build WordPress. 77 # - Download previous build artifact (target branch or previous commit). 78 # - Download artifact. 79 # - Unzip the build. 77 80 # - Run any database upgrades. 81 # - Flush cache. 82 # - Delete expired transients. 78 83 # - Run performance tests (previous/target commit). 79 # - Print target performance tests results.80 # - Reset to original commit.81 # - Switch Node.js versions if necessary.82 # - Install npm dependencies.83 84 # - Set the environment to the baseline version. 84 85 # - Run any database upgrades. 86 # - Flush cache. 87 # - Delete expired transients. 85 88 # - Run baseline performance tests. 86 # - Print baseline performance tests results.87 # - Compare results with base.89 # - Archive artifacts. 90 # - Compare results. 88 91 # - Add workflow summary. 89 92 # - Set the base sha. … … 91 94 # - Publish performance results. 92 95 # - Ensure version-controlled files are not modified or deleted. 93 # - Dispatch workflow run.94 96 performance: 95 name: Run performance tests 97 name: Run performance tests ${{ matrix.memcached && '(with memcached)' || '' }} 96 98 runs-on: ubuntu-latest 97 99 permissions: 98 100 contents: read 99 101 if: ${{ ( github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' ) && ! contains( github.event.before, '00000000' ) }} 100 102 strategy: 103 fail-fast: false 104 matrix: 105 memcached: [ true, false ] 106 env: 107 LOCAL_PHP_MEMCACHED: ${{ matrix.memcached }} 101 108 steps: 102 109 - name: Configure environment variables … … 128 135 129 136 - name: Install Playwright browsers 130 run: npx playwright install --with-deps 137 run: npx playwright install --with-deps chromium 131 138 132 139 - name: Build WordPress … … 134 141 135 142 - name: Start Docker environment 136 run: | 137 npm run env:start 143 run: npm run env:start 144 145 - name: Install object cache drop-in 146 if: ${{ matrix.memcached }} 147 run: cp src/wp-content/object-cache.php build/wp-content/object-cache.php 138 148 139 149 - name: Log running Docker containers … … 161 171 rm themeunittestdata.wordpress.xml 162 172 173 - name: Deactivate WordPress Importer plugin 174 run: npm run env:cli -- plugin deactivate wordpress-importer --path=/var/www/${{ env.LOCAL_DIR }} 175 163 176 - name: Update permalink structure 164 run: | 165 npm run env:cli -- rewrite structure '/%year%/%monthnum%/%postname%/' --path=/var/www/${{ env.LOCAL_DIR }} 177 run: npm run env:cli -- rewrite structure '/%year%/%monthnum%/%postname%/' --path=/var/www/${{ env.LOCAL_DIR }} 166 178 167 179 - name: Install additional languages … … 171 183 npm run env:cli -- language theme install de_DE --all --path=/var/www/${{ env.LOCAL_DIR }} 172 184 185 # Prevent background update checks from impacting test stability. 186 - name: Disable external HTTP requests 187 run: npm run env:cli -- config set WP_HTTP_BLOCK_EXTERNAL true --raw --type=constant --path=/var/www/${{ env.LOCAL_DIR }} 188 189 # Prevent background tasks from impacting test stability. 190 - name: Disable cron 191 run: npm run env:cli -- config set DISABLE_WP_CRON true --raw --type=constant --path=/var/www/${{ env.LOCAL_DIR }} 192 193 - name: List defined constants 194 run: npm run env:cli -- config list --path=/var/www/${{ env.LOCAL_DIR }} 195 173 196 - name: Install MU plugin 174 197 run: | … … 179 202 run: npm run test:performance 180 203 181 - name: Print performance tests results 182 run: node ./tests/performance/results.js 183 184 - name: Check out target commit (target branch or previous commit) 185 run: | 186 if [[ -z "$TARGET_REF" ]]; then 187 git fetch -n origin $TARGET_SHA 188 else 189 git fetch -n origin $TARGET_REF 190 fi 191 git reset --hard $TARGET_SHA 192 193 - name: Set up Node.js 194 uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 195 with: 196 node-version-file: '.nvmrc' 197 cache: npm 198 199 - name: Install npm dependencies 200 run: npm ci 201 202 - name: Build WordPress 203 run: npm run build 204 - name: Download previous build artifact (target branch or previous commit) 205 uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 206 id: get-previous-build 207 with: 208 script: | 209 const artifacts = await github.rest.actions.listArtifactsForRepo({ 210 owner: context.repo.owner, 211 repo: context.repo.repo, 212 name: 'wordpress-build-' + process.env.TARGET_SHA, 213 }); 214 215 const matchArtifact = artifacts.data.artifacts[0]; 216 217 if ( ! matchArtifact ) { 218 core.setFailed( 'No artifact found!' ); 219 return false; 220 } 221 222 const download = await github.rest.actions.downloadArtifact( { 223 owner: context.repo.owner, 224 repo: context.repo.repo, 225 artifact_id: matchArtifact.id, 226 archive_format: 'zip', 227 } ); 228 229 const fs = require( 'fs' ); 230 fs.writeFileSync( '${{ github.workspace }}/before.zip', Buffer.from( download.data ) ) 231 232 return true; 233 234 - name: Unzip the build 235 if: ${{ steps.get-previous-build.outputs.result }} 236 run: | 237 unzip ${{ github.workspace }}/before.zip 238 unzip -o ${{ github.workspace }}/wordpress.zip 204 239 205 240 - name: Run any database upgrades 241 if: ${{ steps.get-previous-build.outputs.result }} 206 242 run: npm run env:cli -- core update-db --path=/var/www/${{ env.LOCAL_DIR }} 207 243 208 - name: Run target performance tests (base/previous commit) 244 - name: Flush cache 245 if: ${{ steps.get-previous-build.outputs.result }} 246 run: npm run env:cli -- cache flush --path=/var/www/${{ env.LOCAL_DIR }} 247 248 - name: Delete expired transients 249 if: ${{ steps.get-previous-build.outputs.result }} 250 run: npm run env:cli -- transient delete --expired --path=/var/www/${{ env.LOCAL_DIR }} 251 252 - name: Run target performance tests (previous/target commit) 253 if: ${{ steps.get-previous-build.outputs.result }} 209 254 env: 210 255 TEST_RESULTS_PREFIX: before 211 256 run: npm run test:performance 212 257 213 - name: Print target performance tests results214 env:215 TEST_RESULTS_PREFIX: before216 run: node ./tests/performance/results.js217 218 - name: Reset to original commit219 run: git reset --hard $GITHUB_SHA220 221 - name: Set up Node.js222 uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2223 with:224 node-version-file: '.nvmrc'225 cache: npm226 227 - name: Install npm dependencies228 run: npm ci229 230 258 - name: Set the environment to the baseline version 259 if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' }} 231 260 run: | 232 261 npm run env:cli -- core update --version=${{ env.BASE_TAG }} --force --path=/var/www/${{ env.LOCAL_DIR }} … … 234 263 235 264 - name: Run any database upgrades 265 if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' }} 236 266 run: npm run env:cli -- core update-db --path=/var/www/${{ env.LOCAL_DIR }} 237 267 268 - name: Flush cache 269 if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' }} 270 run: npm run env:cli -- cache flush --path=/var/www/${{ env.LOCAL_DIR }} 271 272 - name: Delete expired transients 273 if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' }} 274 run: npm run env:cli -- transient delete --expired --path=/var/www/${{ env.LOCAL_DIR }} 275 238 276 - name: Run baseline performance tests 277 if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' }} 239 278 env: 240 279 TEST_RESULTS_PREFIX: base 241 280 run: npm run test:performance 242 281 243 - name: Print baseline performance tests results 244 env: 245 TEST_RESULTS_PREFIX: base 246 run: node ./tests/performance/results.js 247 248 - name: Compare results with base 282 - name: Archive artifacts 283 uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 284 if: always() 285 with: 286 name: performance-artifacts${{ matrix.memcached && '-memcached' || '' }}-${{ github.run_id }} 287 path: artifacts 288 if-no-files-found: ignore 289 290 - name: Compare results 249 291 run: node ./tests/performance/compare-results.js ${{ runner.temp }}/summary.md 250 292 … … 254 296 - name: Set the base sha 255 297 # Only needed when publishing results. 256 if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' }}298 if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' && ! matrix.memcached }} 257 299 uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 258 300 id: base-sha … … 265 307 - name: Set commit details 266 308 # Only needed when publishing results. 267 if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' }}309 if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' && ! matrix.memcached }} 268 310 uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 269 311 id: commit-timestamp … … 276 318 - name: Publish performance results 277 319 # Only publish results on pushes to trunk. 278 if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' }}320 if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' && ! matrix.memcached }} 279 321 env: 280 322 BASE_SHA: ${{ steps.base-sha.outputs.result }}
Note: See TracChangeset
for help on using the changeset viewer.