Make WordPress Core

Changeset 63517


Ignore:
Timestamp:
09/07/2026 04:05:46 PM (2 months ago)
Author:
lancewillett
Message:

Build/Test Tools: Share smoke checks between install and upgrade jobs.

Move the upgrade smoke check into a composite action and run it after new installations. Continue skipping multisite because moving a network to a temporary port requires coordinated configuration and database changes.

Follow-up to [63447].

Developed in: ​https://github.com/WordPress/wordpress-develop/pull/13388

Props adrianmoldovanwp, lucatume.
See #66036.

Location:
trunk/.github
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/.github/workflows/install-testing.yml

    r63396 r63517  
    1313    # Always test the workflow after it's updated.
    1414    paths:
     15      - '.github/actions/smoke-check/**'
    1516      - '.github/workflows/install-testing.yml'
    1617      - '.version-support-*.json'
    … …  
    1920    # Always test the workflow when changes are suggested.
    2021    paths:
     22      - '.github/actions/smoke-check/**'
    2123      - '.version-support-*.json'
    2224      - '.github/workflows/install-testing.yml'
    … …  
    6163  # - Creates a `wp-config.php` file.
    6264  # - Installs WordPress.
     65  # - Serves the installed site and confirms it renders.
    6366  install-tests-mysql:
    6467    name: WP ${{ inputs.wp-version || 'nightly' }} / PHP ${{ matrix.php }} / ${{ 'mariadb' == matrix.db-type && 'MariaDB' || 'MySQL' }} ${{ matrix.db-version }}${{ matrix.multisite && ' multisite' || '' }}
    … …  
    6770    runs-on: ${{ matrix.os }}
    6871    if: ${{ github.repository == 'WordPress/wordpress-develop' }}
    69     timeout-minutes: 10
     72    timeout-minutes: 15
    7073    needs: [ build-test-matrix ]
     74
     75    env:
     76      WP_ADMIN_USER: admin
     77      WP_ADMIN_PASSWORD: password
    7178    strategy:
    7279      fail-fast: false
    … …  
    136143
    137144      - name: Install WordPress
    138         run: wp core ${{ matrix.multisite && 'multisite-install' || 'install' }} --url=http://localhost/ --title="Upgrade Test" --admin_user=admin --admin_password=password --admin_email=me@example.org --skip-email
     145        run: |
     146          wp core ${{ matrix.multisite && 'multisite-install' || 'install' }} \
     147          --url=http://localhost/ --title="Install Test" --admin_user="${WP_ADMIN_USER}" \
     148          --admin_password="${WP_ADMIN_PASSWORD}" --admin_email=me@example.org --skip-email
     149
     150      - name: Check out the smoke check action
     151        if: ${{ ! matrix.multisite }}
     152        uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
     153        with:
     154          path: ci-tools
     155          sparse-checkout: .github/actions
     156          persist-credentials: false
     157
     158      - name: Post-install smoke check
     159        # A network's domain lives in wp-config.php and the database, not just an option.
     160        if: ${{ ! matrix.multisite }}
     161        uses: ./ci-tools/.github/actions/smoke-check
     162        with:
     163          admin-user: ${{ env.WP_ADMIN_USER }}
     164          admin-password: ${{ env.WP_ADMIN_PASSWORD }}
    139165
    140166  slack-notifications:
  • trunk/.github/workflows/reusable-upgrade-testing.yml

    r63447 r63517  
    142142        run: wp core version
    143143
     144      - name: Check out the smoke check action
     145        if: ${{ ! inputs.multisite }}
     146        uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
     147        with:
     148          path: ci-tools
     149          sparse-checkout: .github/actions
     150          persist-credentials: false
     151
    144152      - name: Post-upgrade smoke check
    145153        # A network's domain lives in wp-config.php and the database, not just an option.
    146154        if: ${{ ! inputs.multisite }}
    147         run: |
    148           site_url="http://127.0.0.1:${SITE_PORT}"
    149           server_log="${RUNNER_TEMP}/server.log"
    150           jar="${RUNNER_TEMP}/cookies.txt"
    151           response="${RUNNER_TEMP}/response.txt"
    152           code="${RUNNER_TEMP}/http-code.txt"
    153           http_code=''
    154 
    155           # Nothing undoes these, so this step stays last.
    156           wp option update home "${site_url}"
    157           wp option update siteurl "${site_url}"
    158           # Both make requests no check asked for, and the update checks call api.wordpress.org.
    159           wp config set DISABLE_WP_CRON true --raw
    160           wp config set WP_HTTP_BLOCK_EXTERNAL true --raw
    161 
    162           # opcache counts php -S as a web SAPI, so the runner's JIT runs here and segfaults.
    163           php -d opcache.jit=disable -S "127.0.0.1:${SITE_PORT}" -t . > "${server_log}" 2>&1 &
    164           server_pid=$!
    165 
    166           stop_server() {
    167             local status=$?
    168             kill "${server_pid}" 2> /dev/null || true
    169             wait "${server_pid}" 2> /dev/null || true
    170             [ "${status}" -eq 0 ] || cat "${server_log}" || true
    171             exit "${status}"
    172           }
    173           trap stop_server EXIT
    174 
    175           # No connection prints 000 and exits 7, which set -e would take as fatal.
    176           deadline=$(( SECONDS + 30 ))
    177           while :; do
    178             ready_code="$(curl --silent --max-time 5 --output /dev/null --write-out '%{http_code}' "${site_url}/" || true)"
    179             [ "${ready_code}" = '000' ] || break
    180             [ "${SECONDS}" -lt "${deadline}" ] || { echo '::error::the server never answered'; exit 1; }
    181             sleep 1
    182           done
    183 
    184           fail() {
    185             echo "::error::${1}"
    186             tail -n 20 "${response}"
    187             exit 1
    188           }
    189 
    190           # An HTTP error returns to the caller. No reply at all is fatal.
    191           fetch() {
    192             local path="${1}" status=0
    193             shift
    194             : > "${response}"
    195             curl --silent --show-error --max-time 30 --output "${response}" \
    196               --write-out '%{http_code}' --cookie "${jar}" --cookie-jar "${jar}" \
    197               "$@" "${site_url}${path}" > "${code}" || status=$?
    198             http_code="$(cat "${code}")"
    199             [ "${status}" -eq 0 ] || [ "${status}" -eq 22 ] \
    200               || fail "${path} got no reply and curl exited ${status}"
    201             return "${status}"
    202           }
    203 
    204           check() {
    205             local path="${1}" marker status=0
    206             shift
    207             fetch "${path}" --fail-with-body || status=$?
    208             [ "${status}" -eq 0 ] || fail "${path} returned HTTP ${http_code}"
    209             for marker in "$@"; do
    210               grep -qF -e "${marker}" "${response}" || fail "${path} did not contain: ${marker}"
    211             done
    212             echo "ok  ${path}"
    213           }
    214 
    215           version="$(wp core version)"
    216 
    217           # A fatal mid-page still returns 200, so every check also asks for the closing tag.
    218           check '/' "content=\"WordPress ${version}\"" 'Hello world!' '</html>'
    219 
    220           fetch '/?rest_route=/' --fail-with-body || fail "/?rest_route=/ returned HTTP ${http_code}"
    221           jq -e '.name == "Upgrade Test"' "${response}" > /dev/null \
    222             || fail 'the REST index was not the expected JSON'
    223           echo 'ok  /?rest_route=/'
    224 
    225           # It prints this for an empty database too, which the checks above rule out.
    226           check '/wp-admin/upgrade.php' 'No Update Required' '</html>'
    227 
    228           fetch '/?p=99999999' || true
    229           [ "${http_code}" = '404' ] || fail "a missing post returned ${http_code}, expected 404"
    230           grep -qF '</html>' "${response}" || fail 'the 404 page was cut short'
    231           echo 'ok  404 handling'
    232 
    233           login_status=0
    234           fetch '/wp-login.php' --fail-with-body \
    235             --data-urlencode "log=${WP_ADMIN_USER}" --data-urlencode "pwd=${WP_ADMIN_PASSWORD}" || login_status=$?
    236           [ "${login_status}" -eq 0 ] || fail "logging in returned HTTP ${http_code}"
    237           grep -qF 'wordpress_logged_in_' "${jar}" || fail 'logging in did not set an authentication cookie'
    238           echo 'ok  login'
    239 
    240           # The admin bar renders only for a logged-in user.
    241           check '/wp-admin/' 'id="wpadminbar"' '</html>'
    242 
    243           # Catches a fatal during shutdown. An empty log would let the grep pass silently.
    244           [ -s "${server_log}" ] || { echo '::error::the server wrote no log'; exit 1; }
    245           if grep -qE 'Fatal error|Uncaught|Segmentation fault' "${server_log}"; then
    246             echo '::error::the server logged a fatal error'
    247             exit 1
    248           fi
    249           echo 'ok  server log'
    250         env:
    251           SITE_PORT: 8889
     155        uses: ./ci-tools/.github/actions/smoke-check
     156        with:
     157          admin-user: ${{ env.WP_ADMIN_USER }}
     158          admin-password: ${{ env.WP_ADMIN_PASSWORD }}
  • trunk/.github/workflows/reusable-workflow-lint.yml

    r62936 r63517  
    2929        with:
    3030          args: "-color -verbose"
     31
     32      # actionlint shellchecks inline `run:` blocks, but does not read composite actions.
     33      - name: Run shellcheck on composite action scripts
     34        run: find .github -path '.github/actions/*' -name '*.sh' -print0 | xargs -0 -r shellcheck
    3135
    3236  # Runs the Zizmor GitHub Action workflow file linter.
  • trunk/.github/workflows/upgrade-develop-testing.yml

    r63396 r63517  
    1414      - 'src/**.php'
    1515      # Confirm any changes to relevant workflow files.
     16      - '.github/actions/smoke-check/**'
    1617      - '.github/workflows/upgrade-develop-testing.yml'
    1718      - '.github/workflows/reusable-upgrade-testing.yml'
    … …  
    2526      - 'src/**.php'
    2627      # Confirm any changes to relevant workflow files.
     28      - '.github/actions/smoke-check/**'
    2729      - '.github/workflows/upgrade-develop-testing.yml'
    2830      - '.github/workflows/reusable-upgrade-testing.yml'
  • trunk/.github/workflows/upgrade-testing.yml

    r63437 r63517  
    1010    # Always test the workflow after it's updated.
    1111    paths:
     12      - '.github/actions/smoke-check/**'
    1213      - '.github/workflows/upgrade-testing.yml'
    1314      - '.github/workflows/reusable-upgrade-testing.yml'
    … …  
    1819    # Always test the workflow when changes are suggested.
    1920    paths:
     21      - '.github/actions/smoke-check/**'
    2022      - '.github/workflows/upgrade-testing.yml'
    2123      - '.github/workflows/reusable-upgrade-testing.yml'
  • trunk/.github/workflows/workflow-lint.yml

    r63396 r63517  
    99    paths:
    1010      # Only run when changes are made to workflow files.
     11      - '.github/actions/**'
    1112      - '.github/workflows/**'
    1213  pull_request:
    … …  
    1617    paths:
    1718      # Only run when changes are made to workflow files.
     19      - '.github/actions/**'
    1820      - '.github/workflows/**'
    1921  workflow_dispatch:
Note: See TracChangeset for help on using the changeset viewer.