Changeset 58166 for branches/6.5/.github/workflows/performance.yml
- Timestamp:
- 05/17/2024 06:12:02 PM (7 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/6.5/.github/workflows/performance.yml
r57927 r58166 30 30 permissions: {} 31 31 32 env:33 PUPPETEER_SKIP_DOWNLOAD: ${{ true }}34 35 # Performance testing should be performed in an environment reflecting a standard production environment.36 LOCAL_WP_DEBUG: false37 LOCAL_SCRIPT_DEBUG: false38 LOCAL_SAVEQUERIES: false39 LOCAL_WP_DEVELOPMENT_MODE: "''"40 41 # This workflow takes two sets of measurements — one for the current commit,42 # and another against a consistent version that is used as a baseline measurement.43 # This is done to isolate variance in measurements caused by the GitHub runners44 # from differences caused by code changes between commits. The BASE_TAG value here45 # represents the version being used for baseline measurements. It should only be46 # changed if we want to normalize results against a different baseline.47 BASE_TAG: '6.1.1'48 LOCAL_DIR: build49 TARGET_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || '' }}50 TARGET_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}51 52 32 jobs: 53 33 # Runs the performance test suite. 54 #55 # Performs the following steps:56 # - Configure environment variables.57 # - Checkout repository.58 # - Set up Node.js.59 # - Log debug information.60 # - Install npm dependencies.61 # - Install Playwright browsers.62 # - Build WordPress.63 # - Start Docker environment.64 # - Log running Docker containers.65 # - Docker debug information.66 # - Install WordPress.67 # - Install WordPress Importer plugin.68 # - Import mock data.69 # - Update permalink structure.70 # - Install MU plugin.71 # - 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 # - Run any database upgrades.78 # - 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 # - Set the environment to the baseline version.84 # - Run any database upgrades.85 # - Run baseline performance tests.86 # - Print baseline performance tests results.87 # - Compare results with base.88 # - Add workflow summary.89 # - Set the base sha.90 # - Set commit details.91 # - Publish performance results.92 # - Ensure version-controlled files are not modified or deleted.93 # - Dispatch workflow run.94 34 performance: 95 35 name: Run performance tests 96 runs-on: ubuntu-latest36 uses: WordPress/wordpress-develop/.github/workflows/reusable-performance.yml@trunk 97 37 permissions: 98 38 contents: read 99 39 if: ${{ ( github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' ) && ! contains( github.event.before, '00000000' ) }} 100 101 steps:102 - name: Configure environment variables103 run: |104 echo "PHP_FPM_UID=$(id -u)" >> $GITHUB_ENV105 echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV106 107 - name: Checkout repository108 uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1109 with:110 show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}111 112 - name: Set up Node.js113 uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2114 with:115 node-version-file: '.nvmrc'116 cache: npm117 118 - name: Log debug information119 run: |120 npm --version121 node --version122 curl --version123 git --version124 locale -a125 126 - name: Install npm dependencies127 run: npm ci128 129 - name: Install Playwright browsers130 run: npx playwright install --with-deps131 132 - name: Build WordPress133 run: npm run build134 135 - name: Start Docker environment136 run: |137 npm run env:start138 139 - name: Log running Docker containers140 run: docker ps -a141 142 - name: Docker debug information143 run: |144 docker -v145 docker compose run --rm mysql mysql --version146 docker compose run --rm php php --version147 docker compose run --rm php php -m148 docker compose run --rm php php -i149 docker compose run --rm php locale -a150 151 - name: Install WordPress152 run: npm run env:install153 154 - name: Install WordPress Importer plugin155 run: npm run env:cli -- plugin install wordpress-importer --activate --path=/var/www/${{ env.LOCAL_DIR }}156 157 - name: Import mock data158 run: |159 curl -O https://raw.githubusercontent.com/WordPress/theme-test-data/b9752e0533a5acbb876951a8cbb5bcc69a56474c/themeunittestdata.wordpress.xml160 npm run env:cli -- import themeunittestdata.wordpress.xml --authors=create --path=/var/www/${{ env.LOCAL_DIR }}161 rm themeunittestdata.wordpress.xml162 163 - name: Update permalink structure164 run: |165 npm run env:cli -- rewrite structure '/%year%/%monthnum%/%postname%/' --path=/var/www/${{ env.LOCAL_DIR }}166 167 - name: Install additional languages168 run: |169 npm run env:cli -- language core install de_DE --path=/var/www/${{ env.LOCAL_DIR }}170 npm run env:cli -- language plugin install de_DE --all --path=/var/www/${{ env.LOCAL_DIR }}171 npm run env:cli -- language theme install de_DE --all --path=/var/www/${{ env.LOCAL_DIR }}172 173 - name: Install MU plugin174 run: |175 mkdir ./${{ env.LOCAL_DIR }}/wp-content/mu-plugins176 cp ./tests/performance/wp-content/mu-plugins/server-timing.php ./${{ env.LOCAL_DIR }}/wp-content/mu-plugins/server-timing.php177 178 - name: Run performance tests (current commit)179 run: npm run test:performance180 181 - name: Print performance tests results182 run: node ./tests/performance/results.js183 184 - name: Check out target commit (target branch or previous commit)185 run: |186 if [[ -z "$TARGET_REF" ]]; then187 git fetch -n origin $TARGET_SHA188 else189 git fetch -n origin $TARGET_REF190 fi191 git reset --hard $TARGET_SHA192 193 - name: Set up Node.js194 uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2195 with:196 node-version-file: '.nvmrc'197 cache: npm198 199 - name: Install npm dependencies200 run: npm ci201 202 - name: Build WordPress203 run: npm run build204 205 - name: Run any database upgrades206 run: npm run env:cli -- core update-db --path=/var/www/${{ env.LOCAL_DIR }}207 208 - name: Run target performance tests (base/previous commit)209 env:210 TEST_RESULTS_PREFIX: before211 run: npm run test:performance212 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 - name: Set the environment to the baseline version231 run: |232 npm run env:cli -- core update --version=${{ env.BASE_TAG }} --force --path=/var/www/${{ env.LOCAL_DIR }}233 npm run env:cli -- core version --path=/var/www/${{ env.LOCAL_DIR }}234 235 - name: Run any database upgrades236 run: npm run env:cli -- core update-db --path=/var/www/${{ env.LOCAL_DIR }}237 238 - name: Run baseline performance tests239 env:240 TEST_RESULTS_PREFIX: base241 run: npm run test:performance242 243 - name: Print baseline performance tests results244 env:245 TEST_RESULTS_PREFIX: base246 run: node ./tests/performance/results.js247 248 - name: Compare results with base249 run: node ./tests/performance/compare-results.js ${{ runner.temp }}/summary.md250 251 - name: Add workflow summary252 run: cat ${{ runner.temp }}/summary.md >> $GITHUB_STEP_SUMMARY253 254 - name: Set the base sha255 # Only needed when publishing results.256 if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' }}257 uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1258 id: base-sha259 with:260 github-token: ${{ secrets.GITHUB_TOKEN }}261 script: |262 const baseRef = await github.rest.git.getRef({ owner: context.repo.owner, repo: context.repo.repo, ref: 'tags/${{ env.BASE_TAG }}' });263 return baseRef.data.object.sha;264 265 - name: Set commit details266 # Only needed when publishing results.267 if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' }}268 uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1269 id: commit-timestamp270 with:271 github-token: ${{ secrets.GITHUB_TOKEN }}272 script: |273 const commit_details = await github.rest.git.getCommit({ owner: context.repo.owner, repo: context.repo.repo, commit_sha: context.sha });274 return parseInt((new Date( commit_details.data.author.date ).getTime() / 1000).toFixed(0))275 276 - name: Publish performance results277 # Only publish results on pushes to trunk.278 if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' }}279 env:280 BASE_SHA: ${{ steps.base-sha.outputs.result }}281 COMMITTED_AT: ${{ steps.commit-timestamp.outputs.result }}282 CODEVITALS_PROJECT_TOKEN: ${{ secrets.CODEVITALS_PROJECT_TOKEN }}283 HOST_NAME: "www.codevitals.run"284 run: node ./tests/performance/log-results.js $CODEVITALS_PROJECT_TOKEN trunk $GITHUB_SHA $BASE_SHA $COMMITTED_AT $HOST_NAME285 286 - name: Ensure version-controlled files are not modified or deleted287 run: git diff --exit-code288 40 289 41 slack-notifications:
Note: See TracChangeset
for help on using the changeset viewer.