Make WordPress Core


Ignore:
Timestamp:
05/31/2024 07:23:44 PM (11 months ago)
Author:
desrosj
Message:

Build/Test Tools: Make use of new reusable workflows.

This updates the 6.4 branch to utilize the new reusable workflows in trunk introduced in [58165].

This also includes backports for a some additional improvements and bug fixes that are necessary for the local development environment to continue working long term:

  • Migrating to Docker Compose V2 (#60901).
  • Removing the version property from docker-compose.yml (#59416).
  • Improvements to how artifacts and comments for Playground testing are generated.
  • Removing SVN related commands causing failures (#61216).
  • Updating the actions/github-scripts action to the latest version.

Merges [57918], [58157], [57124], [57125], [57249] to the 6.4 branch.

Props johnbillion, joemcgill, swissspidy, thelovekesh, narenin, mukesh27, JeffPaul, peterwilsoncc, zieladam, ockham, SergeyBiryukov, jorbin.
Fixes #61216. See #60901, #61101, #59416, #59805, #61213.

Location:
branches/6.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.4

  • branches/6.4/.github/workflows/performance.yml

    r58272 r58276  
    3030permissions: {}
    3131
    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: false
    37   LOCAL_SCRIPT_DEBUG: false
    38   LOCAL_SAVEQUERIES: false
    39   LOCAL_WP_DEVELOPMENT_MODE: "''"
    40   LOCAL_PHP: "8.2-fpm"
    41 
    42   # This workflow takes two sets of measurements — one for the current commit,
    43   # and another against a consistent version that is used as a baseline measurement.
    44   # This is done to isolate variance in measurements caused by the GitHub runners
    45   # from differences caused by code changes between commits. The BASE_TAG value here
    46   # represents the version being used for baseline measurements. It should only be
    47   # changed if we want to normalize results against a different baseline.
    48   BASE_TAG: '6.1.1'
    49   LOCAL_DIR: build
    50   TARGET_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || '' }}
    51   TARGET_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
    52 
    5332jobs:
    5433  # Runs the performance test suite.
    55   #
    56   # Performs the following steps:
    57   # - Configure environment variables.
    58   # - Checkout repository.
    59   # - Set up Node.js.
    60   # - Log debug information.
    61   # - Install npm dependencies.
    62   # - Install Playwright browsers.
    63   # - Build WordPress.
    64   # - Start Docker environment.
    65   # - Log running Docker containers.
    66   # - Docker debug information.
    67   # - Install WordPress.
    68   # - Install WordPress Importer plugin.
    69   # - Import mock data.
    70   # - Update permalink structure.
    71   # - Install MU plugin.
    72   # - Run performance tests (current commit).
    73   # - Print performance tests results.
    74   # - Check out target commit (target branch or previous commit).
    75   # - Switch Node.js versions if necessary.
    76   # - Install npm dependencies.
    77   # - Build WordPress.
    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 baseline performance tests.
    85   # - Print baseline performance tests results.
    86   # - Compare results with base.
    87   # - Add workflow summary.
    88   # - Set the base sha.
    89   # - Set commit details.
    90   # - Publish performance results.
    91   # - Ensure version-controlled files are not modified or deleted.
    92   # - Dispatch workflow run.
    9334  performance:
    9435    name: Run performance tests
    95     runs-on: ubuntu-latest
     36    uses: WordPress/wordpress-develop/.github/workflows/reusable-performance.yml@trunk
    9637    permissions:
    9738      contents: read
    98     if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
    99 
    100     steps:
    101       - name: Configure environment variables
    102         run: |
    103           echo "PHP_FPM_UID=$(id -u)" >> $GITHUB_ENV
    104           echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV
    105 
    106       - name: Checkout repository
    107         uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
    108         with:
    109           show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
    110 
    111       - name: Set up Node.js
    112         uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
    113         with:
    114           node-version-file: '.nvmrc'
    115           cache: npm
    116 
    117       - name: Log debug information
    118         run: |
    119           npm --version
    120           node --version
    121           curl --version
    122           git --version
    123           svn --version
    124           locale -a
    125 
    126       - name: Install npm dependencies
    127         run: npm ci
    128 
    129       - name: Install Playwright browsers
    130         run: npx playwright install --with-deps
    131 
    132       - name: Build WordPress
    133         run: npm run build
    134 
    135       - name: Start Docker environment
    136         run: |
    137           npm run env:start
    138 
    139       - name: Log running Docker containers
    140         run: docker ps -a
    141 
    142       - name: Docker debug information
    143         run: |
    144           docker -v
    145           docker-compose -v
    146           docker-compose run --rm mysql mysql --version
    147           docker-compose run --rm php php --version
    148           docker-compose run --rm php php -m
    149           docker-compose run --rm php php -i
    150           docker-compose run --rm php locale -a
    151 
    152       - name: Install WordPress
    153         run: npm run env:install
    154 
    155       - name: Install WordPress Importer plugin
    156         run: npm run env:cli -- plugin install wordpress-importer --activate --path=/var/www/${{ env.LOCAL_DIR }}
    157 
    158       - name: Import mock data
    159         run: |
    160           curl -O https://raw.githubusercontent.com/WordPress/theme-test-data/b9752e0533a5acbb876951a8cbb5bcc69a56474c/themeunittestdata.wordpress.xml
    161           npm run env:cli -- import themeunittestdata.wordpress.xml --authors=create --path=/var/www/${{ env.LOCAL_DIR }}
    162           rm themeunittestdata.wordpress.xml
    163 
    164       - name: Update permalink structure
    165         run: |
    166           npm run env:cli -- rewrite structure '/%year%/%monthnum%/%postname%/' --path=/var/www/${{ env.LOCAL_DIR }}
    167 
    168       - name: Install MU plugin
    169         run: |
    170           mkdir ./${{ env.LOCAL_DIR }}/wp-content/mu-plugins
    171           cp ./tests/performance/wp-content/mu-plugins/server-timing.php ./${{ env.LOCAL_DIR }}/wp-content/mu-plugins/server-timing.php
    172 
    173       - name: Run performance tests (current commit)
    174         run: npm run test:performance
    175 
    176       - name: Print performance tests results
    177         run: node ./tests/performance/results.js
    178 
    179       - name: Check out target commit (target branch or previous commit)
    180         run: |
    181           if [[ -z "$TARGET_REF" ]]; then
    182             git fetch -n origin $TARGET_SHA
    183           else
    184             git fetch -n origin $TARGET_REF
    185           fi
    186           git reset --hard $TARGET_SHA
    187 
    188       - name: Set up Node.js
    189         uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
    190         with:
    191           node-version-file: '.nvmrc'
    192           cache: npm
    193 
    194       - name: Install npm dependencies
    195         run: npm ci
    196 
    197       - name: Build WordPress
    198         run: npm run build
    199 
    200       - name: Run target performance tests (base/previous commit)
    201         env:
    202           TEST_RESULTS_PREFIX: before
    203         run: npm run test:performance
    204 
    205       - name: Print target performance tests results
    206         env:
    207           TEST_RESULTS_PREFIX: before
    208         run: node ./tests/performance/results.js
    209 
    210       - name: Reset to original commit
    211         run: git reset --hard $GITHUB_SHA
    212 
    213       - name: Set up Node.js
    214         uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
    215         with:
    216           node-version-file: '.nvmrc'
    217           cache: npm
    218 
    219       - name: Install npm dependencies
    220         run: npm ci
    221 
    222       - name: Set the environment to the baseline version
    223         run: |
    224           npm run env:cli -- core update --version=${{ env.BASE_TAG }} --force --path=/var/www/${{ env.LOCAL_DIR }}
    225           npm run env:cli -- core version --path=/var/www/${{ env.LOCAL_DIR }}
    226 
    227       - name: Run baseline performance tests
    228         env:
    229           TEST_RESULTS_PREFIX: base
    230         run: npm run test:performance
    231 
    232       - name: Print baseline performance tests results
    233         env:
    234           TEST_RESULTS_PREFIX: base
    235         run: node ./tests/performance/results.js
    236 
    237       - name: Compare results with base
    238         run: node ./tests/performance/compare-results.js ${{ runner.temp }}/summary.md
    239 
    240       - name: Add workflow summary
    241         run: cat ${{ runner.temp }}/summary.md >> $GITHUB_STEP_SUMMARY
    242 
    243       - name: Set the base sha
    244         # Only needed when publishing results.
    245         if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' }}
    246         uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
    247         id: base-sha
    248         with:
    249             github-token: ${{ secrets.GITHUB_TOKEN }}
    250             script: |
    251                 const baseRef = await github.rest.git.getRef({ owner: context.repo.owner, repo: context.repo.repo, ref: 'tags/${{ env.BASE_TAG }}' });
    252                 return baseRef.data.object.sha;
    253 
    254       - name: Set commit details
    255         # Only needed when publishing results.
    256         if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' }}
    257         uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
    258         id: commit-timestamp
    259         with:
    260             github-token: ${{ secrets.GITHUB_TOKEN }}
    261             script: |
    262                 const commit_details = await github.rest.git.getCommit({ owner: context.repo.owner, repo: context.repo.repo, commit_sha: context.sha });
    263                 return parseInt((new Date( commit_details.data.author.date ).getTime() / 1000).toFixed(0))
    264 
    265       - name: Publish performance results
    266         # Only publish results on pushes to trunk.
    267         if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' }}
    268         env:
    269             BASE_SHA: ${{ steps.base-sha.outputs.result }}
    270             COMMITTED_AT: ${{ steps.commit-timestamp.outputs.result }}
    271             CODEVITALS_PROJECT_TOKEN: ${{ secrets.CODEVITALS_PROJECT_TOKEN }}
    272             HOST_NAME: "www.codevitals.run"
    273         run: node ./tests/performance/log-results.js $CODEVITALS_PROJECT_TOKEN trunk $GITHUB_SHA $BASE_SHA $COMMITTED_AT $HOST_NAME
    274 
    275       - name: Ensure version-controlled files are not modified or deleted
    276         run: git diff --exit-code
     39    if: ${{ ( github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' ) && ! contains( github.event.before, '00000000' ) }}
     40    with:
     41      php-version: '8.2'
    27742
    27843  slack-notifications:
     
    31075    steps:
    31176      - name: Dispatch workflow run
    312         uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
     77        uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
    31378        with:
    31479          retries: 2
Note: See TracChangeset for help on using the changeset viewer.