diff --git a/.env.example b/.env.example index bdd47dedb82d5..3011755feac73 100644 --- a/.env.example +++ b/.env.example @@ -24,7 +24,7 @@ LOCAL_NGINX_COMPRESSION=off LOCAL_NGINX_STATIC_EXPIRES=off # The PHP version to use. Valid options are 'latest', and '{version}-fpm'. -LOCAL_PHP=latest +LOCAL_PHP=8.6-fpm # Whether or not to enable Xdebug. LOCAL_PHP_XDEBUG=false diff --git a/.github/workflows/cleanup-pull-requests.yml b/.github/workflows/cleanup-pull-requests.yml index 578710dcf56ac..6c8d38e67b0b7 100644 --- a/.github/workflows/cleanup-pull-requests.yml +++ b/.github/workflows/cleanup-pull-requests.yml @@ -25,4 +25,4 @@ jobs: permissions: pull-requests: write if: ${{ github.repository == 'WordPress/wordpress-develop' }} - uses: ./.github/workflows/reusable-cleanup-pull-requests.yml + uses: WordPress/wordpress-develop/.github/workflows/reusable-cleanup-pull-requests.yml@trunk diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 6739279616a5d..a09c760c078af 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -88,7 +88,7 @@ jobs: # Runs the PHP coding standards checks. phpcs: name: Coding standards - uses: ./.github/workflows/reusable-coding-standards-php.yml + uses: WordPress/wordpress-develop/.github/workflows/reusable-coding-standards-php.yml@trunk permissions: contents: read if: | @@ -103,7 +103,7 @@ jobs: # Runs the JavaScript coding standards checks. jshint: name: Coding standards - uses: ./.github/workflows/reusable-coding-standards-javascript.yml + uses: WordPress/wordpress-develop/.github/workflows/reusable-coding-standards-javascript.yml@trunk permissions: contents: read if: | @@ -117,7 +117,7 @@ jobs: slack-notifications: name: Slack Notifications - uses: ./.github/workflows/slack-notifications.yml + uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk permissions: actions: read contents: read diff --git a/.github/workflows/end-to-end-tests.yml b/.github/workflows/end-to-end-tests.yml index ee64fd8490b31..398ace4dd07c5 100644 --- a/.github/workflows/end-to-end-tests.yml +++ b/.github/workflows/end-to-end-tests.yml @@ -68,7 +68,7 @@ jobs: # Runs the end-to-end test suite. e2e-tests: name: ${{ matrix.label }} - uses: ./.github/workflows/reusable-end-to-end-tests.yml + uses: WordPress/wordpress-develop/.github/workflows/reusable-end-to-end-tests.yml@trunk permissions: contents: read if: | @@ -93,7 +93,7 @@ jobs: slack-notifications: name: Slack Notifications - uses: ./.github/workflows/slack-notifications.yml + uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk permissions: actions: read contents: read diff --git a/.github/workflows/failed-workflow.yml b/.github/workflows/failed-workflow.yml deleted file mode 100644 index 0eabce41807b9..0000000000000 --- a/.github/workflows/failed-workflow.yml +++ /dev/null @@ -1,59 +0,0 @@ -## -# Performs follow-up tasks when a workflow fails or is cancelled. -## -name: Failed Workflow - -on: - workflow_dispatch: - inputs: - run_id: - description: 'ID of the GitHub Action workflow run to rerun' - required: true - type: 'string' - -# Disable permissions for all available scopes by default. -# Any needed permissions should be configured at the job level. -permissions: {} - -jobs: - # Attempts to rerun a workflow. - # - # Performs the following steps: - # - Retrieves the workflow run that dispatched this workflow. - # - Restarts all failed jobs when the workflow fails or is cancelled for the first time. - failed-workflow: - name: Rerun a workflow - runs-on: ubuntu-26.04 - permissions: - actions: write - timeout-minutes: 30 - - steps: - - name: Rerun a workflow - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 - with: - retries: 15 - retry-exempt-status-codes: 418 - script: | - const workflow_run = await github.rest.actions.getWorkflowRun({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: process.env.RUN_ID, - }); - - // Only rerun after the first run attempt. - if ( workflow_run.data.run_attempt > 1 ) { - core.info(`Skipping rerun, attempt ${workflow_run.data.run_attempt}: ${workflow_run.data.html_url}`); - return; - } - - core.notice(`Rerunning workflow run "${workflow_run.data.name}" on ${workflow_run.data.head_branch}: ${workflow_run.data.html_url}`); - - const rerun = await github.rest.actions.reRunWorkflowFailedJobs({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: process.env.RUN_ID, - enable_debug_logging: true - }); - env: - RUN_ID: ${{ inputs.run_id }} diff --git a/.github/workflows/file-type-check.yml b/.github/workflows/file-type-check.yml index e2773384a8009..0b300be28b9e7 100644 --- a/.github/workflows/file-type-check.yml +++ b/.github/workflows/file-type-check.yml @@ -134,7 +134,7 @@ jobs: slack-notifications: name: Slack Notifications - uses: ./.github/workflows/slack-notifications.yml + uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk permissions: actions: read contents: read diff --git a/.github/workflows/install-testing.yml b/.github/workflows/install-testing.yml deleted file mode 100644 index eb238338b3e87..0000000000000 --- a/.github/workflows/install-testing.yml +++ /dev/null @@ -1,259 +0,0 @@ -# Confirms that installing WordPress using WP-CLI works successfully. -# -# This workflow is not meant to test wordpress-develop checkouts, but rather tagged versions officially available on WordPress.org. -# -# This workflow is triggered for all WordPress versions that are currently receiving security updates. It therefore needs to -# retain support for older PHP and database versions. -name: Installation Tests - -on: - push: - branches: - - trunk - # Always test the workflow after it's updated. - paths: - - '.github/actions/setup-wp-cli/**' - - '.github/actions/run-with-retry/**' - - '.github/actions/smoke-check/**' - - '.github/workflows/install-testing.yml' - - '.version-support-*.json' - - '.github/workflows/reusable-support-json-reader-v1.yml' - - '.github/workflows/reusable-download-wordpress-release.yml' - pull_request: - # Always test the workflow when changes are suggested. - paths: - - '.github/actions/setup-wp-cli/**' - - '.github/actions/run-with-retry/**' - - '.github/actions/smoke-check/**' - - '.version-support-*.json' - - '.github/workflows/install-testing.yml' - - '.github/workflows/reusable-support-json-reader-v1.yml' - - '.github/workflows/reusable-download-wordpress-release.yml' - - schedule: - - cron: '0 0 * * 1' - workflow_dispatch: - inputs: - wp-version: - description: 'The version to test installing. Accepts major and minor versions, "latest", or "nightly". Major releases must not end with ".0".' - type: string - default: 'nightly' - -# Cancels all previous workflow runs for pull requests that have not completed. -concurrency: - # The concurrency group contains the workflow name and the pull request number for pull requests - # or the commit hash for any other events. - group: ${{ github.workflow }}-${{ inputs.wp-version || github.event_name == 'pull_request' && github.event.pull_request.number || github.sha }} - cancel-in-progress: true - -# Disable permissions for all available scopes by default. -# Any needed permissions should be configured at the job level. -permissions: {} - -jobs: - # Determines the supported values for PHP and database versions based on the WordPress version being tested. - build-test-matrix: - name: Build Test Matrix - uses: ./.github/workflows/reusable-support-json-reader-v1.yml - permissions: - contents: read - if: ${{ github.repository == 'WordPress/wordpress-develop' }} - with: - wp-version: ${{ inputs.wp-version }} - - # Downloads a release zip once for every matrix job, waiting until WordPress.org serves it. - download-wordpress: - name: Download WordPress - uses: $/.github/workflows/reusable-download-wordpress-release.yml - permissions: - contents: read - if: ${{ github.repository == 'WordPress/wordpress-develop' }} - with: - version: ${{ inputs.wp-version || 'nightly' }} - - # Test the WordPress installation process through WP-CLI. - # - # Performs the following steps: - # - Sets up PHP. - # - Downloads the specified version of WordPress. - # - Creates a `wp-config.php` file. - # - Installs WordPress. - # - Serves the installed site and confirms it renders. - install-tests-mysql: - name: WP ${{ inputs.wp-version || 'nightly' }} / PHP ${{ matrix.php }} / ${{ 'mariadb' == matrix.db-type && 'MariaDB' || 'MySQL' }} ${{ matrix.db-version }}${{ matrix.multisite && ' multisite' || '' }} - permissions: - contents: read - runs-on: ${{ matrix.os }} - if: ${{ github.repository == 'WordPress/wordpress-develop' }} - timeout-minutes: 15 - needs: [ build-test-matrix, download-wordpress ] - - env: - WP_ADMIN_USER: admin - WP_ADMIN_PASSWORD: password - strategy: - fail-fast: false - matrix: - os: [ ubuntu-26.04 ] - php: ${{ fromJSON( needs.build-test-matrix.outputs.php-versions ) }} - db-type: [ 'mysql' ] - db-version: ${{ fromJSON( needs.build-test-matrix.outputs.mysql-versions ) }} - multisite: [ false, true ] - memcached: [ false ] - - # Exclude some PHP and MySQL versions that cannot currently be tested with Docker containers. - exclude: - # There are no local WordPress Docker environment containers for PHP <= 5.3. - - php: '5.2' - - php: '5.3' - # MySQL containers <= 5.5 do not exist or fail to start properly. - - db-version: '5.0' - - db-version: '5.1' - - db-version: '5.5' - # Only test the latest innovation release. - - db-version: '9.0' - - db-version: '9.1' - - db-version: '9.2' - - db-version: '9.3' - - db-version: '9.4' - - db-version: '9.5' - - db-version: '9.6' - - db-version: '26.7' - # MySQL 9.0+ will not work on PHP 7.2 & 7.3. See https://core.trac.wordpress.org/ticket/61218. - - php: '7.2' - db-version: '9.7' - - php: '7.3' - db-version: '9.7' - - php: '7.2' - db-version: '26.10' - - php: '7.3' - db-version: '26.10' - - services: - database: - image: ${{ matrix.db-type }}:${{ matrix.db-version }} - ports: - - 3306 - # Ping over TCP, to wait for the TCP server rather than the Unix socket. - # MariaDB 11.0 dropped the `mysqladmin` symlink, so pick the client the image ships. - options: >- - --health-cmd="${{ matrix.db-type == 'mariadb' && ! contains( fromJSON('["5.5", "10.0", "10.1", "10.2", "10.3"]'), matrix.db-version ) && 'mariadb-admin' || 'mysqladmin' }} ping -h 127.0.0.1 --protocol=tcp" - --health-interval="30s" - --health-timeout="10s" - --health-retries="5" - -e MYSQL_ROOT_PASSWORD="root" - -e MYSQL_DATABASE="test_db" - --entrypoint sh ${{ matrix.db-type }}:${{ matrix.db-version }} - -c "exec docker-entrypoint.sh mysqld${{ matrix.db-type == 'mysql' && contains( fromJSON('["5.4", "5.5", "5.6", "7.0", "7.1", "7.2", "7.3"]'), matrix.php ) && ( matrix.db-version == '8.4' && ' --mysql-native-password=ON --authentication-policy=mysql_native_password' || ' --default-authentication-plugin=mysql_native_password' ) || '' }}" - - steps: - - name: Set up PHP ${{ matrix.php }} - uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2 - with: - php-version: '${{ matrix.php }}' - coverage: none - - # This job does not check out the repository: `$/` fetches the action from this workflow's commit. - - name: Set up WP-CLI - uses: $/.github/actions/setup-wp-cli - with: - version: ${{ contains( fromJSON('["5.4", "5.5"]'), matrix.php ) && '2.4.0' || contains( fromJSON('["5.6", "7.0", "7.1"]'), matrix.php ) && '2.12.0' || 'latest' }} - - - name: Download the WordPress release artifact - if: ${{ needs.download-wordpress.outputs.artifact != '' }} - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 - with: - name: ${{ needs.download-wordpress.outputs.artifact }} - path: ${{ runner.temp }} - - # WP-CLI 2.4.0 cannot install from a local zip, so unzip it. - - name: Extract WordPress - if: ${{ needs.download-wordpress.outputs.artifact != '' }} - run: | - unzip -q "${RUNNER_TEMP}/wordpress.zip" -d "${RUNNER_TEMP}" - mv "${RUNNER_TEMP}"/wordpress/* . - - # WP-CLI 2.x extracts tarballs with PharData, which truncates paths longer than 100 characters. - # Zip archives are not affected, so download the zip for every version. - - name: Download WordPress - if: ${{ needs.download-wordpress.outputs.artifact == '' }} - # WP-CLI requests WordPress from WordPress.org once, so a network error fails the job. - # It extracts only after a complete download, so a retry starts from an empty directory. - uses: $/.github/actions/run-with-retry - with: - command: | - case "${WP_VERSION}" in - nightly|trunk) wp core download --version=nightly ;; - *) wp core download "https://wordpress.org/wordpress-${WP_VERSION}.zip" ;; - esac - env: - WP_VERSION: ${{ inputs.wp-version || 'nightly' }} - - - name: Create wp-config.php file - run: wp config create --dbname=test_db --dbuser=root --dbpass=root --dbhost="127.0.0.1:${DB_PORT}" - env: - DB_PORT: ${{ job.services.database.ports['3306'] }} - - - name: Install WordPress - run: | - wp core ${{ matrix.multisite && 'multisite-install' || 'install' }} \ - --url=http://localhost/ --title="Install Test" --admin_user="${WP_ADMIN_USER}" \ - --admin_password="${WP_ADMIN_PASSWORD}" --admin_email=me@example.org --skip-email - - - name: Post-install smoke check - # A network's domain lives in wp-config.php and the database, not just an option. - if: ${{ ! matrix.multisite }} - uses: WordPress/wordpress-develop/.github/actions/smoke-check@trunk # zizmor: ignore[unpinned-uses] - with: - admin-user: ${{ env.WP_ADMIN_USER }} - admin-password: ${{ env.WP_ADMIN_PASSWORD }} - - slack-notifications: - name: Slack Notifications - uses: ./.github/workflows/slack-notifications.yml - permissions: - actions: read - contents: read - needs: [ download-wordpress, install-tests-mysql ] - if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }} - with: - calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }} - version: ${{ inputs.wp-version || 'nightly' }} - secrets: - SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }} - SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }} - SLACK_GHA_FIXED_WEBHOOK: ${{ secrets.SLACK_GHA_FIXED_WEBHOOK }} - SLACK_GHA_FAILURE_WEBHOOK: ${{ secrets.SLACK_GHA_FAILURE_WEBHOOK }} - - failed-workflow: - name: Failed workflow tasks - runs-on: ubuntu-26.04 - permissions: - actions: write - needs: [ slack-notifications ] - if: | - always() && - github.repository == 'WordPress/wordpress-develop' && - github.event_name != 'pull_request' && - github.run_attempt < 2 && - ( - contains( needs.*.result, 'cancelled' ) || - contains( needs.*.result, 'failure' ) - ) - - steps: - - name: Dispatch workflow run - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 - with: - retries: 2 - retry-exempt-status-codes: 418 - script: | - github.rest.actions.createWorkflowDispatch({ - owner: context.repo.owner, - repo: context.repo.repo, - workflow_id: 'failed-workflow.yml', - ref: 'trunk', - inputs: { - run_id: `${context.runId}`, - } - }); diff --git a/.github/workflows/javascript-tests.yml b/.github/workflows/javascript-tests.yml index 7c664bae516df..ca299b5d68bb4 100644 --- a/.github/workflows/javascript-tests.yml +++ b/.github/workflows/javascript-tests.yml @@ -89,7 +89,7 @@ jobs: # Runs the WordPress Core JavaScript tests. test-js: name: QUnit Tests - uses: ./.github/workflows/reusable-javascript-tests.yml + uses: WordPress/wordpress-develop/.github/workflows/reusable-javascript-tests.yml@trunk permissions: contents: read if: | @@ -103,7 +103,7 @@ jobs: slack-notifications: name: Slack Notifications - uses: ./.github/workflows/slack-notifications.yml + uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk permissions: actions: read contents: read diff --git a/.github/workflows/javascript-type-checking.yml b/.github/workflows/javascript-type-checking.yml index a65cb7a0afbbb..f7db2a4015821 100644 --- a/.github/workflows/javascript-type-checking.yml +++ b/.github/workflows/javascript-type-checking.yml @@ -44,7 +44,7 @@ jobs: # Runs JavaScript type checking. typecheck: name: JavaScript type checking - uses: ./.github/workflows/reusable-javascript-type-checking-v1.yml + uses: WordPress/wordpress-develop/.github/workflows/reusable-javascript-type-checking-v1.yml@trunk permissions: contents: read if: | @@ -58,7 +58,7 @@ jobs: slack-notifications: name: Slack Notifications - uses: ./.github/workflows/slack-notifications.yml + uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk permissions: actions: read contents: read diff --git a/.github/workflows/local-docker-environment.yml b/.github/workflows/local-docker-environment.yml index a8053e5efdb2f..f108b0a6bc948 100644 --- a/.github/workflows/local-docker-environment.yml +++ b/.github/workflows/local-docker-environment.yml @@ -80,7 +80,7 @@ jobs: # build-test-matrix: name: Build Test Matrix - uses: ./.github/workflows/reusable-support-json-reader-v1.yml + uses: WordPress/wordpress-develop/.github/workflows/reusable-support-json-reader-v1.yml@trunk permissions: contents: read if: ${{ github.repository == 'WordPress/wordpress-develop' }} @@ -90,7 +90,7 @@ jobs: # Tests the local Docker environment. environment-tests-mysql: name: PHP ${{ matrix.php }} - uses: ./.github/workflows/reusable-test-local-docker-environment-v1.yml + uses: WordPress/wordpress-develop/.github/workflows/reusable-test-local-docker-environment-v1.yml@trunk permissions: contents: read needs: [ build-test-matrix ] @@ -127,7 +127,7 @@ jobs: slack-notifications: name: Slack Notifications - uses: ./.github/workflows/slack-notifications.yml + uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk permissions: actions: read contents: read diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index f8c5f54aeda6e..d3779063086f7 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -117,7 +117,7 @@ jobs: # Runs the performance test suite. performance: name: ${{ matrix.multisite && 'Multisite' || 'Single Site' }} ${{ matrix.memcached && 'Memcached' || 'Default' }} - uses: ./.github/workflows/reusable-performance-test-v2.yml + uses: WordPress/wordpress-develop/.github/workflows/reusable-performance-test-v2.yml@trunk needs: [ determine-matrix ] permissions: contents: read @@ -135,7 +135,7 @@ jobs: compare: name: ${{ matrix.label }} - uses: ./.github/workflows/reusable-performance-report-v2.yml + uses: WordPress/wordpress-develop/.github/workflows/reusable-performance-report-v2.yml@trunk needs: [ determine-matrix, performance ] permissions: contents: read @@ -156,7 +156,7 @@ jobs: slack-notifications: name: Slack Notifications - uses: ./.github/workflows/slack-notifications.yml + uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk permissions: actions: read contents: read diff --git a/.github/workflows/php-compatibility.yml b/.github/workflows/php-compatibility.yml index 50d9f9d18314a..d5d2d9224925f 100644 --- a/.github/workflows/php-compatibility.yml +++ b/.github/workflows/php-compatibility.yml @@ -77,7 +77,7 @@ jobs: # Runs PHP compatibility testing. php-compatibility: name: Check PHP compatibility - uses: ./.github/workflows/reusable-php-compatibility.yml + uses: WordPress/wordpress-develop/.github/workflows/reusable-php-compatibility.yml@trunk permissions: contents: read if: | @@ -91,7 +91,7 @@ jobs: slack-notifications: name: Slack Notifications - uses: ./.github/workflows/slack-notifications.yml + uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk permissions: actions: read contents: read diff --git a/.github/workflows/phpstan-static-analysis.yml b/.github/workflows/phpstan-static-analysis.yml index 386a71cece831..386582cfd5e2e 100644 --- a/.github/workflows/phpstan-static-analysis.yml +++ b/.github/workflows/phpstan-static-analysis.yml @@ -41,7 +41,7 @@ jobs: # Runs PHPStan Static Analysis. phpstan: name: PHP static analysis - uses: ./.github/workflows/reusable-phpstan-static-analysis-v2.yml + uses: WordPress/wordpress-develop/.github/workflows/reusable-phpstan-static-analysis-v2.yml@trunk permissions: contents: read if: | @@ -55,7 +55,7 @@ jobs: slack-notifications: name: Slack Notifications - uses: ./.github/workflows/slack-notifications.yml + uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk permissions: actions: read contents: read diff --git a/.github/workflows/phpunit-tests-full-matrix.yml b/.github/workflows/phpunit-tests-full-matrix.yml index eedbbdb087e4e..7cc568ff8e310 100644 --- a/.github/workflows/phpunit-tests-full-matrix.yml +++ b/.github/workflows/phpunit-tests-full-matrix.yml @@ -59,7 +59,7 @@ jobs: # Required by the called workflow's recovery job, which is skipped on PR events. actions: write contents: read - uses: ./.github/workflows/phpunit-tests.yml + uses: WordPress/wordpress-develop/.github/workflows/phpunit-tests.yml@trunk secrets: CODEVITALS_PROJECT_TOKEN: ${{ secrets.CODEVITALS_PROJECT_TOKEN }} CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/phpunit-tests.yml b/.github/workflows/phpunit-tests.yml index 2147698eb1e2b..636099e47c104 100644 --- a/.github/workflows/phpunit-tests.yml +++ b/.github/workflows/phpunit-tests.yml @@ -153,7 +153,7 @@ jobs: # Single site only. Asset tests must not also belong to groups excluded by phpunit.xml.dist. test-assets: name: Core assets - uses: ./.github/workflows/reusable-phpunit-tests-v3.yml + uses: WordPress/wordpress-develop/.github/workflows/reusable-phpunit-tests-v3.yml@trunk needs: [ select-test-coverage, prepare-gutenberg ] permissions: contents: read @@ -169,7 +169,7 @@ jobs: # Downloads and verifies the Gutenberg build once for all PHPUnit jobs. prepare-gutenberg: name: Prepare Gutenberg Assets - uses: ./.github/workflows/reusable-prepare-gutenberg.yml + uses: WordPress/wordpress-develop/.github/workflows/reusable-prepare-gutenberg.yml@trunk permissions: contents: read if: | @@ -190,7 +190,7 @@ jobs: # test-with-mysql: name: PHP ${{ matrix.php }} - uses: ./.github/workflows/reusable-phpunit-tests-v3.yml + uses: WordPress/wordpress-develop/.github/workflows/reusable-phpunit-tests-v3.yml@trunk needs: [ select-test-coverage, prepare-gutenberg ] permissions: contents: read @@ -303,7 +303,7 @@ jobs: # test-with-mariadb: name: PHP ${{ matrix.php }} - uses: ./.github/workflows/reusable-phpunit-tests-v3.yml + uses: WordPress/wordpress-develop/.github/workflows/reusable-phpunit-tests-v3.yml@trunk needs: [ select-test-coverage, prepare-gutenberg ] permissions: contents: read @@ -390,7 +390,7 @@ jobs: # test-innovation-releases: name: PHP ${{ matrix.php }} - uses: ./.github/workflows/reusable-phpunit-tests-v3.yml + uses: WordPress/wordpress-develop/.github/workflows/reusable-phpunit-tests-v3.yml@trunk needs: [ select-test-coverage, prepare-gutenberg ] permissions: contents: read @@ -463,7 +463,7 @@ jobs: # html-api-test-groups: name: ${{ matrix.label }} - uses: ./.github/workflows/reusable-phpunit-tests-v3.yml + uses: WordPress/wordpress-develop/.github/workflows/reusable-phpunit-tests-v3.yml@trunk needs: [ select-test-coverage, prepare-gutenberg ] permissions: contents: read @@ -507,7 +507,7 @@ jobs: # limited-matrix-for-forks: name: PHP ${{ matrix.php }} - uses: ./.github/workflows/reusable-phpunit-tests-v3.yml + uses: WordPress/wordpress-develop/.github/workflows/reusable-phpunit-tests-v3.yml@trunk needs: [ select-test-coverage, prepare-gutenberg ] permissions: contents: read @@ -572,7 +572,7 @@ jobs: slack-notifications: name: Slack Notifications - uses: ./.github/workflows/slack-notifications.yml + uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk permissions: actions: read contents: read diff --git a/.github/workflows/reusable-build-package.yml b/.github/workflows/reusable-build-package.yml deleted file mode 100644 index 2d1d6ad34e103..0000000000000 --- a/.github/workflows/reusable-build-package.yml +++ /dev/null @@ -1,69 +0,0 @@ -## -# A reusable workflow that builds and packages WordPress. The resulting package can be used to test upgrading and installing. -# -# This workflow is used by `trunk` and branches >= 6.8. -## -name: Build and package WordPress - -on: - workflow_call: - -# Disable permissions for all available scopes by default. -# Any needed permissions should be configured at the job level. -permissions: {} - -jobs: - # Builds and packages WordPress. - # - # Performs the following steps: - # - Checks out the repository. - # - Sets up Node.js. - # - Runs the build script. - # - Prepares the directory structure for the ZIP. - # - Creates a ZIP of the built files. - # - Uploads the ZIP as a GitHub Actions artifact. - build: - name: WordPress - permissions: - contents: read - runs-on: ubuntu-26.04 - timeout-minutes: 20 - - steps: - - name: Checkout repository - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - persist-credentials: false - - - name: Set up Node.js - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 - with: - node-version-file: '.nvmrc' - package-manager-cache: false - - - name: Set up npm - # Release branches run this workflow from trunk, but some older branches may lack the action. - if: ${{ hashFiles('.github/actions/setup-npm/action.yml') != '' }} - uses: ./.github/actions/setup-npm - - - name: Install npm Dependencies - run: npm ci - - - name: Build WordPress - timeout-minutes: 5 - run: npm run build - - - name: Prepare the directory structure for the ZIP - run: mv build wordpress - - - name: Create ZIP of built files - run: zip -q -r develop.zip wordpress/. - - - name: Upload ZIP as a GitHub Actions artifact - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 - with: - name: wordpress-develop - path: develop.zip - if-no-files-found: error - retention-days: 1 diff --git a/.github/workflows/reusable-cleanup-pull-requests.yml b/.github/workflows/reusable-cleanup-pull-requests.yml deleted file mode 100644 index b8e5af9319dad..0000000000000 --- a/.github/workflows/reusable-cleanup-pull-requests.yml +++ /dev/null @@ -1,136 +0,0 @@ -## -# A reusable workflow that finds and closes any pull requests that are linked to Trac -# tickets that are referenced as fixed in commit messages. -# -# More info about using GitHub pull requests for contributing to WordPress can be found in the handbook: https://make.wordpress.org/core/handbook/contribute/git/github-pull-requests-for-code-review/. -# -# This workflow is used by `trunk` and branches >= 6.8. -## -name: Run pull request cleanup - -on: - workflow_call: - -jobs: - # Finds and closes pull requests referencing fixed Trac tickets in commit messages using the - # documented expected format - # - # Commit message format is documented in the Core handbook: https://make.wordpress.org/core/handbook/best-practices/commit-messages/. - # - # Performs the following steps: - # - Parse fixed ticket numbers from the commit message. - # - Parse the SVN revision from the commit message. - # - Searches for pull requests referencing any fixed tickets. -# - Comments on pull requests referencing any fixed tickets before closing. - close-prs: - name: Find and close PRs - runs-on: ubuntu-26.04 - permissions: - pull-requests: write - - steps: - - name: Find fixed ticket numbers - id: trac-tickets - env: - COMMIT_MSG_RAW: ${{ github.event.head_commit.message }} - run: | - COMMIT_MESSAGE="$(echo "$COMMIT_MSG_RAW" | sed -n '/^Fixes #/,/\./p')" - echo "fixed_list=$(echo "$COMMIT_MESSAGE" | sed -n 's/.*Fixes #\([0-9]\+\).*/\1/p' | tr '\n' ' ')" >> "$GITHUB_OUTPUT" - - - name: Get the SVN revision - id: git-svn-id - env: - COMMIT_MSG_RAW: ${{ github.event.head_commit.message }} - run: | - COMMIT_MESSAGE="$(echo "$COMMIT_MSG_RAW" | sed -n '$p')" - echo "svn_revision_number=$(echo "$COMMIT_MESSAGE" | sed -n 's/.*git-svn-id: https:\/\/develop.svn.wordpress.org\/[^@]*@\([0-9]*\) .*/\1/p')" >> "$GITHUB_OUTPUT" - - - name: Find, comment on, and close pull requests - if: ${{ steps.trac-tickets.outputs.fixed_list != '' && steps.git-svn-id.outputs.svn_revision_number != '' }} - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 - env: - FIXED_LIST: ${{ steps.trac-tickets.outputs.fixed_list }} - SVN_REVISION_NUMBER: ${{ steps.git-svn-id.outputs.svn_revision_number }} - with: - script: | - const fixedList = process.env.FIXED_LIST.split(' ').filter(Boolean); - const svnRevisionNumber = process.env.SVN_REVISION_NUMBER; - const githubSha = process.env.GITHUB_SHA; - let prNumbers = []; - - core.notice(`Processing pull request cleanup for SVN changeset: https://core.trac.wordpress.org/changeset/${svnRevisionNumber}`); - - for (const ticket of fixedList) { - const tracTicketUrl = `https://core.trac.wordpress.org/ticket/${ticket}`; - const corePrefix = `core-${ticket}`; - - core.info(`Ticket: ${tracTicketUrl}`); - - const query = ` - query($searchQuery: String!) { - search(query: $searchQuery, type: ISSUE_ADVANCED, first: 20) { - nodes { - ... on PullRequest { - number - body - } - } - } - } - `; - - // The PR template only asks for "a link to the WordPress Trac ticket", so some - // PRs reference it as a Markdown link with just the ticket number as the link - // text (e.g. "Trac ticket: [65864](https://core.trac.wordpress.org/ticket/65864)"). - // GitHub's search index doesn't cover Markdown link targets, only the rendered - // text, so the bare ticket number is searched for too to surface those PRs. - const searchQuery = `repo:${context.repo.owner}/${context.repo.repo} is:pr is:open ( "${tracTicketUrl}" OR "${corePrefix}" OR "${ticket}" )`; - - const result = await github.graphql(query, { - searchQuery, - }); - - // Since search queries will match anywhere for any activity on a pull request, the body - // specifically needs to be manually checked. The raw `body` (rather than `bodyText`) is used - // here because `bodyText` strips Markdown links down to just their visible text, which would - // drop the Trac ticket URL entirely for PRs that link the ticket via its number. - const matchingPRs = result.search.nodes - .filter(pr => { - const bodyLower = pr.body.toLowerCase(); - - return bodyLower.includes(tracTicketUrl.toLowerCase()) || bodyLower.includes(corePrefix.toLowerCase()); - }).map(pr => pr.number); - - prNumbers.push(...matchingPRs); - } - - const commentBody = `A commit was made that fixes the Trac ticket referenced in the description of this pull request. - - SVN changeset: [${svnRevisionNumber}](https://core.trac.wordpress.org/changeset/${svnRevisionNumber}) - GitHub commit: https://github.com/WordPress/wordpress-develop/commit/${githubSha} - - This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.`; - - const uniquePrNumbers = [...new Set(prNumbers)]; - core.info(`Found ${uniquePrNumbers.length} pull request(s) to close.`); - - // Update all matched pull requests. - for (const prNumber of uniquePrNumbers) { - core.info(`Closing pull request: https://github.com/${context.repo.owner}/${context.repo.repo}/pull/${prNumber}`); - - // Comment on the pull request with details. - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: prNumber, - body: commentBody - }); - - // Close the pull request. - await github.rest.pulls.update({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: prNumber, - state: 'closed' - }); - } diff --git a/.github/workflows/reusable-coding-standards-javascript.yml b/.github/workflows/reusable-coding-standards-javascript.yml deleted file mode 100644 index e58a6c061cada..0000000000000 --- a/.github/workflows/reusable-coding-standards-javascript.yml +++ /dev/null @@ -1,68 +0,0 @@ -## -# A reusable workflow that checks the JavaScript coding standards. -# -# This workflow is used by `trunk` and branches >= 4.7. -## -name: JavaScript coding standards - -on: - workflow_call: - -env: - PUPPETEER_SKIP_DOWNLOAD: true - -# Disable permissions for all available scopes by default. -# Any needed permissions should be configured at the job level. -permissions: {} - -jobs: - # Runs the JavaScript coding standards checks. - # - # JSHint violations are not currently reported inline with annotations. - # - # Performs the following steps: - # - Checks out the repository. - # - Sets up Node.js. - # - Logs debug information about the GitHub Action runner. - # - Installs npm dependencies. - # - Run the WordPress JSHint checks. - # - Ensures version-controlled files are not modified or deleted. - jshint: - name: JavaScript checks - runs-on: ubuntu-26.04 - permissions: - contents: read - timeout-minutes: 20 - - steps: - - name: Checkout repository - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - persist-credentials: false - - - name: Set up Node.js - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 - with: - node-version-file: '.nvmrc' - package-manager-cache: false - - - name: Set up npm - # Release branches run this workflow from trunk, but some older branches may lack the action. - if: ${{ hashFiles('.github/actions/setup-npm/action.yml') != '' }} - uses: ./.github/actions/setup-npm - - - name: Log debug information - run: | - npm --version - node --version - git --version - - - name: Install npm Dependencies - run: npm ci - - - name: Run JSHint - run: npm run grunt jshint - - - name: Ensure version-controlled files are not modified or deleted - run: git diff --exit-code diff --git a/.github/workflows/reusable-coding-standards-php.yml b/.github/workflows/reusable-coding-standards-php.yml deleted file mode 100644 index cb8700408b0f3..0000000000000 --- a/.github/workflows/reusable-coding-standards-php.yml +++ /dev/null @@ -1,111 +0,0 @@ -## -# A reusable workflow that checks the PHP coding standards. -# -# This workflow is used by `trunk` and branches >= 5.1. -## -name: PHP coding standards - -on: - workflow_call: - inputs: - php-version: - description: 'The PHP version to use.' - required: false - type: 'string' - default: 'latest' - old-branch: - description: 'Whether this is an old branch that runs phpcbf instead of phpcs' - required: false - type: 'boolean' - default: false - -# Disable permissions for all available scopes by default. -# Any needed permissions should be configured at the job level. -permissions: {} - -jobs: - # Runs the PHP coding standards checks. - # - # Violations are reported inline with annotations. - # - # Performs the following steps: - # - Checks out the repository. - # - Sets up PHP. - # - Gets last Monday's date for use in cache keys. - # - Configures caching for PHPCS scans. - # - Installs Composer dependencies. - # - Make Composer packages available globally. - # - Runs PHPCS on the full codebase (warnings excluded). - # - Generate a report for displaying issues as pull request annotations. - # - Runs PHPCS on the `tests` directory without (warnings included). - # - Generate a report for displaying `test` directory issues as pull request annotations. - # - Ensures version-controlled files are not modified or deleted. - phpcs: - name: PHP checks - runs-on: ubuntu-26.04 - permissions: - contents: read - timeout-minutes: 20 - - steps: - - name: Checkout repository - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - persist-credentials: false - - - name: Set up PHP - uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2 - with: - php-version: ${{ inputs.php-version }} - coverage: none - tools: cs2pr - - # This date is used to ensure that the PHPCS cache is cleared at least once every week. - # http://man7.org/linux/man-pages/man1/date.1.html - - name: "Get last Monday's date" - id: get-date - run: echo "date=$(/bin/date -u --date='last Mon' "+%F")" >> "$GITHUB_OUTPUT" - - - name: Cache PHPCS scan cache - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 - with: - path: | - .cache/phpcs-src.json - .cache/phpcs-tests.json - key: ${{ runner.os }}-date-${{ steps.get-date.outputs.date }}-php-${{ inputs.php-version }}-phpcs-cache-${{ hashFiles('**/composer.json', 'phpcs.xml.dist') }} - - # Since Composer dependencies are installed using `composer update` and no lock file is in version control, - # passing a custom cache suffix ensures that the cache is flushed at least once per week. - - name: Install Composer dependencies - uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0 - with: - custom-cache-suffix: ${{ steps.get-date.outputs.date }} - - - name: Make Composer packages available globally - run: echo "${PWD}/vendor/bin" >> "$GITHUB_PATH" - - - name: Run PHPCS on all Core files - id: phpcs-core - if: ${{ ! inputs.old-branch }} - run: phpcs -n --report-full --cache=./.cache/phpcs-src.json --report-checkstyle=./.cache/phpcs-report.xml - - - name: Show PHPCS results in PR - if: ${{ always() && steps.phpcs-core.outcome == 'failure' }} - run: cs2pr ./.cache/phpcs-report.xml - - - name: Check test suite files for warnings - id: phpcs-tests - if: ${{ ! inputs.old-branch }} - run: phpcs tests --report-full --cache=./.cache/phpcs-tests.json --report-checkstyle=./.cache/phpcs-tests-report.xml - - - name: Show test suite scan results in PR - if: ${{ always() && steps.phpcs-tests.outcome == 'failure' }} - run: cs2pr ./.cache/phpcs-tests-report.xml - - - name: Run PHPCBF on all Core files (old branches) - if: ${{ inputs.old-branch }} - run: phpcbf - - - name: Ensure version-controlled files are not modified during the tests - run: git diff --exit-code diff --git a/.github/workflows/reusable-download-wordpress-release.yml b/.github/workflows/reusable-download-wordpress-release.yml deleted file mode 100644 index ec953abbfd58f..0000000000000 --- a/.github/workflows/reusable-download-wordpress-release.yml +++ /dev/null @@ -1,101 +0,0 @@ -## -# A reusable workflow that downloads a WordPress release zip once and shares it as an artifact. -# -# For a while after a release is uploaded, some WordPress.org download servers do not have the new zip yet. -# This workflow waits until the zip downloads and passes its md5 check, so the jobs that use it do not each fail. -## -name: Download a WordPress release - -on: - workflow_call: - inputs: - version: - description: 'The WordPress version to download. "latest", "nightly", "trunk" and "develop" are not downloaded.' - type: string - required: true - outputs: - artifact: - description: 'The name of the artifact that holds wordpress.zip, or an empty string when nothing was downloaded.' - value: ${{ jobs.download.outputs.artifact }} - -# Disable permissions for all available scopes by default. -# Any needed permissions should be configured at the job level. -permissions: {} - -jobs: - # Downloads the release zip and uploads it as an artifact. - # - # Performs the following steps: - # - Sets up PHP and WP-CLI. - # - Downloads the release zip, retrying until it is available. - # - Uploads the zip as an artifact. - download: - name: Download WordPress ${{ inputs.version }} - permissions: - contents: read - runs-on: ubuntu-26.04 - timeout-minutes: 50 - outputs: - artifact: ${{ steps.upload.outcome == 'success' && 'wordpress-release' || '' }} - - steps: - - name: Check whether the version is a release - id: check - run: | - case "${WP_VERSION}" in - latest|nightly|trunk|develop) echo "release=false" >> "$GITHUB_OUTPUT" ;; - *) echo "release=true" >> "$GITHUB_OUTPUT" ;; - esac - env: - WP_VERSION: ${{ inputs.version }} - - - name: Set up PHP - if: ${{ steps.check.outputs.release == 'true' }} - uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2 - with: - php-version: '8.4' - coverage: none - - # This job does not check out the repository: `$/` fetches the action from this workflow's commit. - - name: Set up WP-CLI - if: ${{ steps.check.outputs.release == 'true' }} - uses: $/.github/actions/setup-wp-cli - - # A missing md5 checksum is only a warning in WP-CLI, so a try passes only when the hash was verified. - # The URL form always saves a zip; `--version` can save a tar.gz. - - name: Download WordPress ${{ inputs.version }} - if: ${{ steps.check.outputs.release == 'true' }} - run: | - until output=$(wp core download "https://wordpress.org/wordpress-${WP_VERSION}.zip" --no-extract --path="$DOWNLOAD_DIR" 2>&1) \ - && grep -q 'md5 hash verified' <<< "$output"; do - echo "$output" - - if (( SECONDS + RETRY_DELAY_SECONDS > MAX_WAIT_SECONDS )); then - echo "::error::WordPress ${WP_VERSION} could not be downloaded after ${SECONDS} seconds." - exit 1 - fi - - echo "Trying again in ${RETRY_DELAY_SECONDS} seconds." - sleep "$RETRY_DELAY_SECONDS" - rm -rf "$DOWNLOAD_DIR" - done - - echo "$output" - echo "Downloaded WordPress ${WP_VERSION} after waiting ${SECONDS} seconds." - mv "$DOWNLOAD_DIR"/wp_*.zip "$DOWNLOAD_DIR/wordpress.zip" - env: - WP_VERSION: ${{ inputs.version }} - DOWNLOAD_DIR: ${{ runner.temp }}/wordpress-release - MAX_WAIT_SECONDS: 2700 # 45 minutes. - RETRY_DELAY_SECONDS: 60 - - - name: Upload the release zip - id: upload - if: ${{ steps.check.outputs.release == 'true' }} - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 - with: - name: wordpress-release - path: ${{ runner.temp }}/wordpress-release/wordpress.zip - if-no-files-found: error - overwrite: true - retention-days: 30 diff --git a/.github/workflows/reusable-end-to-end-tests.yml b/.github/workflows/reusable-end-to-end-tests.yml deleted file mode 100644 index a7f440e156845..0000000000000 --- a/.github/workflows/reusable-end-to-end-tests.yml +++ /dev/null @@ -1,186 +0,0 @@ -## -# A reusable workflow that runs end-to-end tests. -# -# This workflow is used by `trunk` and branches >= 5.8. -## -name: End-to-end Tests - -on: - workflow_call: - inputs: - LOCAL_SCRIPT_DEBUG: - description: 'Whether to enable script debugging.' - required: false - type: 'boolean' - default: false - php-version: - description: 'The PHP version to use.' - required: false - type: 'string' - default: 'latest' - install-gutenberg: - description: 'Whether to install the Gutenberg plugin.' - required: false - type: 'boolean' - default: true - gutenberg-version: - description: 'A specific version of Gutenberg to install.' - required: false - type: 'string' - install-playwright: - description: 'Whether to install Playwright browsers.' - required: false - type: 'boolean' - default: true - test-group: - description: 'The Playwright project to run. Runs the default projects when empty.' - required: false - type: 'string' - default: '' - -env: - LOCAL_DIR: build - LOCAL_PHP: ${{ inputs.php-version }}${{ 'latest' != inputs.php-version && '-fpm' || '' }} - -# Disable permissions for all available scopes by default. -# Any needed permissions should be configured at the job level. -permissions: {} - -jobs: - # Runs the end-to-end test suite. - # - # Performs the following steps: - # - Sets environment variables. - # - Checks out the repository. - # - Sets up Node.js. - # - Logs debug information about the GitHub Action runner. - # - Installs npm dependencies. - # - Install Playwright browsers. - # - Builds WordPress to run from the `build` directory. - # - Starts the WordPress Docker container. - # - Logs the running Docker containers. - # - Logs Docker debug information (about both the Docker installation within the runner and the WordPress container). - # - Install WordPress within the Docker container. - # - Install Gutenberg. - # - Install additional languages. - # - Run the E2E tests. - # - Uploads screenshots and HTML snapshots as an artifact. - # - Ensures version-controlled files are not modified or deleted. - e2e-tests: - name: ${{ inputs.test-group && format( '{0}, ', inputs.test-group ) || '' }}SCRIPT_DEBUG ${{ inputs.LOCAL_SCRIPT_DEBUG && 'enabled' || 'disabled' }} - runs-on: ubuntu-26.04 - permissions: - contents: read - timeout-minutes: 20 - - steps: - - name: Configure environment variables - run: | - echo "PHP_FPM_UID=$(id -u)" >> "$GITHUB_ENV" - echo "PHP_FPM_GID=$(id -g)" >> "$GITHUB_ENV" - - - name: Checkout repository - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - persist-credentials: false - - - name: Set up Node.js - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 - with: - node-version-file: '.nvmrc' - package-manager-cache: false - - - name: Set up npm - # Release branches run this workflow from trunk, but some older branches may lack the action. - if: ${{ hashFiles('.github/actions/setup-npm/action.yml') != '' }} - uses: ./.github/actions/setup-npm - - - name: Log debug information - run: | - npm --version - node --version - curl --version - git --version - locale -a - - - name: Install npm Dependencies - run: npm ci - - - name: Install Playwright browsers - if: ${{ inputs.install-playwright }} - run: npm exec --no -- playwright install chromium - - - name: Build WordPress - timeout-minutes: 5 - run: npm run build - - - name: Start Docker environment - run: | - npm run env:start - - - name: Log running Docker containers - run: docker ps -a - - - name: Docker debug information - run: | - docker -v - docker compose run --rm mysql mysql --version - docker compose run --rm php php --version - docker compose run --rm php php -m - docker compose run --rm php php -i - docker compose run --rm php locale -a - - - name: Install WordPress - env: - LOCAL_SCRIPT_DEBUG: ${{ inputs.LOCAL_SCRIPT_DEBUG }} - run: npm run env:install - - - name: Download Gutenberg - if: ${{ inputs.install-gutenberg }} - # Downloaded on the runner so failed downloads are retried: WP-CLI tries once. - # Release branches run this workflow from trunk: `$/` resolves to this workflow's commit, not the caller's. - uses: $/.github/actions/download-with-retry - with: - url: https://downloads.wordpress.org/plugin/gutenberg.${{ inputs.gutenberg-version || 'latest-stable' }}.zip - output: gutenberg.zip - - - name: Install Gutenberg - if: ${{ inputs.install-gutenberg }} - run: | - npm run env:cli -- plugin install gutenberg.zip --path="/var/www/${LOCAL_DIR}" - rm gutenberg.zip - # Installing from a zip doesn't log the version; unpinned branches get the latest. - npm run env:cli -- plugin get gutenberg --field=version --path="/var/www/${LOCAL_DIR}" - - - name: Install additional languages - run: | - npm run env:cli -- language core install de_DE --path="/var/www/${LOCAL_DIR}" - npm run env:cli -- language plugin install de_DE --all --path="/var/www/${LOCAL_DIR}" - npm run env:cli -- language theme install de_DE --all --path="/var/www/${LOCAL_DIR}" - - - name: Run E2E tests - run: | - if [ -n "${TEST_GROUP}" ]; then - npm run test:e2e -- --project="${TEST_GROUP}" - else - npm run test:e2e - fi - env: - TEST_GROUP: ${{ inputs.test-group }} - # Chromium is installed above and is the only browser the suite runs. Without this, - # `wp-scripts test-playwright` also downloads Firefox and WebKit on every run. - PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: ${{ inputs.install-playwright && '1' || '' }} - - - name: Archive debug artifacts (screenshots, HTML snapshots) - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 - if: always() - with: - name: failures-artifacts${{ inputs.test-group && format( '-{0}', inputs.test-group ) || '' }}${{ inputs.LOCAL_SCRIPT_DEBUG && '-SCRIPT_DEBUG' || '' }}-${{ github.run_id }} - path: artifacts - if-no-files-found: ignore - include-hidden-files: true - retention-days: 14 - - - name: Ensure version-controlled files are not modified or deleted - run: git diff --exit-code diff --git a/.github/workflows/reusable-javascript-tests.yml b/.github/workflows/reusable-javascript-tests.yml deleted file mode 100644 index bc4d2c9d1ccf8..0000000000000 --- a/.github/workflows/reusable-javascript-tests.yml +++ /dev/null @@ -1,78 +0,0 @@ -## -# A reusable workflow that runs JavaScript tests. -# -# This workflow is used by `trunk` and branches >= 4.7. -## -name: JavaScript tests - -on: - workflow_call: - inputs: - disable-apparmor: - description: 'Whether to disable AppArmor.' - required: false - type: 'boolean' - default: false - -# Disable permissions for all available scopes by default. -# Any needed permissions should be configured at the job level. -permissions: {} - -jobs: - # Runs the QUnit test suite. - # - # Performs the following steps: - # - Checks out the repository. - # - Sets up Node.js. - # - Logs debug information about the GitHub Action runner. - # - Installs npm dependencies. - # - Run the WordPress QUnit tests. - # - Ensures version-controlled files are not modified or deleted. - test-js: - name: Run QUnit tests - runs-on: ubuntu-26.04 - permissions: - contents: read - timeout-minutes: 20 - - steps: - - name: Checkout repository - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - persist-credentials: false - - - name: Set up Node.js - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 - with: - node-version-file: '.nvmrc' - package-manager-cache: false - - - name: Set up npm - # Release branches run this workflow from trunk, but some older branches may lack the action. - if: ${{ hashFiles('.github/actions/setup-npm/action.yml') != '' }} - uses: ./.github/actions/setup-npm - - - name: Log debug information - run: | - npm --version - node --version - git --version - - - name: Install npm Dependencies - run: npm ci - - # Branches prior to 6.1 using outdated versions of Puppeteer fail on the `ubuntu-24.04` image and newer. - # This disables AppArmor in order to work around those failures. - # - # See https://issues.chromium.org/issues/373753919 - # and https://chromium.googlesource.com/chromium/src/+/main/docs/security/apparmor-userns-restrictions.md - - name: Disable AppArmor - if: ${{ inputs.disable-apparmor }} - run: echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns - - - name: Run QUnit tests - run: npm run grunt qunit:compiled - - - name: Ensure version-controlled files are not modified or deleted - run: git diff --exit-code diff --git a/.github/workflows/reusable-javascript-type-checking-v1.yml b/.github/workflows/reusable-javascript-type-checking-v1.yml deleted file mode 100644 index d8d0eeff785a4..0000000000000 --- a/.github/workflows/reusable-javascript-type-checking-v1.yml +++ /dev/null @@ -1,83 +0,0 @@ -## -# A reusable workflow that runs JavaScript Type Checking. -# -# This workflow is used by `trunk` and branches >= 7.0. -## -name: JavaScript Type Checking - -on: - workflow_call: - -# Disable permissions for all available scopes by default. -# Any needed permissions should be configured at the job level. -permissions: {} - -jobs: - # Runs JavaScript type checking. - # - # Violations are reported inline with annotations. - # - # Performs the following steps: - # - Checks out the repository. - # - Sets up Node.js. - # - Logs debug information. - # - Installs npm dependencies. - # - Configures caching for TypeScript build info. - # - Runs JavaScript type checking. - # - Saves the TypeScript build info. - # - Ensures version-controlled files are not modified or deleted. - typecheck: - name: Run JavaScript type checking - runs-on: ubuntu-26.04 - permissions: - contents: read - timeout-minutes: 10 - - steps: - - name: Checkout repository - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - persist-credentials: false - - - name: Set up Node.js - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 - with: - node-version-file: '.nvmrc' - package-manager-cache: false - - - name: Set up npm - # Release branches run this workflow from trunk, but some older branches may lack the action. - if: ${{ hashFiles('.github/actions/setup-npm/action.yml') != '' }} - uses: ./.github/actions/setup-npm - - - name: Log debug information - run: | - npm --version - node --version - - - name: Install npm dependencies - run: npm ci --ignore-scripts - - - name: Cache TypeScript build info - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 - with: - path: | - *.tsbuildinfo - key: "ts-build-info-${{ github.run_id }}" - restore-keys: | - ts-build-info- - - - name: Run JavaScript type checking - run: npm run typecheck:js - - - name: "Save result cache" - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 - if: ${{ !cancelled() }} - with: - path: | - *.tsbuildinfo - key: "ts-build-info-${{ github.run_id }}" - - - name: Ensure version-controlled files are not modified or deleted - run: git diff --exit-code diff --git a/.github/workflows/reusable-performance-report-v2.yml b/.github/workflows/reusable-performance-report-v2.yml deleted file mode 100644 index de9a29a7e68ef..0000000000000 --- a/.github/workflows/reusable-performance-report-v2.yml +++ /dev/null @@ -1,116 +0,0 @@ -## -# A reusable workflow that compares and publishes the performance tests. -# -# This workflow is used by `trunk` and branches >= 6.8. -## -name: Compare and publish performance Tests - -on: - workflow_call: - inputs: - BASE_TAG: - description: 'The version being used for baseline measurements.' - required: true - type: string - memcached: - description: 'Whether to enable memcached.' - required: false - type: boolean - default: false - multisite: - description: 'Whether to use Multisite.' - required: false - type: boolean - default: false - publish: - description: 'Whether to publish the results to Code Vitals.' - required: false - type: boolean - default: false - secrets: - CODEVITALS_PROJECT_TOKEN: - description: 'The authorization token for https://www.codevitals.run/project/wordpress.' - required: false - -env: - BASE_TAG: ${{ inputs.BASE_TAG }} - -# Disable permissions for all available scopes by default. -# Any needed permissions should be configured at the job level. -permissions: {} - -jobs: - # Performs the following steps: - # - Checkout repository. - # - Set up Node.js. - # - Download the relevant performance test artifacts. - # - List the downloaded files for debugging. - # - Compare results. - # - Add workflow summary. - # - Determine the sha of the baseline tag if necessary. - # - Publish performance results if necessary. - compare: - name: ${{ inputs.multisite && 'Multisite' || 'Single Site' }} ${{ inputs.memcached && 'Memcached' || 'Default' }} ${{ inputs.publish && '(Publishes)' || '' }} - runs-on: ubuntu-26.04 - permissions: - contents: read - - steps: - - name: Checkout repository - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - fetch-depth: ${{ github.event_name == 'workflow_dispatch' && '2' || '1' }} - persist-credentials: false - - - name: Set up Node.js - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 - with: - node-version-file: '.nvmrc' - package-manager-cache: false - - - name: Download artifacts - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 - with: - pattern: performance-${{ inputs.multisite && 'multisite' || 'single' }}-${{ inputs.memcached && 'memcached' || 'default' }}-* - path: artifacts - merge-multiple: true - - - name: List files - run: tree artifacts - - - name: Compare results - run: node ./tests/performance/compare-results.js "${RUNNER_TEMP}/summary.md" - - - name: Add workflow summary - run: cat "${RUNNER_TEMP}/summary.md" >> "$GITHUB_STEP_SUMMARY" - - - name: Set the base sha - # Only needed when publishing results. - if: ${{ inputs.publish }} - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 - id: base-sha - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - result-encoding: string - script: | - const baseRef = await github.rest.git.getRef({ - owner: context.repo.owner, - repo: context.repo.repo, - ref: 'tags/' + process.env.BASE_TAG, - }); - return baseRef.data.object.sha; - - - name: Publish performance results - if: ${{ inputs.publish }} - env: - BASE_SHA: ${{ steps.base-sha.outputs.result }} - CODEVITALS_PROJECT_TOKEN: ${{ secrets.CODEVITALS_PROJECT_TOKEN }} - HOST_NAME: codevitals.run - run: | - if [ -z "$CODEVITALS_PROJECT_TOKEN" ]; then - echo "Performance results could not be published. 'CODEVITALS_PROJECT_TOKEN' is not set" - exit 1 - fi - COMMITTED_AT="$(git show -s "$GITHUB_SHA" --format='%cI')" - node ./tests/performance/log-results.js "$CODEVITALS_PROJECT_TOKEN" trunk "$GITHUB_SHA" "$BASE_SHA" "$COMMITTED_AT" "$HOST_NAME" diff --git a/.github/workflows/reusable-performance-test-v2.yml b/.github/workflows/reusable-performance-test-v2.yml deleted file mode 100644 index edff5788cbe50..0000000000000 --- a/.github/workflows/reusable-performance-test-v2.yml +++ /dev/null @@ -1,313 +0,0 @@ -## -# A reusable workflow that runs the performance test suite. -# -# This workflow is used by `trunk` and branches >= 6.8. -## -name: Run performance Tests - -on: - workflow_call: - inputs: - subject: - description: Subject of the test. One of `current`, `before`, or `base`. - required: true - type: string - LOCAL_DIR: - description: 'Where to run WordPress from.' - required: false - type: 'string' - default: 'build' - BASE_TAG: - description: 'The version being used for baseline measurements.' - required: false - type: 'string' - default: '7.1.0' - TARGET_SHA: - description: 'SHA hash of the target commit used for "before" measurements.' - required: true - type: 'string' - php-version: - description: 'The PHP version to use.' - required: false - type: 'string' - default: 'latest' - memcached: - description: 'Whether to enable memcached.' - required: false - type: 'boolean' - default: false - multisite: - description: 'Whether to use Multisite.' - required: false - type: 'boolean' - default: false - outputs: - BASE_TAG: - description: 'The version being used for baseline measurements.' - value: ${{ inputs.BASE_TAG }} - secrets: - CODEVITALS_PROJECT_TOKEN: - description: 'The authorization token for https://www.codevitals.run/project/wordpress.' - required: false - -env: - PUPPETEER_SKIP_DOWNLOAD: true - - # Prevent wp-scripts from downloading extra Playwright browsers, - # since Chromium will be installed in its dedicated step already. - PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true - - # Performance testing should be performed in an environment reflecting a standard production environment. - LOCAL_WP_DEBUG: false - LOCAL_SCRIPT_DEBUG: false - LOCAL_SAVEQUERIES: false - LOCAL_WP_DEVELOPMENT_MODE: "''" - - BASE_TAG: ${{ inputs.BASE_TAG }} - TARGET_SHA: ${{ inputs.TARGET_SHA }} - - LOCAL_DIR: ${{ inputs.LOCAL_DIR }} - LOCAL_PHP_MEMCACHED: ${{ inputs.memcached }} - LOCAL_PHP: ${{ inputs.php-version }}${{ 'latest' != inputs.php-version && '-fpm' || '' }} - LOCAL_MULTISITE: ${{ inputs.multisite }} - -# Disable permissions for all available scopes by default. -# Any needed permissions should be configured at the job level. -permissions: {} - -jobs: - # Performs the following steps: - # - Configure environment variables. - # - Checkout repository. - # - Set up Node.js. - # - Set up PHP. - # - Log debug information. - # - Install npm dependencies. - # - Install Playwright browsers. - # - Build WordPress. - # - Start Docker environment. - # - Put the baseline or target version of WordPress in place if necessary. - # - Install object cache drop-in. - # - Log running Docker containers. - # - Docker debug information. - # - Install WordPress. - # - WordPress debug information. - # - Enable themes on Multisite. - # - Install WordPress Importer plugin. - # - Import mock data. - # - Deactivate WordPress Importer plugin. - # - Update permalink structure. - # - Install additional languages. - # - Disable external HTTP requests. - # - Disable cron. - # - List defined constants. - # - Install MU plugin. - # - Run performance tests. - # - Archive artifacts. - # - Ensure version-controlled files are not modified or deleted. - performance: - name: Test ${{ inputs.subject == 'base' && inputs.BASE_TAG || inputs.subject }} - runs-on: ubuntu-26.04 - permissions: - contents: read - - steps: - - name: Configure environment variables - run: | - echo "PHP_FPM_UID=$(id -u)" >> "$GITHUB_ENV" - echo "PHP_FPM_GID=$(id -g)" >> "$GITHUB_ENV" - - - name: Checkout repository - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - fetch-depth: ${{ github.event_name == 'workflow_dispatch' && '2' || '1' }} - persist-credentials: false - - - name: Set up Node.js - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 - with: - node-version-file: '.nvmrc' - package-manager-cache: false - - - name: Set up npm - # Release branches run this workflow from trunk, but some older branches may lack the action. - if: ${{ hashFiles('.github/actions/setup-npm/action.yml') != '' }} - uses: ./.github/actions/setup-npm - - - name: Set up PHP - if: ${{ inputs.subject == 'base' }} - uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2 - with: - php-version: ${{ inputs.php-version }} - coverage: none - - - name: Set up WP-CLI - if: ${{ inputs.subject == 'base' }} - # Release branches run this workflow from trunk: `$/` resolves to this workflow's commit, not the caller's. - uses: $/.github/actions/setup-wp-cli - - - name: Log debug information - run: | - npm --version - node --version - curl --version - git --version - locale -a - - - name: Install npm dependencies - run: npm ci - - - name: Install Playwright browsers - # A hung install would otherwise run until the 6 hour job limit. The cap - # leaves room for slow downloads. - timeout-minutes: 15 - run: npm exec --no -- playwright install --with-deps chromium - - - name: Start Docker environment - run: npm run env:start - - - name: Build WordPress - timeout-minutes: 5 - run: npm run build - - - name: Download previous build artifact (target branch or previous commit) - if: ${{ inputs.subject == 'before' }} - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 - id: get-previous-build - with: - script: | - const artifacts = await github.rest.actions.listArtifactsForRepo({ - owner: context.repo.owner, - repo: context.repo.repo, - name: 'wordpress-build-' + process.env.TARGET_SHA, - }); - const matchArtifact = artifacts.data.artifacts[0]; - if ( ! matchArtifact ) { - core.setFailed( 'No artifact found!' ); - return false; - } - const download = await github.rest.actions.downloadArtifact( { - owner: context.repo.owner, - repo: context.repo.repo, - artifact_id: matchArtifact.id, - archive_format: 'zip', - } ); - const fs = require( 'fs' ); - fs.writeFileSync( process.env.GITHUB_WORKSPACE + '/before.zip', Buffer.from( download.data ) ) - return true; - - - name: Unzip the previous build - if: ${{ inputs.subject == 'before' }} - run: | - unzip "${GITHUB_WORKSPACE}/before.zip" - unzip -o "${GITHUB_WORKSPACE}/wordpress.zip" - - - name: Set the environment to the baseline version - if: ${{ inputs.subject == 'base' }} - # WP-CLI requests the release from WordPress.org once, so a network error fails the job. - # It extracts only after a complete download, and `--force` lets a retry overwrite files. - uses: $/.github/actions/run-with-retry - with: - command: wp core download --version="${BASE_TAG%.0}" --force --path="${LOCAL_DIR}" - - - name: Install object cache drop-in - if: ${{ inputs.memcached }} - run: cp src/wp-content/object-cache.php build/wp-content/object-cache.php - - - name: Log running Docker containers - run: docker ps -a - - - name: Docker debug information - run: | - docker -v - docker compose run --rm mysql mysql --version - docker compose run --rm php php --version - docker compose run --rm php php -m - docker compose run --rm php php -i - docker compose run --rm php locale -a - - - name: Install WordPress - run: npm run env:install - - - name: Check version number - run: npm run env:cli -- core version --path="/var/www/${LOCAL_DIR}" - - - name: Enable themes on Multisite - if: ${{ inputs.multisite }} - run: | - npm run env:cli -- theme enable twentytwentyone --network --path="/var/www/${LOCAL_DIR}" - npm run env:cli -- theme enable twentytwentythree --network --path="/var/www/${LOCAL_DIR}" - npm run env:cli -- theme enable twentytwentyfour --network --path="/var/www/${LOCAL_DIR}" - npm run env:cli -- theme enable twentytwentyfive --network --path="/var/www/${LOCAL_DIR}" - - - name: Download WordPress Importer plugin - # Downloaded on the runner so failed downloads are retried: WP-CLI tries once. - uses: $/.github/actions/download-with-retry - with: - url: https://downloads.wordpress.org/plugin/wordpress-importer.latest-stable.zip - output: wordpress-importer.zip - - - name: Install WordPress Importer plugin - run: | - npm run env:cli -- plugin install wordpress-importer.zip --activate --path="/var/www/${LOCAL_DIR}" - rm wordpress-importer.zip - - - name: Download mock data - uses: $/.github/actions/download-with-retry - with: - url: https://raw.githubusercontent.com/WordPress/theme-test-data/b9752e0533a5acbb876951a8cbb5bcc69a56474c/themeunittestdata.wordpress.xml - output: themeunittestdata.wordpress.xml - - - name: Import mock data - # The importer waits up to 300 s per attachment download and skips the ones that - # fail: the cap leaves room for a stalled attachment, not a hung import. - timeout-minutes: 15 - run: | - npm run env:cli -- import themeunittestdata.wordpress.xml --authors=create --path="/var/www/${LOCAL_DIR}" - rm themeunittestdata.wordpress.xml - - - name: Deactivate WordPress Importer plugin - run: npm run env:cli -- plugin deactivate wordpress-importer --path="/var/www/${LOCAL_DIR}" - - - name: Install additional languages - run: | - npm run env:cli -- language core install de_DE --path="/var/www/${LOCAL_DIR}" - npm run env:cli -- language plugin install de_DE --all --path="/var/www/${LOCAL_DIR}" - npm run env:cli -- language theme install de_DE --all --path="/var/www/${LOCAL_DIR}" - - # Prevent background update checks from impacting test stability. - - name: Disable external HTTP requests - run: npm run env:cli -- config set WP_HTTP_BLOCK_EXTERNAL true --raw --type=constant --path="/var/www/${LOCAL_DIR}" - - # Prevent background tasks from impacting test stability. - - name: Disable cron - run: npm run env:cli -- config set DISABLE_WP_CRON true --raw --type=constant --path="/var/www/${LOCAL_DIR}" - - - name: List defined constants - run: npm run env:cli -- config list --path="/var/www/${LOCAL_DIR}" - - - name: Install MU plugin - run: | - mkdir "./${LOCAL_DIR}/wp-content/mu-plugins" - cp ./tests/performance/wp-content/mu-plugins/server-timing.php "./${LOCAL_DIR}/wp-content/mu-plugins/server-timing.php" - - - name: Run performance tests - id: performance-tests - run: npm run test:performance - env: - TEST_RESULTS_PREFIX: ${{ inputs.subject != 'current' && inputs.subject || '' }} - - - name: Archive artifacts - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 - # Without test results, a failed setup step would report a second failure here. - if: ${{ always() && steps.performance-tests.outcome != 'skipped' }} - with: - name: performance-${{ inputs.multisite && 'multisite' || 'single' }}-${{ inputs.memcached && 'memcached' || 'default' }}-${{ inputs.subject }} - path: artifacts - if-no-files-found: error - include-hidden-files: true - retention-days: 1 - - - name: Ensure version-controlled files are not modified or deleted - run: git diff --exit-code diff --git a/.github/workflows/reusable-php-compatibility.yml b/.github/workflows/reusable-php-compatibility.yml deleted file mode 100644 index d4bcdad270c40..0000000000000 --- a/.github/workflows/reusable-php-compatibility.yml +++ /dev/null @@ -1,92 +0,0 @@ -## -# A reusable workflow that runs PHP compatibility tests. -# -# This workflow is used by `trunk` and branches >= 5.5. -## -name: PHP Compatibility - -on: - workflow_call: - inputs: - php-version: - description: 'The PHP version to use.' - required: false - type: 'string' - default: 'latest' - -# Disable permissions for all available scopes by default. -# Any needed permissions should be configured at the job level. -permissions: {} - -jobs: - # Runs PHP compatibility tests. - # - # Violations are reported inline with annotations. - # - # Performs the following steps: - # - Checks out the repository. - # - Sets up PHP. - # - Logs debug information. - # - Configures caching for PHP compatibility scans. - # - Installs Composer dependencies. - # - Make Composer packages available globally. - # - Runs the PHP compatibility tests. - # - Generate a report for displaying issues as pull request annotations. - # - Ensures version-controlled files are not modified or deleted. - php-compatibility: - name: Run compatibility checks - runs-on: ubuntu-26.04 - permissions: - contents: read - timeout-minutes: 20 - - steps: - - name: Checkout repository - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - persist-credentials: false - - - name: Set up PHP - uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2 - with: - php-version: ${{ inputs.php-version }} - coverage: none - tools: cs2pr - - - name: Log debug information - run: | - composer --version - - # This date is used to ensure that the PHP compatibility cache is cleared at least once every week. - # http://man7.org/linux/man-pages/man1/date.1.html - - name: "Get last Monday's date" - id: get-date - run: echo "date=$(/bin/date -u --date='last Mon' "+%F")" >> "$GITHUB_OUTPUT" - - - name: Cache PHP compatibility scan cache - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 - with: - path: .cache/phpcompat.json - key: ${{ runner.os }}-date-${{ steps.get-date.outputs.date }}-php-${{ inputs.php-version }}-phpcompat-cache-${{ hashFiles('**/composer.json', 'phpcompat.xml.dist') }} - - # Since Composer dependencies are installed using `composer update` and no lock file is in version control, - # passing a custom cache suffix ensures that the cache is flushed at least once per week. - - name: Install Composer dependencies - uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0 - with: - custom-cache-suffix: ${{ steps.get-date.outputs.date }} - - - name: Make Composer packages available globally - run: echo "${PWD}/vendor/bin" >> "$GITHUB_PATH" - - - name: Run PHP compatibility tests - id: phpcs - run: phpcs --standard=phpcompat.xml.dist --report-full --report-checkstyle=./.cache/phpcs-compat-report.xml - - - name: Show PHPCompatibility results in PR - if: ${{ always() && steps.phpcs.outcome == 'failure' }} - run: cs2pr ./.cache/phpcs-compat-report.xml - - - name: Ensure version-controlled files are not modified or deleted - run: git diff --exit-code diff --git a/.github/workflows/reusable-phpstan-static-analysis-v1.yml b/.github/workflows/reusable-phpstan-static-analysis-v1.yml deleted file mode 100644 index cda319835e645..0000000000000 --- a/.github/workflows/reusable-phpstan-static-analysis-v1.yml +++ /dev/null @@ -1,317 +0,0 @@ -## -# A reusable workflow that runs PHP Static Analysis tests. -# -# This workflow is used by branches 7.0 and 7.1. -## -name: PHP Static Analysis - -on: - workflow_call: - inputs: - php-version: - description: 'The PHP version to use.' - required: false - type: 'string' - default: 'latest' - -# Disable permissions for all available scopes by default. -# Any needed permissions should be configured at the job level. -permissions: {} - -jobs: - # Runs PHP static analysis tests. - # - # Violations are reported inline with annotations. For pull requests, the results are also uploaded - # as an artifact, which the PHPStan Pull Request Comments workflow summarizes in a comment. - # - # Performs the following steps: - # - Checks out the repository. - # - Sets up PHP. - # - Logs debug information. - # - Installs Composer dependencies. - # - Make Composer packages available globally. - # - Builds WordPress. - # - Configures caching for PHPStan static analysis scans. - # - Runs PHPStan static analysis. - # - Reports the results as annotations. - # - Uploads the results as an artifact (pull requests only). - # - Checks for errors that cannot be reported as warnings, such as out-of-date baselines. - # - Saves the PHPStan result cache. - # - Ensures version-controlled files are not modified or deleted. - phpstan: - name: Run PHP static analysis - runs-on: ubuntu-26.04 - permissions: - contents: read - timeout-minutes: 20 - - steps: - # For a pull request, the parents of the merge commit are fetched too, to find the files that the base branch - # has changed since the pull request branched from it. - - name: Checkout repository - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - persist-credentials: false - fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 1 }} - - - name: Set up PHP - uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2 - with: - php-version: ${{ inputs.php-version }} - coverage: none - - - name: General debug information - run: | - composer --version - - # Since Composer dependencies are installed using `composer update` and no lock file is in version control, - # passing a custom cache suffix ensures that the cache is flushed at least once per week. - - name: Install Composer dependencies - uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0 - with: - custom-cache-suffix: $(/bin/date -u --date='last Mon' "+%F") - - - name: Make Composer packages available globally - run: echo "${PWD}/vendor/bin" >> "$GITHUB_PATH" - - # The directory holds more than the analysis results. PHPStan also stores what it read out of - # each source file there, the docblocks and signatures it found, keyed by that file's contents - # and nothing else. The extensions in `tests/phpstan` change what reading a file yields without - # changing the file: a parser node visitor rewrites a docblock in the syntax tree, and the bytes - # on disk stay as they were. A cache written before one of them changed therefore answers with - # what the old code saw, and the analysis silently runs against types no longer derived. - # - # Keying on the configuration and the extensions keeps a run from restoring a cache that - # predates either. The baselines are left out of the key: they only decide which reported errors - # are ignored, PHPStan invalidates the results cache on a configuration change by itself, and - # including them would discard the whole cache every time one is regenerated. - # - # The cache is renamed rather than only prefixed, because the key this replaces restored on - # `phpstan-result-cache-`, which every key below still begins with. A branch that has not - # merged this commit yet runs the workflow it has, and that workflow would prefix-match the - # caches written here: it would analyse without the extensions against reflection derived with - # them. A name of its own leaves those runs restoring only their own caches. - - name: Cache PHP Static Analysis scan cache - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 - with: - path: .cache # This is defined in the base.neon file. - key: "phpstan-analysis-cache-${{ hashFiles('phpstan.neon.dist', 'tests/phpstan/*.neon', 'tests/phpstan/*.php') }}-${{ github.run_id }}" - restore-keys: | - phpstan-analysis-cache-${{ hashFiles('phpstan.neon.dist', 'tests/phpstan/*.neon', 'tests/phpstan/*.php') }}- - - - name: Run PHP static analysis tests - id: phpstan - run: | - # The report is written to a file for the steps below, which turn it into annotations, - # the pull request comment, and a check for errors that cannot be reported as warnings. - # Only the report goes to standard output; the debug output goes to standard error, so - # it stays in the log without corrupting the JSON. - # - # The step shell exits on the first failing command, which would also end the step on - # the status of 1 that PHPStan uses for reporting errors. Capture the status instead. - status=0 - composer run phpstan -- -vvv --error-format=json > "${RUNNER_TEMP}/phpstan-report.json" || status=$? - - # PHPStan exits 1 when it has errors to report, which is the expected case here and - # is what the annotations are for. Anything higher means it did not finish at all. - if [ "${status}" -gt 1 ]; then - echo "::error title=PHPStan did not complete::The analysis exited with status ${status}, so the code was not fully checked. This is a failure of the run itself rather than a problem found in the code." - exit "${status}" - fi - - # Errors are annotated as warnings, so that they are visible on the pull request without - # failing the run. The exception is an error that PHPStan does not allow to be ignored, - # such as an out-of-date baseline entry, or one that is not specific to a file. These are - # annotated as errors instead, and the run fails on them in the check further below. - # - # The results are also written out for the PHPStan Pull Request Comments workflow, which - # runs with the permissions needed to comment on the pull request. Only the facts are - # passed along: the comment is composed there, since a pull request can change anything - # that runs here. - - name: Report the analysis results - id: report - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 - with: - script: | - const fs = require( 'fs' ); - - const report = JSON.parse( fs.readFileSync( `${ process.env.RUNNER_TEMP }/phpstan-report.json`, 'utf8' ) ); - const workspace = `${ process.env.GITHUB_WORKSPACE }/`; - - const errors = []; - for ( const [ absolutePath, file ] of Object.entries( report.files ) ) { - const relativePath = absolutePath.startsWith( workspace ) ? absolutePath.slice( workspace.length ) : absolutePath; - for ( const message of file.messages ) { - errors.push( { - file: relativePath, - line: message.line ?? null, - message: message.message, - identifier: message.identifier ?? null, - tip: message.tip ?? null, - ignorable: message.ignorable, - fixable: message.fixable ?? false, - } ); - } - } - - // Errors that are not specific to a file, such as an `ignoreErrors` entry from a config - // file PHPStan cannot locate it in. These cannot be ignored either. - for ( const message of report.errors ) { - errors.push( { file: null, line: null, message, identifier: null, tip: null, ignorable: false, fixable: false } ); - } - - // PHPStan marks an error it can fix itself, such as a stale baseline entry, as fixable. - const fixHint = 'This can be fixed automatically by running `composer phpstan:fix` (or `npm run typecheck:php:fix`).'; - - for ( const error of errors ) { - const properties = { title: error.identifier ? `PHPStan: ${ error.identifier }` : 'PHPStan' }; - if ( error.file ) { - properties.file = error.file; - } - if ( error.line ) { - properties.startLine = error.line; - } - const message = [ error.message, error.tip, error.fixable ? fixHint : null ].filter( Boolean ).join( '\n' ); - if ( error.ignorable ) { - core.warning( message, properties ); - } else { - core.error( message, properties ); - } - } - - // Tips and whether an error is fixable are left out of the results, since they are only shown in the - // annotations, next to the code. - // - // The commit analyzed is the pull request merged into its base branch, whose second parent is the head - // commit. The files with errors that differ between the two are those the base branch has changed, in - // which the line numbers reported can be off in the head commit. - if ( context.eventName === 'pull_request' ) { - let changedInBase = []; - try { - const filesWithErrors = new Set( errors.map( ( error ) => error.file ) ); - changedInBase = require( 'child_process' ) - .execFileSync( 'git', [ 'diff', '--name-only', '--no-renames', 'HEAD^2', 'HEAD' ], { encoding: 'utf8' } ) - .split( '\n' ) - .filter( ( file ) => filesWithErrors.has( file ) ); - } catch ( error ) { - core.warning( `The files changed in the base branch could not be found: ${ error.message }` ); - } - fs.mkdirSync( `${ process.env.RUNNER_TEMP }/phpstan-results`, { recursive: true } ); - fs.writeFileSync( `${ process.env.RUNNER_TEMP }/phpstan-results/results.json`, JSON.stringify( { - pull_request: context.payload.pull_request.number, - changed_in_base: changedInBase, - errors: errors.map( ( { tip, fixable, ...error } ) => error ), - } ) ); - } - - # Uploads the results for the PHPStan Pull Request Comments workflow, which keeps a comment on the - # pull request up to date with them. - - name: Upload the analysis results as an artifact - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 - if: ${{ github.event_name == 'pull_request' && steps.report.outcome == 'success' }} - with: - name: phpstan-results - path: ${{ runner.temp }}/phpstan-results/ - - # Some errors cannot be ignored, so they cannot be reported as warnings either. Most often - # this is an ignored error that no longer occurs, or occurs a different number of times, - # which is reported under an `ignore.*` identifier. That is not something to fix in the - # code: the usual cause is that the error *was* fixed, leaving a baseline describing a state - # that no longer exists. - # - # Such an error is reported without a line number, so its annotation is not shown alongside - # the changes in the pull request, and one that is not specific to a file has nowhere to be - # shown at all. A passing run would let it go unnoticed, so fail the run on it instead, and - # say what to do about it. - # - # Detection is on PHPStan's own `ignorable` flag rather than on the identifier or message. - - name: Check for errors that cannot be reported as warnings - if: ${{ !cancelled() }} - env: - BASELINES_URL: ${{ github.server_url }}/${{ github.repository }}/tree/${{ github.sha }}/tests/phpstan/baselines - README_URL: ${{ github.server_url }}/${{ github.repository }}/blob/${{ github.sha }}/tests/phpstan/README.md - run: | - # This step runs even when the analysis above it failed, in which case the report may - # never have been written. That failure is reported there, so there is nothing to add - # here beyond staying quiet about a file that was never going to exist. - report="${RUNNER_TEMP}/phpstan-report.json" - if [ ! -f "${report}" ]; then - exit 0 - fi - - # Errors that are not specific to a file are listed separately from the rest, and are - # never ignorable. - unignorable=$( jq '[ .files[].messages[] | select( .ignorable | not ) ] + .errors | length' "${report}" ) - if [ "${unignorable}" -eq 0 ]; then - exit 0 - fi - - # Whether the errors include ignore errors decides what to say about them, but not whether to - # fail: every error that reaches this point fails the run. Ignore errors concern an ignore - # configuration that no longer describes the code. They are `ignore.unmatched`, where a - # pattern matched nothing at all, and `ignore.count`, where it matched a different number of - # times than the entry records. The `ignore.` prefix is matched rather than those two names - # so that any later addition to the group is caught as well. Any other error that cannot be - # ignored is something regenerating the baselines would not help with, so it is reported - # plainly instead. - ignore_errors=$( jq '[ .files[].messages[] | select( .identifier // "" | startswith( "ignore." ) ) ] | length' "${report}" ) - - # The summary is Markdown, and its code spans and fences are written literally, so the - # heredoc is quoted to keep the backticks out of the shell's hands. The links are - # written in reference style for the same reason: the URLs are the only part needing - # a variable, so defining them afterwards keeps the whole of the prose in here. - # - # A newline renders as a line break rather than a space, so each paragraph is one - # line however long that makes it, and the rendered summary wraps to its own width. - baselines_summary=$( cat <<'SUMMARY' - ## PHPStan baselines are out of date - - An ignored error no longer occurs, or occurs a different number of times, so PHPStan reported it under an `ignore.unmatched` or `ignore.count` identifier. - - **If you fixed the error, this is expected.** Each baseline entry records an exact count for a specific file, so that a new occurrence of an already baselined error is reported rather than absorbed. That same exactness means fixing one leaves the baseline describing a state that no longer exists. There is nothing to fix in the code; the baselines just need to catch up. - - Remove the stale entries, and commit the result: - - ```bash - npm run typecheck:php:fix - ``` - - or, outside the Docker environment: - - ```bash - composer phpstan:fix - ``` - - That runs PHPStan with `--fix`, which lowers the counts in the files under [`tests/phpstan/baselines`][baselines], removes the entries that no longer match, and removes any `@phpstan-ignore` annotation in the code that no longer ignores anything. It then deletes any baseline left with no entries. - - Alternatively, regenerate the baselines with `npm run typecheck:php:baselines` or `composer phpstan:baselines`. That also deletes any baseline whose errors are now all fixed, but it does not clear an `@phpstan-ignore` annotation. - - See [`tests/phpstan/README.md`][readme] for details. - - SUMMARY - ) - - if [ "${ignore_errors}" -gt 0 ]; then - { - printf '%s\n\n' "${baselines_summary}" - echo "[baselines]: ${BASELINES_URL}" - echo "[readme]: ${README_URL}" - } >> "${GITHUB_STEP_SUMMARY}" - - echo "::error title=PHPStan baselines are out of date::An ignored error no longer occurs, or occurs a different number of times. If you fixed it, that is expected: run \`npm run typecheck:php:fix\` or \`composer phpstan:fix\` and commit the updated baselines. See ${README_URL}" - else - echo "::error title=PHPStan reported errors that cannot be ignored::PHPStan reported ${unignorable} error(s) that cannot be ignored or reported as warnings. See the error annotations for details, and ${README_URL} for how to run the analysis locally." - fi - - exit 1 - - - name: "Save result cache" - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 - if: ${{ !cancelled() }} - with: - path: .cache - key: "phpstan-analysis-cache-${{ hashFiles('phpstan.neon.dist', 'tests/phpstan/*.neon', 'tests/phpstan/*.php') }}-${{ github.run_id }}" - - - name: Ensure version-controlled files are not modified or deleted - run: git diff --exit-code diff --git a/.github/workflows/reusable-phpstan-static-analysis-v2.yml b/.github/workflows/reusable-phpstan-static-analysis-v2.yml deleted file mode 100644 index 2973de0ca40a2..0000000000000 --- a/.github/workflows/reusable-phpstan-static-analysis-v2.yml +++ /dev/null @@ -1,384 +0,0 @@ -## -# A reusable workflow that runs PHP Static Analysis tests. -# -# This workflow is used by `trunk` and branches >= 7.2. -## -name: PHP Static Analysis - -on: - workflow_call: - inputs: - php-version: - description: 'The PHP version to use.' - required: false - type: 'string' - default: 'latest' - -# Disable permissions for all available scopes by default. -# Any needed permissions should be configured at the job level. -permissions: {} - -jobs: - # Runs PHP static analysis tests. - # - # Core is analyzed twice, in parallel: the whole codebase with phpstan.neon.dist, and the paths held to a stricter rule - # level with phpstan-strict.neon.dist. See tests/phpstan/README.md. - # - # Violations are reported inline with annotations. For pull requests, the results of each analysis are also uploaded - # as an artifact, and the PHPStan Pull Request Comments workflow combines them in a comment. - # - # Performs the following steps: - # - Checks out the repository. - # - Sets up PHP. - # - Logs debug information. - # - Installs Composer dependencies. - # - Make Composer packages available globally. - # - Builds WordPress. - # - Configures caching for PHPStan static analysis scans. - # - Runs PHPStan static analysis. - # - Reports the results as annotations. - # - Uploads the results as an artifact (pull requests only). - # - Checks for errors that cannot be reported as warnings, such as out-of-date baselines. - # - Saves the PHPStan result cache. - # - Ensures version-controlled files are not modified or deleted. - phpstan: - name: Run PHP static analysis (${{ matrix.label }}) - runs-on: ubuntu-26.04 - permissions: - contents: read - timeout-minutes: 20 - strategy: - fail-fast: false - matrix: - include: - # The artifact of the analysis of the whole codebase keeps the name it had before there were two, which is - # the name the PHPStan Pull Request Comments workflow on trunk requires. That way the comment is kept up to - # date for a pull request whose branch does not have the second analysis yet. - # - # The analyses are named for their role rather than their rule level, which is read from the configuration - # when the results are reported, so that raising either level is an edit of its configuration alone. - - analysis: default - label: all paths - config: phpstan.neon.dist - baselines: tests/phpstan/baselines - script: phpstan:default - artifact: phpstan-results - - analysis: strict - label: strict paths - config: phpstan-strict.neon.dist - baselines: tests/phpstan/baselines-strict - script: phpstan:strict - artifact: phpstan-results-strict - - steps: - # For a pull request, the parents of the merge commit are fetched too, to find the files that the base branch - # has changed since the pull request branched from it. - - name: Checkout repository - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - persist-credentials: false - fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 1 }} - - - name: Set up PHP - uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2 - with: - php-version: ${{ inputs.php-version }} - coverage: none - - - name: General debug information - run: | - composer --version - - # Since Composer dependencies are installed using `composer update` and no lock file is in version control, - # passing a custom cache suffix ensures that the cache is flushed at least once per week. - - name: Install Composer dependencies - uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0 - with: - custom-cache-suffix: $(/bin/date -u --date='last Mon' "+%F") - - - name: Make Composer packages available globally - run: echo "${PWD}/vendor/bin" >> "$GITHUB_PATH" - - # The directory holds more than the analysis results. PHPStan also stores what it read out of - # each source file there, the docblocks and signatures it found, keyed by that file's contents - # and nothing else. The extensions in `tests/phpstan` change what reading a file yields without - # changing the file: a parser node visitor rewrites a docblock in the syntax tree, and the bytes - # on disk stay as they were. A cache written before one of them changed therefore answers with - # what the old code saw, and the analysis silently runs against types no longer derived. - # - # Keying on the configuration and the extensions keeps a run from restoring a cache that - # predates either. The baselines are left out of the key: they only decide which reported errors - # are ignored, PHPStan invalidates the results cache on a configuration change by itself, and - # including them would discard the whole cache every time one is regenerated. - # - # The cache is renamed rather than only prefixed, because the key this replaces restored on - # `phpstan-result-cache-`, which every key below still begins with. A branch that has not - # merged this commit yet runs the workflow it has, and that workflow would prefix-match the - # caches written here: it would analyse without the extensions against reflection derived with - # them. A name of its own leaves those runs restoring only their own caches. - # - # Each analysis caches separately. Its result cache records the rule level, and is discarded - # by a run at another level, so restoring the other analysis's cache would gain nothing. - - name: Cache PHP Static Analysis scan cache - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 - with: - path: .cache # This is defined in the base.neon file. - key: "phpstan-analysis-cache-${{ matrix.analysis }}-${{ hashFiles('phpstan.neon.dist', 'phpstan-strict.neon.dist', 'tests/phpstan/*.neon', 'tests/phpstan/*.php') }}-${{ github.run_id }}" - restore-keys: | - phpstan-analysis-cache-${{ matrix.analysis }}-${{ hashFiles('phpstan.neon.dist', 'phpstan-strict.neon.dist', 'tests/phpstan/*.neon', 'tests/phpstan/*.php') }}- - - - name: Run PHP static analysis tests - id: phpstan - env: - SCRIPT: ${{ matrix.script }} - run: | - # The report is written to a file for the steps below, which turn it into annotations, - # the pull request comment, and a check for errors that cannot be reported as warnings. - # Only the report goes to standard output; the debug output goes to standard error, so - # it stays in the log without corrupting the JSON. - # - # The step shell exits on the first failing command, which would also end the step on - # the status of 1 that PHPStan uses for reporting errors. Capture the status instead. - status=0 - composer run "${SCRIPT}" -- -vvv --error-format=json > "${RUNNER_TEMP}/phpstan-report.json" || status=$? - - # PHPStan exits 1 when it has errors to report, which is the expected case here and - # is what the annotations are for. Anything higher means it did not finish at all. - if [ "${status}" -gt 1 ]; then - echo "::error title=PHPStan did not complete::The analysis exited with status ${status}, so the code was not fully checked. This is a failure of the run itself rather than a problem found in the code." - exit "${status}" - fi - - # Errors are annotated as warnings, so that they are visible on the pull request without - # failing the run. The exception is an error that PHPStan does not allow to be ignored, - # such as an out-of-date baseline entry, or one that is not specific to a file. These are - # annotated as errors instead, and the run fails on them in the check further below. - # - # The results are also written out for the PHPStan Pull Request Comments workflow, which - # runs with the permissions needed to comment on the pull request. Only the facts are - # passed along: the comment is composed there, since a pull request can change anything - # that runs here. - - name: Report the analysis results - id: report - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 - env: - ANALYSIS: ${{ matrix.analysis }} - CONFIG: ${{ matrix.config }} - with: - script: | - const fs = require( 'fs' ); - - // The rule level the configuration analyzes at, as a number, or `max`. Only the line of the parameter is - // matched, rather than decoding the whole dump, because the JSON PHPStan prints can be invalid: it writes - // the `\<` in a message pattern as is, which is not a valid JSON escape. - let level = null; - try { - const parameters = require( 'child_process' ).execFileSync( - `${ process.env.GITHUB_WORKSPACE }/vendor/bin/phpstan`, - [ 'dump-parameters', `--configuration=${ process.env.CONFIG }`, '--json' ], - { encoding: 'utf8' } - ); - const match = parameters.match( /^\s*"level":\s*"?(max|\d+)"?,?$/m ); - if ( match ) { - level = match[ 1 ] === 'max' ? 'max' : Number( match[ 1 ] ); - } - } catch ( error ) { - core.warning( `The rule level of ${ process.env.CONFIG } could not be read: ${ error.message }` ); - } - - // Annotations from the stricter analysis say so, since the same code can pass the other one. - const analysis = process.env.ANALYSIS; - const titlePrefix = analysis === 'strict' ? `PHPStan (strict${ level === null ? '' : `, level ${ level }` })` : 'PHPStan'; - - const report = JSON.parse( fs.readFileSync( `${ process.env.RUNNER_TEMP }/phpstan-report.json`, { encoding: 'utf8' } ) ); - const workspace = `${ process.env.GITHUB_WORKSPACE }/`; - - const errors = []; - for ( const [ absolutePath, file ] of Object.entries( report.files ) ) { - const relativePath = absolutePath.startsWith( workspace ) ? absolutePath.slice( workspace.length ) : absolutePath; - for ( const message of file.messages ) { - errors.push( { - file: relativePath, - line: message.line ?? null, - message: message.message, - identifier: message.identifier ?? null, - tip: message.tip ?? null, - ignorable: message.ignorable, - fixable: message.fixable ?? false, - } ); - } - } - - // Errors that are not specific to a file, such as an `ignoreErrors` entry from a config - // file PHPStan cannot locate it in. These cannot be ignored either. - for ( const message of report.errors ) { - errors.push( { file: null, line: null, message, identifier: null, tip: null, ignorable: false, fixable: false } ); - } - - // PHPStan marks an error it can fix itself, such as a stale baseline entry, as fixable. - const fixHint = 'This can be fixed automatically by running `composer phpstan:fix` (or `npm run typecheck:php:fix`).'; - - for ( const error of errors ) { - const properties = { title: error.identifier ? `${ titlePrefix }: ${ error.identifier }` : titlePrefix }; - if ( error.file ) { - properties.file = error.file; - } - if ( error.line ) { - properties.startLine = error.line; - } - const message = [ error.message, error.tip, error.fixable ? fixHint : null ].filter( Boolean ).join( '\n' ); - if ( error.ignorable ) { - core.warning( message, properties ); - } else { - core.error( message, properties ); - } - } - - // Tips and whether an error is fixable are left out of the results, since they are only shown in the - // annotations, next to the code. - // - // The commit analyzed is the pull request merged into its base branch, whose second parent is the head - // commit. The files with errors that differ between the two are those the base branch has changed, in - // which the line numbers reported can be off in the head commit. - // - // Each analysis writes its own results. Those of the analysis of the whole codebase also list every - // analysis the run makes, so that the comment is not updated from only some of them: an error missing - // because its analysis did not upload results would otherwise be shown as resolved. - if ( context.eventName === 'pull_request' ) { - let changedInBase = []; - try { - const filesWithErrors = new Set( errors.map( ( error ) => error.file ) ); - changedInBase = require( 'child_process' ) - .execFileSync( 'git', [ 'diff', '--name-only', '--no-renames', 'HEAD^2', 'HEAD' ], { encoding: 'utf8' } ) - .split( '\n' ) - .filter( ( file ) => filesWithErrors.has( file ) ); - } catch ( error ) { - core.warning( `The files changed in the base branch could not be found: ${ error.message }` ); - } - fs.mkdirSync( `${ process.env.RUNNER_TEMP }/phpstan-results`, { recursive: true } ); - fs.writeFileSync( `${ process.env.RUNNER_TEMP }/phpstan-results/results.json`, JSON.stringify( { - pull_request: context.payload.pull_request.number, - analysis, - level, - // Keep this list in step with the `analysis` values of the job's matrix. - ...( analysis === 'default' ? { analyses: [ 'default', 'strict' ] } : {} ), - changed_in_base: changedInBase, - errors: errors.map( ( { tip, fixable, ...error } ) => error ), - } ) ); - } - - # Uploads the results for the PHPStan Pull Request Comments workflow, which keeps a comment on the - # pull request up to date with them. - - name: Upload the analysis results as an artifact - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 - if: ${{ github.event_name == 'pull_request' && steps.report.outcome == 'success' }} - with: - name: ${{ matrix.artifact }} - path: ${{ runner.temp }}/phpstan-results/ - - # Some errors cannot be ignored, so they cannot be reported as warnings either. Most often - # this is an ignored error that no longer occurs, or occurs a different number of times, - # which is reported under an `ignore.*` identifier. That is not something to fix in the - # code: the usual cause is that the error *was* fixed, leaving a baseline describing a state - # that no longer exists. - # - # Such an error is reported without a line number, so its annotation is not shown alongside - # the changes in the pull request, and one that is not specific to a file has nowhere to be - # shown at all. A passing run would let it go unnoticed, so fail the run on it instead, and - # say what to do about it. - # - # Detection is on PHPStan's own `ignorable` flag rather than on the identifier or message. - - name: Check for errors that cannot be reported as warnings - if: ${{ !cancelled() }} - env: - BASELINES_URL: ${{ github.server_url }}/${{ github.repository }}/tree/${{ github.sha }}/${{ matrix.baselines }} - LABEL: ${{ matrix.label }} - README_URL: ${{ github.server_url }}/${{ github.repository }}/blob/${{ github.sha }}/tests/phpstan/README.md - run: | - # This step runs even when the analysis above it failed, in which case the report may - # never have been written. That failure is reported there, so there is nothing to add - # here beyond staying quiet about a file that was never going to exist. - report="${RUNNER_TEMP}/phpstan-report.json" - if [ ! -f "${report}" ]; then - exit 0 - fi - - # Errors that are not specific to a file are listed separately from the rest, and are - # never ignorable. - unignorable=$( jq '[ .files[].messages[] | select( .ignorable | not ) ] + .errors | length' "${report}" ) - if [ "${unignorable}" -eq 0 ]; then - exit 0 - fi - - # Whether the errors include ignore errors decides what to say about them, but not whether to - # fail: every error that reaches this point fails the run. Ignore errors concern an ignore - # configuration that no longer describes the code. They are `ignore.unmatched`, where a - # pattern matched nothing at all, and `ignore.count`, where it matched a different number of - # times than the entry records. The `ignore.` prefix is matched rather than those two names - # so that any later addition to the group is caught as well. Any other error that cannot be - # ignored is something regenerating the baselines would not help with, so it is reported - # plainly instead. - ignore_errors=$( jq '[ .files[].messages[] | select( .identifier // "" | startswith( "ignore." ) ) ] | length' "${report}" ) - - # The summary is Markdown, and its code spans and fences are written literally, so the - # heredoc is quoted to keep the backticks out of the shell's hands. The links are - # written in reference style for the same reason: the URLs are the only part needing - # a variable, so defining them afterwards keeps the whole of the prose in here. - # - # A newline renders as a line break rather than a space, so each paragraph is one - # line however long that makes it, and the rendered summary wraps to its own width. - # - # The heading names the analysis whose baselines are out of date, which is filled in for - # the LABEL placeholder when the summary is written, since the heredoc expands nothing. - baselines_summary=$( cat <<'SUMMARY' - ## PHPStan baselines are out of date (LABEL) - - An ignored error no longer occurs, or occurs a different number of times, so PHPStan reported it under an `ignore.unmatched` or `ignore.count` identifier. - - **If you fixed the error, this is expected.** Each baseline entry records an exact count for a specific file, so that a new occurrence of an already baselined error is reported rather than absorbed. That same exactness means fixing one leaves the baseline describing a state that no longer exists. There is nothing to fix in the code; the baselines just need to catch up. - - Remove the stale entries, and commit the result: - - ```bash - npm run typecheck:php:fix - ``` - - or, outside the Docker environment: - - ```bash - composer phpstan:fix - ``` - - That runs PHPStan with `--fix`, which lowers the counts in [the baselines][baselines], removes the entries that no longer match, and removes any `@phpstan-ignore` annotation in the code that no longer ignores anything. It then deletes any baseline left with no entries. - - Alternatively, regenerate the baselines with `npm run typecheck:php:baselines` or `composer phpstan:baselines`. That also deletes any baseline whose errors are now all fixed, but it does not clear an `@phpstan-ignore` annotation. - - See [`tests/phpstan/README.md`][readme] for details. - - SUMMARY - ) - - if [ "${ignore_errors}" -gt 0 ]; then - { - printf '%s\n\n' "${baselines_summary/LABEL/${LABEL}}" - echo "[baselines]: ${BASELINES_URL}" - echo "[readme]: ${README_URL}" - } >> "${GITHUB_STEP_SUMMARY}" - - echo "::error title=PHPStan baselines are out of date (${LABEL})::An ignored error no longer occurs, or occurs a different number of times. If you fixed it, that is expected: run \`npm run typecheck:php:fix\` or \`composer phpstan:fix\` and commit the updated baselines. See ${README_URL}" - else - echo "::error title=PHPStan reported errors that cannot be ignored (${LABEL})::PHPStan reported ${unignorable} error(s) that cannot be ignored or reported as warnings. See the error annotations for details, and ${README_URL} for how to run the analysis locally." - fi - - exit 1 - - - name: "Save result cache" - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 - if: ${{ !cancelled() }} - with: - path: .cache - key: "phpstan-analysis-cache-${{ matrix.analysis }}-${{ hashFiles('phpstan.neon.dist', 'phpstan-strict.neon.dist', 'tests/phpstan/*.neon', 'tests/phpstan/*.php') }}-${{ github.run_id }}" - - - name: Ensure version-controlled files are not modified or deleted - run: git diff --exit-code diff --git a/.github/workflows/reusable-phpunit-tests-v1.yml b/.github/workflows/reusable-phpunit-tests-v1.yml deleted file mode 100644 index a631b243cd3a9..0000000000000 --- a/.github/workflows/reusable-phpunit-tests-v1.yml +++ /dev/null @@ -1,250 +0,0 @@ -## -# DEPRECATED -# -# A reusable workflow that runs the PHPUnit test suite with the specified configuration. -# -# This workflow is used by branches 4.7 through 5.1. -## -name: Run PHPUnit tests - -on: - workflow_call: - inputs: - os: - description: 'Operating system to run tests on' - required: false - type: 'string' - default: 'ubuntu-26.04' - repository: - description: 'The repository to check out and test. Defaults to the repository calling this workflow.' - required: false - type: 'string' - default: '' - ref: - description: 'The branch, tag, or SHA to check out. Defaults to the ref that triggered the calling workflow.' - required: false - type: 'string' - default: '' - php: - description: 'The version of PHP to use, in the format of X.Y' - required: true - type: 'string' - phpunit: - description: 'The PHPUnit version to use when running tests. See .env for details about valid values.' - required: false - type: 'string' - default: ${{ inputs.php }}-fpm - multisite: - description: 'Whether to run tests as multisite' - required: false - type: 'boolean' - default: false - split_slow: - description: 'Whether to run slow tests group.' - required: false - type: 'boolean' - default: false - memcached: - description: 'Whether to test with memcached enabled' - required: false - type: 'boolean' - default: false - phpunit-config: - description: 'The PHPUnit configuration file to use' - required: false - type: 'string' - default: 'phpunit.xml.dist' - phpunit-test-groups: - description: 'A list of test groups to run.' - required: false - type: 'string' - default: '' - allow-errors: - description: 'Whether to continue when test errors occur.' - required: false - type: boolean - default: false - overlay-artifact: - description: 'The name of a same-workflow artifact whose contents are unpacked over the checkout. Optional: for callers whose test files are not part of the repository being tested.' - required: false - type: string - default: '' -env: - COMPOSER_INSTALL: false - LOCAL_PHP: ${{ inputs.php }}-fpm - LOCAL_PHPUNIT: ${{ inputs.phpunit && inputs.phpunit || inputs.php }}-fpm - LOCAL_PHP_MEMCACHED: ${{ inputs.memcached }} - PHPUNIT_CONFIG: ${{ inputs.phpunit-config }} - PHPUNIT_SCRIPT: php - PUPPETEER_SKIP_DOWNLOAD: true - SLOW_TESTS: 'external-http,media' - -# Disable permissions for all available scopes by default. -# Any needed permissions should be configured at the job level. -permissions: {} - -jobs: - # Runs the PHPUnit tests for WordPress. - # - # Performs the following steps: - # - Sets environment variables. - # - Sets up the environment variables needed for testing with memcached (if desired). - # - Installs NodeJS. - # - Build WordPress - # _ Installs npm dependencies. - # - Configures caching for Composer. - # _ Installs Composer dependencies (if desired). - # - Logs Docker debug information (about the Docker installation within the runner). - # - Starts the WordPress Docker container. - # - Starts the Memcached server after the Docker network has been created (if desired). - # - Logs general debug information about the runner. - # - Logs the running Docker containers. - # - Logs debug information from inside the WordPress Docker container. - # - Logs debug information about what's installed within the WordPress Docker containers. - # - Install WordPress within the Docker container. - # - Run the PHPUnit tests. - test-php: - name: PHP ${{ inputs.php }} / ${{ inputs.multisite && ' Multisite' || 'Single site' }}${{ inputs.split_slow && ' slow tests' || '' }}${{ inputs.memcached && ' with memcached' || '' }} - runs-on: ${{ vars.RUNNERS_NAME || inputs.os }} - timeout-minutes: 20 - permissions: - contents: read - - steps: - # `ref` otherwise falls back to checkout's own default, which for another repository is - # its default branch: a "WordPress 6.2" job would test trunk and report green. - - name: Require a ref when testing another repository - if: ${{ inputs.repository != '' && inputs.ref == '' }} - run: | - echo 'Testing another repository needs an explicit ref.' >&2 - exit 1 - - # Legacy docker.js reparses arguments as shell: allow only group names. - - name: Validate test groups - if: ${{ inputs.phpunit-test-groups != '' }} - env: - TEST_GROUPS: ${{ inputs.phpunit-test-groups }} - run: | - if [[ ! "$TEST_GROUPS" =~ ^[A-Za-z0-9_.-]+(,[A-Za-z0-9_.-]+)*$ ]]; then - echo 'phpunit-test-groups must be a comma-separated list of group names.' >&2 - exit 1 - fi - - - name: Configure environment variables - run: | - echo "PHP_FPM_UID=$(id -u)" >> "$GITHUB_ENV" - echo "PHP_FPM_GID=$(id -g)" >> "$GITHUB_ENV" - - - name: Checkout repository - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - repository: ${{ inputs.repository || github.repository }} - ref: ${{ inputs.ref }} - show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - persist-credentials: false - - # If the caller specifies an overlay artifact then unpack it over the checkout. - - name: Download overlay artifact - if: inputs.overlay-artifact != '' - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 - with: - # Without a run ID, this action reads only from the caller's current workflow run. - name: ${{ inputs.overlay-artifact }} - path: . - digest-mismatch: error - - - name: Set up Node.js - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 - with: - node-version-file: '.nvmrc' - cache: npm - - - name: Install Dependencies - run: npm ci - - - name: Build WordPress - run: npm run build - - - name: Get composer cache directory - if: ${{ env.COMPOSER_INSTALL == true }} - id: composer-cache - run: echo "composer_dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT" - - - name: Cache Composer dependencies - if: ${{ env.COMPOSER_INSTALL == true }} - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 - env: - cache-name: cache-composer-dependencies - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-php-${{ inputs.php }}-composer-${{ hashFiles('**/composer.lock') }} - - - name: Install Composer dependencies - if: ${{ env.COMPOSER_INSTALL == true }} - run: | - docker compose run --rm php composer --version - docker compose run --rm php composer install - - - name: Docker debug information - run: | - docker -v - docker compose -v - - - name: Start Docker environment - run: | - npm run env:start - - # The memcached server needs to start after the Docker network has been set up with `npm run env:start`. - - name: Start the Memcached server. - if: ${{ inputs.memcached }} - run: | - cp tests/phpunit/includes/object-cache.php build/wp-content/object-cache.php - BASE=$(basename "$PWD") - docker run --name memcached --net "${BASE}_wpdevnet" -d memcached - - - name: General debug information - run: | - npm --version - node --version - curl --version - git --version - - - name: Log running Docker containers - run: docker ps -a - - - name: WordPress Docker container debug information - run: | - docker compose run --rm mysql mysql --version - docker compose run --rm php php --version - docker compose run --rm php php -m - docker compose run --rm php php -i - docker compose run --rm php locale -a - - - name: Install WordPress - run: npm run env:install - - - name: Run slow PHPUnit tests - if: ${{ inputs.split_slow && ! inputs.phpunit-test-groups }} - run: npm run "test:${PHPUNIT_SCRIPT}" -- --verbose -c "${PHPUNIT_CONFIG}" --group "${SLOW_TESTS}" - - - name: Run PHPUnit tests for single site excluding slow tests - if: ${{ inputs.php < '7.0' && ! inputs.split_slow && ! inputs.multisite && ! inputs.phpunit-test-groups }} - run: npm run "test:${PHPUNIT_SCRIPT}" -- --verbose -c "${PHPUNIT_CONFIG}" --exclude-group "${SLOW_TESTS},ajax,ms-files,ms-required" - - - name: Run PHPUnit tests for Multisite excluding slow tests - if: ${{ inputs.php < '7.0' && ! inputs.split_slow && inputs.multisite && ! inputs.phpunit-test-groups }} - run: npm run "test:${PHPUNIT_SCRIPT}" -- --verbose -c "${PHPUNIT_CONFIG}" --exclude-group "${SLOW_TESTS},ajax,ms-files,ms-excluded,oembed-headers" - - - name: Run PHPUnit tests - if: ${{ inputs.php >= '7.0' || inputs.phpunit-test-groups }} - run: npm run "test:${PHPUNIT_SCRIPT}" -- --verbose -c "${PHPUNIT_CONFIG}" ${{ inputs.phpunit-test-groups && '--group "${TEST_GROUPS}"' || '' }} - env: - TEST_GROUPS: ${{ inputs.phpunit-test-groups }} - - - name: Run AJAX tests - if: ${{ ! inputs.multisite && ! inputs.split_slow && ! inputs.phpunit-test-groups }} - run: npm run "test:${PHPUNIT_SCRIPT}" -- --verbose -c "${PHPUNIT_CONFIG}" --group ajax - - - name: Run external HTTP tests - if: ${{ ! inputs.multisite && ! inputs.split_slow && ! inputs.phpunit-test-groups }} - run: npm run "test:${PHPUNIT_SCRIPT}" -- --verbose -c phpunit.xml.dist --group external-http diff --git a/.github/workflows/reusable-phpunit-tests-v2.yml b/.github/workflows/reusable-phpunit-tests-v2.yml deleted file mode 100644 index 139c41efccf8c..0000000000000 --- a/.github/workflows/reusable-phpunit-tests-v2.yml +++ /dev/null @@ -1,265 +0,0 @@ -## -# DEPRECATED -# -# A reusable workflow that runs the PHPUnit test suite with the specified configuration. -# -# This workflow is used by branches 5.2 through 5.8. -## -name: Run PHPUnit tests - -on: - workflow_call: - inputs: - os: - description: 'Operating system to run tests on' - required: false - type: 'string' - default: 'ubuntu-26.04' - repository: - description: 'The repository to check out and test. Defaults to the repository calling this workflow.' - required: false - type: 'string' - default: '' - ref: - description: 'The branch, tag, or SHA to check out. Defaults to the ref that triggered the calling workflow.' - required: false - type: 'string' - default: '' - php: - description: 'The version of PHP to use, in the format of X.Y' - required: true - type: 'string' - multisite: - description: 'Whether to run tests as multisite' - required: false - type: 'boolean' - default: false - split_slow: - description: 'Whether to run slow tests group.' - required: false - type: 'boolean' - default: false - test_ajax: - description: 'Whether to run AJAX tests.' - required: false - type: 'boolean' - default: true - memcached: - description: 'Whether to test with memcached enabled' - required: false - type: 'boolean' - default: false - phpunit-config: - description: 'The PHPUnit configuration file to use' - required: false - type: 'string' - default: 'phpunit.xml.dist' - phpunit-test-groups: - description: 'A list of test groups to run.' - required: false - type: 'string' - default: '' - report: - description: 'Whether to report results to WordPress.org Hosting Tests' - required: false - type: 'boolean' - default: false - allow-errors: - description: 'Whether to continue when test errors occur.' - required: false - type: boolean - default: false - overlay-artifact: - description: 'The name of a same-workflow artifact whose contents are unpacked over the checkout. Optional: for callers whose test files are not part of the repository being tested.' - required: false - type: string - default: '' -env: - LOCAL_PHP: ${{ inputs.php }}-fpm - LOCAL_PHP_MEMCACHED: ${{ inputs.memcached }} - PHPUNIT_CONFIG: ${{ inputs.phpunit-config }} - PUPPETEER_SKIP_DOWNLOAD: true - # Controls which npm script to use for running PHPUnit tests. Options ar `php` and `php-composer`. - PHPUNIT_SCRIPT: php - SLOW_TESTS: 'external-http,media' - -# Disable permissions for all available scopes by default. -# Any needed permissions should be configured at the job level. -permissions: {} - -jobs: - # Runs the PHPUnit tests for WordPress. - # - # Performs the following steps: - # - Sets environment variables. - # - Checks out the repository. - # - Installs Node.js. - # - Installs npm dependencies - # - Configures caching for Composer. - # - Installs Composer dependencies. - # - Logs Docker debug information (about the Docker installation within the runner). - # - Starts the WordPress Docker container. - # - Logs general debug information about the runner. - # - Logs the running Docker containers. - # - Logs debug information from inside the WordPress Docker container. - # - Install WordPress within the Docker container. - # - Run the PHPUnit tests. - # - Ensures version-controlled files are not modified or deleted. - test-php: - name: PHP ${{ inputs.php }} / ${{ inputs.multisite && ' Multisite' || 'Single Site' }}${{ inputs.split_slow && ' slow tests' || '' }}${{ inputs.memcached && ' with memcached' || '' }} - runs-on: ${{ vars.RUNNERS_NAME || inputs.os }} - timeout-minutes: 20 - permissions: - contents: read - - steps: - # `ref` otherwise falls back to checkout's own default, which for another repository is - # its default branch: a "WordPress 6.2" job would test trunk and report green. - - name: Require a ref when testing another repository - if: ${{ inputs.repository != '' && inputs.ref == '' }} - run: | - echo 'Testing another repository needs an explicit ref.' >&2 - exit 1 - - # Legacy docker.js reparses arguments as shell: allow only group names. - - name: Validate test groups - if: ${{ inputs.phpunit-test-groups != '' }} - env: - TEST_GROUPS: ${{ inputs.phpunit-test-groups }} - run: | - if [[ ! "$TEST_GROUPS" =~ ^[A-Za-z0-9_.-]+(,[A-Za-z0-9_.-]+)*$ ]]; then - echo 'phpunit-test-groups must be a comma-separated list of group names.' >&2 - exit 1 - fi - - - name: Configure environment variables - run: | - echo "PHP_FPM_UID=$(id -u)" >> "$GITHUB_ENV" - echo "PHP_FPM_GID=$(id -g)" >> "$GITHUB_ENV" - - - name: Checkout repository - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - repository: ${{ inputs.repository || github.repository }} - ref: ${{ inputs.ref }} - show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - persist-credentials: false - - # If the caller specifies an overlay artifact then unpack it over the checkout. - - name: Download overlay artifact - if: inputs.overlay-artifact != '' - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 - with: - # Without a run ID, this action reads only from the caller's current workflow run. - name: ${{ inputs.overlay-artifact }} - path: . - digest-mismatch: error - - - name: Install Node.js - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 - with: - node-version-file: '.nvmrc' - cache: npm - - - name: Install npm dependencies - run: npm ci - - - name: Get composer cache directory - id: composer-cache - run: echo "composer_dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT" - - - name: Cache Composer dependencies - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 - env: - cache-name: cache-composer-dependencies - with: - path: ${{ steps.composer-cache.outputs.composer_dir }} - key: ${{ runner.os }}-php-${{ inputs.php }}-composer-${{ hashFiles('**/composer.lock') }} - - - name: Install Composer dependencies - run: | - docker compose run --rm php composer --version - - # The PHPUnit 7.x phar is not compatible with PHP 8 and won't be updated, - # as PHPUnit 7 is no longer supported. The Composer-installed PHPUnit should be - # used for PHP 8 testing instead. - if [ "${LOCAL_PHP}" == '8.0-fpm' ]; then - docker compose run --rm php composer install --ignore-platform-reqs - echo "PHPUNIT_SCRIPT=php-composer" >> "$GITHUB_ENV" - elif [ "${LOCAL_PHP}" == '7.1-fpm' ]; then - docker compose run --rm php composer update - git checkout -- composer.lock - elif [[ "${LOCAL_PHP}" == '5.6-fpm' || "${LOCAL_PHP}" == '7.0-fpm' ]]; then - docker compose run --rm php composer require --dev phpunit/phpunit:"^5.7" --update-with-dependencies - git checkout -- composer.lock composer.json - else - docker compose run --rm php composer install - fi - - - name: Docker debug information - run: | - docker -v - docker compose -v - - - name: Start Docker environment - run: | - npm run env:start - - - name: General debug information - run: | - npm --version - node --version - curl --version - git --version - - - name: Log running Docker containers - run: docker ps -a - - - name: WordPress Docker container debug information - run: | - docker compose run --rm mysql mysql --version - docker compose run --rm php php --version - docker compose run --rm php php -m - docker compose run --rm php php -i - docker compose run --rm php locale -a - - - name: Install WordPress - run: npm run env:install - - - name: Run slow PHPUnit tests - if: ${{ inputs.split_slow && ! inputs.phpunit-test-groups }} - run: npm run "test:${PHPUNIT_SCRIPT}" -- --verbose -c "${PHPUNIT_CONFIG}" --group "${SLOW_TESTS}" - - - name: Run PHPUnit tests for single site excluding slow tests - if: ${{ inputs.php < '7.0' && ! inputs.split_slow && ! inputs.multisite && ! inputs.phpunit-test-groups }} - run: npm run "test:${PHPUNIT_SCRIPT}" -- --verbose -c "${PHPUNIT_CONFIG}" --exclude-group "${SLOW_TESTS},ajax,ms-files,ms-required" - - - name: Run PHPUnit tests for Multisite excluding slow tests - if: ${{ inputs.php < '7.0' && ! inputs.split_slow && inputs.multisite && ! inputs.phpunit-test-groups }} - run: npm run "test:${PHPUNIT_SCRIPT}" -- --verbose -c "${PHPUNIT_CONFIG}" --exclude-group "${SLOW_TESTS},ajax,ms-files,ms-excluded,oembed-headers" - - - name: Run PHPUnit tests - if: ${{ inputs.php >= '7.0' || inputs.phpunit-test-groups }} - run: npm run "test:${PHPUNIT_SCRIPT}" -- --verbose -c "${PHPUNIT_CONFIG}" ${{ inputs.phpunit-test-groups && '--group "${TEST_GROUPS}"' || '' }} - env: - TEST_GROUPS: ${{ inputs.phpunit-test-groups }} - - - name: Run AJAX tests - if: ${{ ! inputs.split_slow&& inputs.test_ajax && ! inputs.phpunit-test-groups }} - run: npm run "test:${PHPUNIT_SCRIPT}" -- --verbose -c "${PHPUNIT_CONFIG}" --group ajax - - - name: Run ms-files tests as a multisite install - if: ${{ inputs.multisite && ! inputs.split_slow && ! inputs.phpunit-test-groups }} - run: npm run "test:${PHPUNIT_SCRIPT}" -- --verbose -c "${PHPUNIT_CONFIG}" --group ms-files - - - name: Run external HTTP tests - if: ${{ ! inputs.multisite && ! inputs.split_slow && ! inputs.phpunit-test-groups }} - run: npm run "test:${PHPUNIT_SCRIPT}" -- --verbose -c phpunit.xml.dist --group external-http - - # __fakegroup__ is excluded to force PHPUnit to ignore the settings in phpunit.xml.dist. - - name: Run (xDebug) tests - if: ${{ ! inputs.split_slow && ! inputs.phpunit-test-groups }} - run: LOCAL_PHP_XDEBUG=true npm run "test:${PHPUNIT_SCRIPT}" -- -v --group xdebug --exclude-group __fakegroup__ - - - name: Ensure version-controlled files are not modified or deleted - run: git diff --exit-code diff --git a/.github/workflows/reusable-phpunit-tests-v3.yml b/.github/workflows/reusable-phpunit-tests-v3.yml deleted file mode 100644 index c025ea8d1f576..0000000000000 --- a/.github/workflows/reusable-phpunit-tests-v3.yml +++ /dev/null @@ -1,414 +0,0 @@ -## -# A reusable workflow that runs the PHPUnit test suite with the specified configuration. -# -# This workflow is used by `trunk` and branches >= 5.9. -## -name: Run PHPUnit tests - -on: - workflow_call: - inputs: - os: - description: 'Operating system to run tests on' - required: false - type: 'string' - default: 'ubuntu-26.04' - repository: - description: 'The repository to check out and test. Defaults to the repository calling this workflow.' - required: false - type: 'string' - default: '' - # Also composes the Gutenberg build name, under the producer's constraint: a valid - # artifact name, so no slashes and none of : < > | * ? " - ref: - description: 'The branch, tag, or SHA to check out. Defaults to the ref that triggered the calling workflow.' - required: false - type: 'string' - default: '' - php: - description: 'The version of PHP to use, in the format of X.Y' - required: true - type: 'string' - db-type: - description: 'Database type. Valid types are mysql and mariadb' - required: false - type: 'string' - default: 'mysql' - db-version: - description: 'Database version' - required: false - type: 'string' - default: '8.4' - db-innovation: - description: 'Whether a database software innovation release is being tested.' - required: false - type: 'boolean' - default: false - multisite: - description: 'Whether to run tests as multisite' - required: false - type: 'boolean' - default: false - memcached: - description: 'Whether to test with memcached enabled' - required: false - type: 'boolean' - default: false - phpunit-config: - description: 'The PHPUnit configuration file to use' - required: false - type: 'string' - default: 'phpunit.xml.dist' - phpunit-test-groups: - description: 'A list of test groups to run.' - required: false - type: 'string' - default: '' - tests-domain: - description: 'The domain to use for the tests' - required: false - type: 'string' - default: 'example.org' - coverage-report: - description: 'Whether to generate a code coverage report.' - required: false - type: boolean - default: false - report: - description: 'Whether to report results to WordPress.org Hosting Tests' - required: false - type: 'boolean' - default: false - allow-errors: - description: 'Whether to continue when test errors occur.' - required: false - type: boolean - default: false - gutenberg-artifact: - description: 'Whether the Gutenberg-sourced assets are sourced from zip artifact.' - required: false - type: boolean - default: false - gutenberg-sha: - description: 'The immutable Gutenberg source SHA verified by the calling workflow.' - required: false - type: string - default: '' - overlay-artifact: - description: 'The name of a same-workflow artifact whose contents are unpacked over the checkout. Optional: for callers whose test files are not part of the repository being tested.' - required: false - type: string - default: '' - secrets: - CODEVITALS_PROJECT_TOKEN: - description: 'The authorization token for publishing results to CodeVitals.' - required: false - CODECOV_TOKEN: - description: 'The Codecov token required for uploading reports.' - required: false - WPT_REPORT_API_KEY: - description: 'The WordPress.org Hosting Tests API key.' - required: false - -env: - LOCAL_PHP: ${{ inputs.php }}-fpm - LOCAL_PHP_XDEBUG: false - LOCAL_PHP_XDEBUG_MODE: 'develop,debug' - LOCAL_PHP_PCOV: ${{ inputs.coverage-report }} - LOCAL_DB_TYPE: ${{ inputs.db-type }} - LOCAL_DB_VERSION: ${{ inputs.db-version }} - LOCAL_PHP_MEMCACHED: ${{ inputs.memcached }} - LOCAL_WP_TESTS_DOMAIN: ${{ inputs.tests-domain }} - PHPUNIT_CONFIG: ${{ inputs.phpunit-config }} - PUPPETEER_SKIP_DOWNLOAD: true - -# Disable permissions for all available scopes by default. -# Any needed permissions should be configured at the job level. -permissions: {} - -jobs: - # Runs the PHPUnit tests for WordPress. - # - # Performs the following steps: - # - Requires a ref when the caller points at another repository. - # - Sets environment variables. - # - Checks out the repository. - # - Unpacks the caller-provided overlay artifact over the checkout, if any. - # - Downloads the prepared Gutenberg build provided by the calling workflow. - # - Sets up Node.js. - # - Sets up PHP. - # - Installs Composer dependencies. - # - Installs npm dependencies - # - Logs general debug information about the runner. - # - Logs Docker debug information (about the Docker installation within the runner). - # - Starts the WordPress Docker container. - # - Logs the running Docker containers. - # - Logs debug information about what's installed within the WordPress Docker containers. - # - Install WordPress within the Docker container. - # - Run the PHPUnit tests. - # - Flags slow PHPUnit tests with GitHub Actions annotations and a run summary. - # - Publish PHPUnit timing metrics to CodeVitals. - # - Upload the code coverage report to Codecov.io. - # - Ensures version-controlled files are not modified or deleted. - # - Checks out the WordPress Test reporter repository. - # - Submit the test results to the WordPress.org host test results. - phpunit-tests: - name: ${{ ( inputs.phpunit-test-groups || inputs.coverage-report ) && format( 'PHP {0} with ', inputs.php ) || '' }} ${{ 'mariadb' == inputs.db-type && 'MariaDB' || 'MySQL' }} ${{ inputs.db-version }}${{ inputs.multisite && ' multisite' || '' }}${{ inputs.db-innovation && ' (innovation release)' || '' }}${{ inputs.memcached && ' with memcached' || '' }}${{ inputs.report && ' (test reporting enabled)' || '' }} ${{ 'example.org' != inputs.tests-domain && inputs.tests-domain || '' }} - runs-on: ${{ vars.RUNNERS_NAME || inputs.os }} - timeout-minutes: ${{ inputs.coverage-report && 120 || 30 }} - permissions: - contents: read - - steps: - # `ref` otherwise falls back to checkout's own default, which for another repository is - # its default branch: a "WordPress 6.2" job would test trunk and report green. - - name: Require a ref when testing another repository - if: ${{ inputs.repository != '' && inputs.ref == '' }} - run: | - echo 'Testing another repository needs an explicit ref.' >&2 - exit 1 - - # `ref` also composes the Gutenberg artifact name, so reject what that name cannot carry - # here rather than at a download step the job only reaches minutes later. - - name: Require a ref the artifact name accepts - if: ${{ inputs.ref != '' }} - env: - REF: ${{ inputs.ref }} - run: | - invalid='[/:<>|*?"\]' - if [[ "$REF" =~ $invalid ]]; then - echo "A ref that names an artifact cannot contain / : < > | * ? \" \\ - received: $REF" >&2 - exit 1 - fi - - - name: Configure environment variables - run: | - echo "PHP_FPM_UID=$(id -u)" >> "$GITHUB_ENV" - echo "PHP_FPM_GID=$(id -g)" >> "$GITHUB_ENV" - - - name: Checkout repository - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - repository: ${{ inputs.repository || github.repository }} - ref: ${{ inputs.ref }} - show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - persist-credentials: false - - # If the caller specifies an overlay artifact then unpack it over the checkout. - - name: Download overlay artifact - if: inputs.overlay-artifact != '' - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 - with: - # Without a run ID, this action reads only from the caller's current workflow run. - name: ${{ inputs.overlay-artifact }} - path: . - digest-mismatch: error - - # Only WordPress 7.0+ include Gutenberg-maintained assets from a built zip file. - - name: Download prepared Gutenberg build - if: ${{ inputs.gutenberg-artifact }} - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 - with: - # Every branch in a run shares one artifact namespace, so the producer names each - # build after the ref it came from. Compose the same name here rather than taking - # it as an input: the two sides already agree on `ref`. - name: gutenberg-build${{ inputs.ref && format( '-{0}', inputs.ref ) || '' }} - path: gutenberg - digest-mismatch: error - - - name: Set up Node.js - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 - with: - node-version-file: '.nvmrc' - package-manager-cache: false - - - name: Set up npm - # Release branches run this workflow from trunk, but some older branches may lack the action. - if: ${{ hashFiles('.github/actions/setup-npm/action.yml') != '' }} - uses: ./.github/actions/setup-npm - - ## - # This allows Composer dependencies to be installed using a single step. - # - # Since the tests are currently run within the Docker containers where the PHP version varies, - # the same PHP version needs to be configured for the action runner machine so that the correct - # dependency versions are installed and cached. - ## - - name: Set up PHP - uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2 - with: - php-version: '${{ inputs.php }}' - coverage: none - - # Since Composer dependencies are installed using `composer update` and no lock file is in version control, - # passing a custom cache suffix ensures that the cache is flushed at least once per week. - - name: Install Composer dependencies - uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0 - with: - custom-cache-suffix: $(/bin/date -u --date='last Mon' "+%F") - - - name: Install npm dependencies - run: npm ci - - - name: Build WordPress - timeout-minutes: 5 - run: npm run build:dev - env: - # The producer resolved this once. Matrix jobs must not re-resolve mutable GHCR tags. - GUTENBERG_EXPECTED_SHA: ${{ inputs.gutenberg-sha }} - - - name: General debug information - run: | - npm --version - node --version - curl --version - git --version - composer --version - locale -a - - - name: Docker debug information - run: | - docker -v - - - name: Pull Docker images - run: npm run env:pull - - - name: Start Docker environment - run: | - npm run env:start - - - name: Log running Docker containers - run: docker ps -a - - - name: WordPress Docker container debug information - run: | - docker compose run --rm mysql "${LOCAL_DB_CMD}" --version - docker compose run --rm php php --version - docker compose run --rm php php -m - docker compose run --rm php php -i - docker compose run --rm php locale -a - env: - LOCAL_DB_CMD: ${{ env.LOCAL_DB_TYPE == 'mariadb' && contains( fromJSON('["5.5", "10.0", "10.1", "10.2", "10.3"]'), env.LOCAL_DB_VERSION ) && 'mysql' || env.LOCAL_DB_TYPE }} - - - name: Install WordPress - run: npm run env:install - - - name: Run external HTTP tests - if: ${{ ! inputs.multisite && ! inputs.phpunit-test-groups && ! inputs.coverage-report }} - continue-on-error: ${{ inputs.allow-errors }} - run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c "${PHPUNIT_CONFIG}" --group external-http - - # PHPUnit versions used below PHP 7.3 do not support --fail-on-empty-test-suite. - - name: Run PHPUnit tests${{ inputs.phpunit-test-groups && format( ' ({0} groups)', inputs.phpunit-test-groups ) || '' }}${{ inputs.coverage-report && ' with coverage report' || '' }} - continue-on-error: ${{ inputs.allow-errors }} - run: | - node ./tools/local-env/scripts/docker.js ${{ inputs.coverage-report && 'exec' || 'run' }} \ - php ./vendor/bin/phpunit \ - --verbose \ - -c "${PHPUNIT_CONFIG}" \ - ${{ inputs.phpunit-test-groups && '--group "${TEST_GROUPS}"' || '' }} \ - ${{ inputs.phpunit-test-groups && inputs.php >= '7.3' && '--fail-on-empty-test-suite' || '' }} \ - ${{ inputs.coverage-report && '--coverage-clover "wp-code-coverage-${MULTISITE_FLAG}-${GITHUB_SHA}.xml"' || '' }} - env: - TEST_GROUPS: ${{ inputs.phpunit-test-groups }} - MULTISITE_FLAG: ${{ inputs.multisite && 'multisite' || 'single' }} - - - name: Flag slow PHPUnit tests - # Runs when the test step succeeds or fails, but skips cancelled jobs. - # This step never fails the job itself (continue-on-error), because the - # slow-test signal is advisory only. - if: >- - ${{ - ! cancelled() && inputs.report && inputs.php == '8.5' && - ( github.event_name == 'pull_request' || - ( github.event_name == 'push' && github.ref == 'refs/heads/trunk' ) ) - }} - continue-on-error: true - run: | - if [ -f tests/phpunit/build/logs/junit.xml ]; then - php tests/phpunit/prepare-slow-test-annotations.php \ - tests/phpunit/build/logs/junit.xml \ - 1.0 \ - 20 \ - "$RUNNER_TEMP/phpunit-timing-metrics.json" - else - echo 'PHPUnit JUnit report not found; skipping slow-test annotations.' - fi - - - name: Publish PHPUnit timing metrics - continue-on-error: true - if: | - github.event_name == 'push' && - github.ref == 'refs/heads/trunk' && - inputs.php == '8.5' && - inputs.report - env: - CODEVITALS_PROJECT_TOKEN: ${{ secrets.CODEVITALS_PROJECT_TOKEN }} - shell: bash - run: | - if [ -z "$CODEVITALS_PROJECT_TOKEN" ]; then - echo "PHPUnit timing metrics could not be published. 'CODEVITALS_PROJECT_TOKEN' is not set" - exit 1 - fi - COMMITTED_AT="$(git show -s "$GITHUB_SHA" --format='%cI')" - RESPONSE="$( - php tests/phpunit/prepare-timing-results.php \ - tests/phpunit/build/logs/junit.xml \ - trunk \ - "$GITHUB_SHA" \ - "$COMMITTED_AT" \ - "$RUNNER_TEMP/phpunit-timing-metrics.json" \ - | curl --fail-with-body --silent --show-error \ - --request POST \ - --header 'Content-Type: application/json' \ - --data-binary @- \ - "https://codevitals.run/api/log?token=${CODEVITALS_PROJECT_TOKEN}" - )" - if ! php -r "\$d = json_decode(file_get_contents('php://stdin'), true); exit(is_array(\$d) && (\$d['status'] ?? null) === 'ok' && (int) (\$d['count'] ?? 0) === 6 ? 0 : 1);" <<< "$RESPONSE"; then - echo 'CodeVitals did not accept all six PHPUnit timing metrics.' - exit 1 - fi - echo 'Published six PHPUnit timing metrics to CodeVitals.' - - - name: Run AJAX tests - if: ${{ ! inputs.phpunit-test-groups && ! inputs.coverage-report }} - continue-on-error: ${{ inputs.allow-errors }} - run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c "${PHPUNIT_CONFIG}" --group ajax - - - name: Run ms-files tests as a multisite install - if: ${{ inputs.multisite && ! inputs.phpunit-test-groups && ! inputs.coverage-report }} - continue-on-error: ${{ inputs.allow-errors }} - run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c "${PHPUNIT_CONFIG}" --group ms-files - - # __fakegroup__ is excluded to force PHPUnit to ignore the settings in phpunit.xml.dist. - - name: Run (Xdebug) tests - if: ${{ ! inputs.phpunit-test-groups && ! inputs.coverage-report }} - continue-on-error: ${{ inputs.allow-errors }} - run: LOCAL_PHP_XDEBUG=true node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit -v --group xdebug --exclude-group __fakegroup__ - - - name: Upload test coverage report to Codecov - if: ${{ inputs.coverage-report }} - uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0 - with: - token: ${{ secrets.CODECOV_TOKEN }} - files: wp-code-coverage${{ inputs.multisite && '-multisite' || '-single' }}-${{ github.sha }}.xml - flags: ${{ inputs.multisite && 'multisite' || 'single' }},php - fail_ci_if_error: true - - - name: Ensure version-controlled files are not modified or deleted - run: git diff --exit-code - - - name: Checkout the WordPress Test Reporter - if: ${{ github.ref == 'refs/heads/trunk' && inputs.report }} - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - repository: 'WordPress/phpunit-test-runner' - path: 'test-runner' - show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - persist-credentials: false - - - name: Submit test results to the WordPress.org host test results - if: ${{ github.ref == 'refs/heads/trunk' && inputs.report }} - env: - WPT_REPORT_API_KEY: "${{ secrets.WPT_REPORT_API_KEY }}" - run: docker compose run --rm -e WPT_REPORT_API_KEY -e WPT_PREPARE_DIR=/var/www -e WPT_TEST_DIR=/var/www -e WPT_DB_HOST=mysql -e WPT_DB_USER=root -e WPT_DB_PASSWORD=password -e WPT_DB_NAME=wordpress_develop_tests php php test-runner/report.php diff --git a/.github/workflows/reusable-prepare-gutenberg.yml b/.github/workflows/reusable-prepare-gutenberg.yml deleted file mode 100644 index 285c2b135788e..0000000000000 --- a/.github/workflows/reusable-prepare-gutenberg.yml +++ /dev/null @@ -1,110 +0,0 @@ -## -# A reusable workflow that downloads and verifies the Gutenberg build once per -# calling workflow run. -## -name: Prepare Gutenberg build - -on: - workflow_call: - inputs: - repository: - description: 'The repository to check out. Defaults to the repository calling this workflow.' - required: false - type: 'string' - default: '' - # Names the uploaded build too, so it must also be a valid artifact name: no slashes, - # and none of : < > | * ? " — a `refs/heads/trunk` or `feature/x` value fails the upload. - ref: - description: 'The branch, tag, or SHA to check out. Defaults to the commit that started the calling workflow run.' - required: false - type: 'string' - default: '' - outputs: - gutenberg-sha: - description: 'The immutable Gutenberg source SHA verified by this workflow.' - value: ${{ jobs.prepare-gutenberg.outputs.gutenberg-sha }} - -# Disable permissions for all available scopes by default. -# Any needed permissions should be configured at the job level. -permissions: {} - -jobs: - prepare-gutenberg: - name: Gutenberg - runs-on: ubuntu-26.04 - # Two download attempts of up to six minutes each, where download.js retries internally. - timeout-minutes: 15 - outputs: - gutenberg-sha: ${{ steps.download.outputs.gutenberg-sha }} - permissions: - contents: read - - steps: - # `ref` otherwise falls back to this run's commit, which another repository does not have. - - name: Require a ref when preparing another repository - if: ${{ inputs.repository != '' && inputs.ref == '' }} - run: | - echo 'Preparing another repository needs an explicit ref.' >&2 - exit 1 - - # The upload names the artifact after `ref` and is this job's last step, so an unusable - # value would otherwise fail only once the whole download and verify has already run. - - name: Require a ref the artifact name accepts - if: ${{ inputs.ref != '' }} - env: - REF: ${{ inputs.ref }} - run: | - invalid='[/:<>|*?"\]' - if [[ "$REF" =~ $invalid ]]; then - echo "A ref that names an artifact cannot contain / : < > | * ? \" \\ - received: $REF" >&2 - exit 1 - fi - - - name: Checkout repository - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - repository: ${{ inputs.repository || github.repository }} - # Resolve the Gutenberg ref from the exact commit that started this workflow run, - # unless the caller is preparing a build for a repository or branch of its own. - ref: ${{ inputs.ref || github.sha }} - show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - persist-credentials: false - - - name: Set up Node.js - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 - with: - node-version-file: '.nvmrc' - package-manager-cache: false - - - name: Download and verify Gutenberg build - id: download - run: | - # Branches whose download.js predates the in-script retry stream the blob straight - # into tar in a single attempt, so an interrupted stream fails the run outright. - # One retry, not two: where download.js does retry, it already allows three tries of - # two minutes each, and a third attempt here would outrun `timeout-minutes` and have - # the job killed rather than reported. - if ! node tools/gutenberg/download.js; then - echo 'Gutenberg download failed; retrying in 5 seconds...' - sleep 5 - node tools/gutenberg/download.js - fi - - gutenberg_sha="$(tr -d '\n' < gutenberg/.gutenberg-hash)" - if [[ ! "$gutenberg_sha" =~ ^[a-fA-F0-9]{40}$ ]]; then - echo "Expected a 40-character Gutenberg SHA, received: $gutenberg_sha" >&2 - exit 1 - fi - echo "gutenberg-sha=$gutenberg_sha" >> "$GITHUB_OUTPUT" - - - name: Upload Gutenberg build - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 - with: - # Every branch in a run shares one artifact namespace, so name the build after the - # ref it came from. The PHPUnit consumer composes the same name from its own `ref`, - # so the name is never passed between them. - name: gutenberg-build${{ inputs.ref && format( '-{0}', inputs.ref ) || '' }} - path: gutenberg/ - if-no-files-found: error - include-hidden-files: true - retention-days: 7 diff --git a/.github/workflows/reusable-support-json-reader-v1.yml b/.github/workflows/reusable-support-json-reader-v1.yml deleted file mode 100644 index 00bdb0de3a865..0000000000000 --- a/.github/workflows/reusable-support-json-reader-v1.yml +++ /dev/null @@ -1,157 +0,0 @@ -## -# A reusable workflow that reads the .version-support-*.json files and returns values for use in a -# test matrix based on a given WordPress version. -# -# This workflow is used by `trunk` and branches >= 6.8. -## -name: Determine test matrix values - -on: - workflow_call: - inputs: - wp-version: - description: 'The WordPress version to test . Accepts major and minor versions, "latest", or "nightly". Major releases must not end with ".0".' - type: string - default: 'nightly' - repository: - description: 'The repository to read support JSON files from.' - type: string - default: 'WordPress/wordpress-develop' - outputs: - major-wp-version: - description: "The major WordPress version based on the version provided in wp-version" - value: ${{ jobs.major-wp-version.outputs.version }} - php-versions: - description: "The PHP versions to test for the given wp-version" - value: ${{ jobs.php-versions.outputs.versions }} - mysql-versions: - description: "The MySQL versions to test for the given wp-version" - value: ${{ jobs.mysql-versions.outputs.versions }} - -# Disable permissions for all available scopes by default. -# Any needed permissions should be configured at the job level. -permissions: {} - -jobs: - # Determines the major version of WordPress being tested. - # - # The data in the JSON files are indexed by major version, so this is used to look up the appropriate support policy. - # - # Performs the following steps: - # - Checks out the repository - # - Returns the major WordPress version as an output based on the value passed to the wp-version input. - major-wp-version: - name: Determine major WordPress version - permissions: - contents: read - runs-on: ubuntu-26.04 - timeout-minutes: 5 - outputs: - version: ${{ steps.major-wp-version.outputs.version }} - - steps: - - name: Checkout repository - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - repository: ${{ inputs.repository }} - show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - persist-credentials: false - - - name: Determine the major WordPress version - id: major-wp-version - run: | - if [ "${WP_VERSION}" ] && [ "${WP_VERSION}" != "nightly" ] && [ "${WP_VERSION}" != "latest" ] && [ "${WP_VERSION}" != "trunk" ]; then - echo "version=$(echo "${WP_VERSION}" | tr '.' '-' | cut -d '-' -f1-2)" >> "$GITHUB_OUTPUT" - elif [ "${WP_VERSION}" ] && [ "${WP_VERSION}" != "trunk" ]; then - echo "version=${WP_VERSION}" >> "$GITHUB_OUTPUT" - else - echo "version=nightly" >> "$GITHUB_OUTPUT" - fi - env: - WP_VERSION: ${{ inputs.wp-version }} - - # Determines the versions of PHP supported for a version of WordPress. - # - # Performs the following steps: - # - Checks out the repository - # - Returns the versions of PHP supported for the major version of WordPress by parsing the - # .version-support-php.json file and returning the values in that version's index. - php-versions: - name: Determine PHP versions - permissions: - contents: read - runs-on: ubuntu-26.04 - needs: [ major-wp-version ] - timeout-minutes: 5 - outputs: - versions: ${{ steps.php-versions.outputs.versions }} - - steps: - - name: Checkout repository - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - repository: ${{ inputs.repository }} - show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - persist-credentials: false - - # Look up the major version's specific PHP support policy when a version is provided. - # Otherwise, use the current PHP support policy. - - name: Get supported PHP versions - id: php-versions - run: | - if [ "${WP_VERSION}" != "latest" ] && [ "${WP_VERSION}" != "nightly" ]; then - VERSIONS="$( jq \ - -r \ - --arg wp_version "${WP_VERSION}" \ - '.[$wp_version] | @json' \ - .version-support-php.json - )" - echo "versions=$VERSIONS" >> "$GITHUB_OUTPUT" - else - echo "versions=$(jq -r '.[ (keys[-1]) ] | @json' .version-support-php.json)" >> "$GITHUB_OUTPUT" - fi - env: - WP_VERSION: ${{ needs.major-wp-version.outputs.version }} - - # Determines the versions of MySQL supported for a version of WordPress. - # - # Performs the following steps: - # - Checks out the repository - # - Returns the versions of MySQL supported for the major version of WordPress by parsing the - # .version-support-mysql.json file and returning the values in that version's index. - mysql-versions: - name: Determine MySQL versions - permissions: - contents: read - runs-on: ubuntu-26.04 - needs: [ major-wp-version ] - timeout-minutes: 5 - outputs: - versions: ${{ steps.mysql-versions.outputs.versions }} - - steps: - - name: Checkout repository - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - repository: ${{ inputs.repository }} - show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - persist-credentials: false - - # Look up the major version's specific MySQL support policy when a version is provided. - # Otherwise, use the current MySQL support policy. - - name: Get supported MySQL versions - id: mysql-versions - run: | - if [ "${WP_VERSION}" != "latest" ] && [ "${WP_VERSION}" != "nightly" ]; then - VERSIONS="$( jq \ - -r \ - --arg wp_version "${WP_VERSION}" \ - '.[$wp_version] | @json' \ - .version-support-mysql.json - )" - echo "versions=$VERSIONS" >> "$GITHUB_OUTPUT" - else - echo "versions=$(jq -r '.[ (keys[-1]) ] | @json' .version-support-mysql.json)" >> "$GITHUB_OUTPUT" - fi - env: - WP_VERSION: ${{ needs.major-wp-version.outputs.version }} diff --git a/.github/workflows/reusable-test-core-build-process.yml b/.github/workflows/reusable-test-core-build-process.yml deleted file mode 100644 index 90f8dfd0d569e..0000000000000 --- a/.github/workflows/reusable-test-core-build-process.yml +++ /dev/null @@ -1,171 +0,0 @@ -## -# A reusable workflow that tests the WordPress Core build process. -# -# This workflow is used by `trunk` and branches >= 4.7. -## -name: Test the WordPress Build Process - -on: - workflow_call: - inputs: - os: - description: 'Operating system to run tests on' - required: false - type: 'string' - default: 'ubuntu-26.04' - directory: - description: 'Directory to run WordPress from. Valid values are `src` or `build`' - required: false - type: 'string' - default: 'src' - test-emoji: - description: 'Whether to run the precommit:emoji Grunt script.' - required: false - type: 'boolean' - default: true - test-certificates: - description: 'Whether to run the certificate related Grunt scripts.' - required: false - type: 'boolean' - default: false - save-build: - description: 'Whether to save a ZIP of built WordPress as an artifact.' - required: false - type: 'boolean' - default: false - prepare-playground: - description: 'Whether to prepare the artifacts needed for Playground testing.' - required: false - type: 'boolean' - default: false - -env: - PUPPETEER_SKIP_DOWNLOAD: true - NODE_OPTIONS: --max-old-space-size=4096 - -# Disable permissions for all available scopes by default. -# Any needed permissions should be configured at the job level. -permissions: {} - -jobs: - # Verifies that installing npm dependencies and building WordPress works as expected. - # - # Performs the following steps: - # - Checks out the repository. - # - Sets up Node.js. - # - Logs debug information about the GitHub Action runner. - # - Installs npm dependencies. - # - Builds WordPress to run from the desired location (src or build). - # - Ensures version-controlled files are not modified or deleted. - # - Creates a ZIP of the built WordPress files (when building to the build directory). - # - Cleans up after building WordPress. - # - Ensures version-controlled files are not modified or deleted. - # - Uploads the ZIP as a GitHub Actions artifact (when building to the build directory). - # - Saves the pull request number to a text file. - # - Uploads the pull request number as an artifact. - build-process-tests: - name: ${{ contains( inputs.os, 'macos-' ) && 'MacOS' || contains( inputs.os, 'windows-' ) && 'Windows' || 'Linux' }} - permissions: - contents: read - runs-on: ${{ inputs.os }} - timeout-minutes: 20 - - steps: - - name: Checkout repository - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - persist-credentials: false - - # This date is used to ensure that the PHPCS cache is cleared at least once every week. - # http://man7.org/linux/man-pages/man1/date.1.html - - name: "Get last Monday's date" - id: get-date - if: ${{ inputs.test-certificates }} - run: echo "date=$(/bin/date -u --date='last Mon' "+%F")" >> "$GITHUB_OUTPUT" - - # Since Composer dependencies are installed using `composer update` and no lock file is in version control, - # passing a custom cache suffix ensures that the cache is flushed at least once per week. - - name: Install Composer dependencies - if: ${{ inputs.test-certificates }} - uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0 - with: - custom-cache-suffix: ${{ steps.get-date.outputs.date }} - - - name: Set up Node.js - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 - with: - node-version-file: '.nvmrc' - package-manager-cache: false - - - name: Set up npm - # Release branches run this workflow from trunk, but some older branches may lack the action. - if: ${{ hashFiles('.github/actions/setup-npm/action.yml') != '' }} - uses: ./.github/actions/setup-npm - - - name: Log debug information - run: | - npm --version - node --version - curl --version - git --version - - - name: Install npm Dependencies - run: npm ci - - - name: Run Emoji precommit task - if: ${{ inputs.test-emoji }} - run: npm run grunt precommit:emoji - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Run CSS precommit tasks - if: ${{ inputs.directory == 'src' }} - run: npm run grunt precommit:css - - - name: Ensure certificates files are updated - if: ${{ inputs.test-certificates }} - run: npm run grunt copy:certificates && npm run grunt build:certificates - - - name: Build WordPress to run from ${{ inputs.directory }} - timeout-minutes: 5 - run: npm run ${{ inputs.directory == 'src' && 'build:dev' || 'build' }} - - - name: Ensure version-controlled files are not modified or deleted during building - run: git diff --exit-code - - - name: Create ZIP of built files - if: ${{ inputs.directory == 'build' && contains( inputs.os, 'ubuntu-' ) }} - run: zip -r wordpress.zip build/. - - - name: Clean after building to run from ${{ inputs.directory }} - run: npm run grunt ${{ inputs.directory == 'src' && 'clean -- --dev' || 'clean' }} - - - name: Ensure version-controlled files are not modified or deleted during cleaning - run: git diff --exit-code - - - name: Upload ZIP as a GitHub Actions artifact - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 - if: ${{ inputs.save-build || inputs.prepare-playground }} - with: - name: wordpress-build-${{ github.event_name == 'pull_request' && github.event.number || github.sha }} - path: wordpress.zip - if-no-files-found: error - retention-days: 14 - - - name: Save PR number - if: ${{ inputs.prepare-playground }} - run: | - mkdir -p ./pr-number - echo "${EVENT_NUMBER}" > ./pr-number/NR - env: - EVENT_NUMBER: ${{ github.event.number }} - - # Uploads the PR number as an artifact for the Pull Request Commenting workflow to download and then - # leave a comment detailing how to test the PR within WordPress Playground. - - name: Upload PR number as artifact - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 - if: ${{ inputs.prepare-playground && github.repository == 'WordPress/wordpress-develop' && github.event_name == 'pull_request' }} - with: - name: pr-number - path: pr-number/ diff --git a/.github/workflows/reusable-test-gutenberg-build-process.yml b/.github/workflows/reusable-test-gutenberg-build-process.yml deleted file mode 100644 index 61705c3f96a55..0000000000000 --- a/.github/workflows/reusable-test-gutenberg-build-process.yml +++ /dev/null @@ -1,110 +0,0 @@ -## -# DEPRECATED -# -# A reusable workflow that tests the Gutenberg plugin build process when run within a wordpress-develop checkout. -# -# This workflow is used by branches 6.5 through 6.9. -## -name: Test the Gutenberg plugin Build Process - -on: - workflow_call: - inputs: - os: - description: 'Operating system to run tests on' - required: false - type: 'string' - default: 'ubuntu-26.04' - directory: - description: 'Directory to run WordPress from. Valid values are `src` or `build`' - required: false - type: 'string' - default: 'src' - gutenberg-branch: - description: 'The branch in the Gutenberg repository that should be tested against.' - required: false - type: 'string' - default: 'trunk' - -env: - GUTENBERG_DIRECTORY: ${{ inputs.directory == 'build' && 'build' || 'src' }}/wp-content/plugins/gutenberg - PUPPETEER_SKIP_DOWNLOAD: true - NODE_OPTIONS: '--max-old-space-size=8192' - -# Disable permissions for all available scopes by default. -# Any needed permissions should be configured at the job level. -permissions: {} - -jobs: - # Verifies that installing npm dependencies and building the Gutenberg plugin works as expected. - # - # Performs the following steps: - # - Checks out the repository. - # - Checks out the Gutenberg plugin into the plugins directory. - # - Sets up Node.js. - # - Logs debug information about the GitHub Action runner. - # - Installs Gutenberg npm dependencies. - # - Runs the Gutenberg build process. - # - Installs Core npm dependencies. - # - Builds WordPress to run from the relevant location (src or build). - # - Builds Gutenberg. - # - Ensures version-controlled files are not modified or deleted. - build-process-tests: - name: ${{ contains( inputs.os, 'macos-' ) && 'MacOS' || contains( inputs.os, 'windows-' ) && 'Windows' || 'Linux' }} - permissions: - contents: read - runs-on: ${{ inputs.os }} - timeout-minutes: 30 - - steps: - - name: Checkout repository - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - persist-credentials: false - - - name: Checkout Gutenberg plugin - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - repository: 'WordPress/gutenberg' - ref: ${{ inputs.gutenberg-branch }} - path: ${{ env.GUTENBERG_DIRECTORY }} - show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - persist-credentials: false - - - name: Set up Node.js - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 - with: - node-version-file: '.nvmrc' - cache: npm - cache-dependency-path: | - package-lock.json - ${{ env.GUTENBERG_DIRECTORY }}/package-lock.json - - - name: Log debug information - run: | - npm --version - node --version - curl --version - git --version - - - name: Install Gutenberg Dependencies - run: npm ci - working-directory: ${{ env.GUTENBERG_DIRECTORY }} - - - name: Build Gutenberg - run: npm run build - working-directory: ${{ env.GUTENBERG_DIRECTORY }} - - - name: Install Core Dependencies - run: npm ci - - - name: Build WordPress to run from ${{ inputs.directory }} - run: npm run ${{ inputs.directory == 'src' && 'build:dev' || 'build' }} - - - name: Run Gutenberg build script after building Core to run from ${{ inputs.directory }} - run: npm run build - working-directory: ${{ env.GUTENBERG_DIRECTORY }} - - - name: Ensure version-controlled files are not modified or deleted during building - run: git diff --exit-code diff --git a/.github/workflows/reusable-test-local-docker-environment-v1.yml b/.github/workflows/reusable-test-local-docker-environment-v1.yml deleted file mode 100644 index fa469a699c446..0000000000000 --- a/.github/workflows/reusable-test-local-docker-environment-v1.yml +++ /dev/null @@ -1,176 +0,0 @@ -## -# A reusable workflow that ensures the local Docker environment is working properly. -# -# This workflow is used by `trunk` and branches >= 6.8. -## -name: Test local Docker environment - -on: - workflow_call: - inputs: - os: - description: 'Operating system to test' - required: false - type: 'string' - default: 'ubuntu-26.04' - php: - description: 'The version of PHP to use, in the format of X.Y' - required: false - type: 'string' - default: 'latest' - db-type: - description: 'Database type. Valid types are mysql and mariadb' - required: false - type: 'string' - default: 'mysql' - db-version: - description: 'Database version' - required: false - type: 'string' - default: '8.4' - memcached: - description: 'Whether to enable memcached' - required: false - type: 'boolean' - default: false - tests-domain: - description: 'The domain to use for the tests' - required: false - type: 'string' - default: 'example.org' - -env: - LOCAL_PHP: ${{ inputs.php == 'latest' && 'latest' || format( '{0}-fpm', inputs.php ) }} - LOCAL_DB_TYPE: ${{ inputs.db-type }} - LOCAL_DB_VERSION: ${{ inputs.db-version }} - LOCAL_PHP_MEMCACHED: ${{ inputs.memcached }} - LOCAL_WP_TESTS_DOMAIN: ${{ inputs.tests-domain }} - PUPPETEER_SKIP_DOWNLOAD: true - -# Disable permissions for all available scopes by default. -# Any needed permissions should be configured at the job level. -permissions: {} - -jobs: - # Tests the local Docker environment. - # - # Performs the following steps: - # - Sets environment variables. - # - Checks out the repository. - # - Sets up Node.js. - # - Sets up PHP. - # - Installs Composer dependencies. - # - Installs npm dependencies - # - Logs general debug information about the runner. - # - Logs Docker debug information (about the Docker installation within the runner). - # - Starts the WordPress Docker container. - # - Logs the running Docker containers. - # - Logs debug information about what's installed within the WordPress Docker containers. - # - Install WordPress within the Docker container. - # - Restarts the Docker environment. - # - Runs a WP CLI command. - # - Tests the logs command. - # - Tests the reset command. - # - Ensures version-controlled files are not modified or deleted. - local-docker-environment-tests: - name: ${{ 'mariadb' == inputs.db-type && 'MariaDB' || 'MySQL' }} ${{ inputs.db-version }}${{ inputs.memcached && ' with memcached' || '' }}${{ 'example.org' != inputs.tests-domain && format( ' {0}', inputs.tests-domain ) || '' }} - permissions: - contents: read - runs-on: ${{ inputs.os }} - timeout-minutes: 20 - - steps: - - name: Configure environment variables - run: | - echo "PHP_FPM_UID=$(id -u)" >> "$GITHUB_ENV" - echo "PHP_FPM_GID=$(id -g)" >> "$GITHUB_ENV" - - - name: Checkout repository - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - persist-credentials: false - - - name: Set up Node.js - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 - with: - node-version-file: '.nvmrc' - package-manager-cache: false - - - name: Set up npm - # Release branches run this workflow from trunk, but some older branches may lack the action. - if: ${{ hashFiles('.github/actions/setup-npm/action.yml') != '' }} - uses: ./.github/actions/setup-npm - - ## - # This allows Composer dependencies to be installed using a single step. - # - # Since tests are currently run within the Docker containers where the PHP version varies, - # the same PHP version needs to be configured for the action runner machine so that the correct - # dependency versions are installed and cached. - ## - - name: Set up PHP - uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2 - with: - php-version: '${{ inputs.php }}' - coverage: none - - # Since Composer dependencies are installed using `composer update` and no lock file is in version control, - # passing a custom cache suffix ensures that the cache is flushed at least once per week. - - name: Install Composer dependencies - uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0 - with: - custom-cache-suffix: $(/bin/date -u --date='last Mon' "+%F") - - - name: Install npm dependencies - run: npm ci - - - name: Build WordPress - timeout-minutes: 5 - run: npm run build:dev - - - name: General debug information - run: | - npm --version - node --version - curl --version - git --version - composer --version - locale -a - - - name: Docker debug information - run: | - docker -v - - - name: Start Docker environment - run: | - npm run env:start - - - name: Log running Docker containers - run: docker ps -a - - - name: WordPress Docker container debug information - run: | - docker compose run --rm mysql "${LOCAL_DB_TYPE}" --version - docker compose run --rm php php --version - docker compose run --rm php php -m - docker compose run --rm php php -i - docker compose run --rm php locale -a - - - name: Install WordPress - run: npm run env:install - - - name: Restart Docker environment - run: npm run env:restart - - - name: Test a CLI command - run: npm run env:cli option get siteurl - - - name: Test logs command - run: npm run env:logs - - - name: Reset the Docker environment - run: npm run env:reset - - - name: Ensure version-controlled files are not modified or deleted - run: git diff --exit-code diff --git a/.github/workflows/reusable-upgrade-testing.yml b/.github/workflows/reusable-upgrade-testing.yml deleted file mode 100644 index 6510ba6818249..0000000000000 --- a/.github/workflows/reusable-upgrade-testing.yml +++ /dev/null @@ -1,185 +0,0 @@ -# A reusable workflow that runs WordPress upgrade testing under the conditions provided. -name: Upgrade Tests - -on: - workflow_call: - inputs: - os: - description: 'Operating system to run tests on.' - required: false - type: 'string' - default: 'ubuntu-26.04' - wp: - description: 'The version of WordPress to start with.' - required: true - type: 'string' - new-version: - description: 'The version of WordPress to update to. Use "latest" to update to the latest version, "develop" to update to the current branch, or provide a specific version number to update to.' - type: 'string' - default: 'latest' - new-version-artifact: - description: 'Optional. The name of an artifact that holds the wordpress.zip of new-version. When set, the upgrade installs from it instead of downloading.' - required: false - type: 'string' - default: '' - php: - description: 'The version of PHP to use. Expected format: X.Y.' - required: true - type: 'string' - multisite: - description: 'Whether to run tests as multisite.' - required: false - type: 'boolean' - default: false - db-type: - description: 'Database type. Valid types are mysql and mariadb.' - required: false - type: 'string' - default: 'mysql' - db-version: - description: 'Database version.' - required: false - type: 'string' - default: '5.7' - -# Disable permissions for all available scopes by default. -# Any needed permissions should be configured at the job level. -permissions: {} - -jobs: - # Runs upgrade tests on a build of WordPress. - # - # Performs the following steps: - # - Sets up PHP. - # - Downloads the specified version of WordPress. - # - Creates a `wp-config.php` file. - # - Installs WordPress. - # - Checks the version of WordPress before the upgrade. - # - Updates to the latest minor version. - # - Updates the database after the minor update. - # - Checks the version of WordPress after the minor update. - # - Updates to the version of WordPress being tested. - # - Updates the database. - # - Checks the version of WordPress after the upgrade. - # - Serves the upgraded site and confirms it renders. - upgrade-tests: - name: PHP ${{ inputs.php }} with ${{ 'mariadb' == inputs.db-type && 'MariaDB' || 'MySQL' }} ${{ inputs.db-version }}${{ inputs.multisite && ' multisite' || '' }} - permissions: - contents: read - runs-on: ${{ inputs.os }} - timeout-minutes: 20 - - env: - WP_ADMIN_USER: admin - WP_ADMIN_PASSWORD: password - - services: - database: - image: ${{ inputs.db-type }}:${{ inputs.db-version }} - ports: - - 3306 - # Ping over TCP, to wait for the TCP server rather than the Unix socket. - # MariaDB 11.0 dropped the `mysqladmin` symlink, so pick the client the image ships. - options: >- - --health-cmd="${{ inputs.db-type == 'mariadb' && ! contains( fromJSON('["5.5", "10.0", "10.1", "10.2", "10.3"]'), inputs.db-version ) && 'mariadb-admin' || 'mysqladmin' }} ping -h 127.0.0.1 --protocol=tcp" - --health-interval="30s" - --health-timeout="10s" - --health-retries="5" - -e MYSQL_ROOT_PASSWORD="root" - -e MYSQL_DATABASE="test_db" - - steps: - - name: Set up PHP ${{ inputs.php }} - uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2 - with: - php-version: '${{ inputs.php }}' - coverage: none - - - name: Set up WP-CLI - # Release branches run this workflow from trunk: `$/` resolves to this workflow's commit, not the caller's. - uses: $/.github/actions/setup-wp-cli - - - name: Download WordPress ${{ inputs.wp }} - # WP-CLI requests the release from WordPress.org once, so a network error fails the job. - # It extracts only after a complete download, so a retry starts from an empty directory. - uses: $/.github/actions/run-with-retry - with: - command: wp core download --version="${WP_VERSION}" - env: - WP_VERSION: ${{ inputs.wp }} - - - name: Create wp-config.php file - run: wp config create --dbname=test_db --dbuser=root --dbpass=root --dbhost="127.0.0.1:${DB_PORT}" - env: - DB_PORT: ${{ job.services.database.ports['3306'] }} - - - name: Install WordPress - run: | - wp core ${{ inputs.multisite && 'multisite-install' || 'install' }} \ - --url=http://localhost/ --title="Upgrade Test" --admin_user="${WP_ADMIN_USER}" \ - --admin_password="${WP_ADMIN_PASSWORD}" --admin_email=me@example.org --skip-email - - - name: Pre-upgrade version check - run: wp core version - - - name: Update to the latest minor version - run: wp core update --minor - - - name: Update the database after the minor update - run: wp core update-db ${{ inputs.multisite && '--network' || '' }} - - - name: Post-upgrade version check after the minor update - run: wp core version - - - name: Download build artifact for the current branch - if: ${{ inputs.new-version == 'develop' }} - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 - with: - name: wordpress-develop - - - name: Upgrade to WordPress at current branch - if: ${{ inputs.new-version == 'develop' }} - run: | - wp core update develop.zip - - - name: Download the WordPress ${{ inputs.new-version }} artifact - if: ${{ inputs.new-version != 'develop' && inputs.new-version-artifact != '' }} - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 - with: - name: ${{ inputs.new-version-artifact }} - - # With a zip, WP-CLI does not stop a downgrade, and the minor update can already be past the target. - # `sort -V` orders 7.2 before 7.2-RC2, so compare the way WordPress does. - - name: Upgrade to WordPress ${{ inputs.new-version }} from the artifact - if: ${{ inputs.new-version != 'develop' && inputs.new-version-artifact != '' }} - run: | - current=$(wp core version) - if ! CURRENT="$current" php -r 'exit( version_compare( getenv( "CURRENT" ), getenv( "WP_VERSION" ), "<" ) ? 0 : 1 );'; then - echo "WordPress ${current} is not older than ${WP_VERSION}, so there is nothing to upgrade." - exit 0 - fi - - wp core update wordpress.zip --version="$WP_VERSION" - env: - WP_VERSION: ${{ inputs.new-version }} - - - name: Upgrade to WordPress ${{ inputs.new-version }} - if: ${{ inputs.new-version != 'develop' && inputs.new-version-artifact == '' }} - run: | - wp core update ${{ 'latest' != inputs.new-version && '--version="${WP_VERSION}"' || '' }} - env: - WP_VERSION: ${{ inputs.new-version }} - - - name: Update the database - run: wp core update-db ${{ inputs.multisite && '--network' || '' }} - - - name: Post-upgrade version check - run: wp core version - - - name: Post-upgrade smoke check - # A network's domain lives in wp-config.php and the database, not just an option. - if: ${{ ! inputs.multisite }} - uses: WordPress/wordpress-develop/.github/actions/smoke-check@trunk # zizmor: ignore[unpinned-uses] - with: - admin-user: ${{ env.WP_ADMIN_USER }} - admin-password: ${{ env.WP_ADMIN_PASSWORD }} diff --git a/.github/workflows/reusable-workflow-lint.yml b/.github/workflows/reusable-workflow-lint.yml deleted file mode 100644 index ffae1fe618d50..0000000000000 --- a/.github/workflows/reusable-workflow-lint.yml +++ /dev/null @@ -1,80 +0,0 @@ -## -# A reusable workflow that lints GitHub Actions workflow files. -# -# This workflow is used by `trunk` and branches >= 6.8. -## -name: Lint GitHub Actions workflows -on: - workflow_call: - -permissions: {} - -jobs: - # Runs the actionlint GitHub Action workflow file linter. - # - # See https://github.com/rhysd/actionlint. - # - # This helps guard against common mistakes including strong type checking for expressions (${{ }}), security checks, - # `run:` script checking, glob syntax validation, and more. - actionlint: - name: Run actionlint - runs-on: ubuntu-26.04 - permissions: - contents: read - timeout-minutes: 5 - steps: - - name: Checkout repository - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - persist-credentials: false - show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - - - name: Run actionlint - uses: docker://rhysd/actionlint@sha256:5457037ba91acd225478edac3d4b32e45cf6c10291e0dabbfd2491c63129afe1 # v1.7.11 - with: - args: "-color -verbose" - - # actionlint shellchecks inline `run:` blocks, but does not read composite actions. - - name: Run shellcheck on composite action scripts - run: find .github -path '.github/actions/*' -name '*.sh' -print0 | xargs -0 -r shellcheck - - # Runs the Zizmor GitHub Action workflow file linter. - # - # See https://github.com/zizmorcore/zizmor - # - # This helps guard against supply chain attacks, unpinned dependencies, excessive permissions, - # dangerous triggers, credential leaks, and sophisticated security vulnerabilities. - # - # Performs the following steps: - # - Checks out the repository. - # - Installs and configures uv. - # - Runs a zizmor scan. - # - Uploads the SARIF file to GitHub. - zizmor: - name: Zizmor - runs-on: ubuntu-26.04 - # GitHub Code Security is not enabled on any of the private mirrors. - if: ${{ github.event.repository.private == false }} - permissions: - security-events: write - actions: read - contents: read - steps: - - name: Checkout repository - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - persist-credentials: false - - - name: Install the latest version of uv - uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0 - - - name: Run zizmor - run: uvx zizmor@1.31.1 --persona=regular --format=sarif --strict-collection . > results.sarif - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Upload SARIF file - uses: github/codeql-action/upload-sarif@54f647b7e1bb85c95cddabcd46b0c578ec92bc1a # v4.36.3 - with: - sarif_file: results.sarif - category: zizmor diff --git a/.github/workflows/slack-notifications.yml b/.github/workflows/slack-notifications.yml deleted file mode 100644 index 239e7da9ea403..0000000000000 --- a/.github/workflows/slack-notifications.yml +++ /dev/null @@ -1,236 +0,0 @@ -## -# A reusable workflow for posting messages to the Making WordPress -# Core Slack Instance by submitting data to Slack webhook URLs -# received by Slack Workflows. -## -name: Slack Notifications - -on: - workflow_call: - inputs: - calling_status: - description: 'The status of the calling workflow' - type: string - required: true - version: - description: 'The WordPress version being tested, added to the workflow name in the message.' - type: string - required: false - default: '' - secrets: - SLACK_GHA_SUCCESS_WEBHOOK: - description: 'The Slack webhook URL for a successful build.' - required: true - SLACK_GHA_CANCELLED_WEBHOOK: - description: 'The Slack webhook URL for a cancelled build.' - required: true - SLACK_GHA_FIXED_WEBHOOK: - description: 'The Slack webhook URL for a fixed build.' - required: true - SLACK_GHA_FAILURE_WEBHOOK: - description: 'The Slack webhook URL for a failed build.' - required: true - -# Disable permissions for all available scopes by default. -# Any needed permissions should be configured at the job level. -permissions: {} - -env: - CURRENT_BRANCH: ${{ github.ref_name }} - -jobs: - # Gathers the details needed for Slack notifications. - # - # These details are passed as outputs to the subsequent, dependant jobs that - # submit data to Slack webhook URLs configured to post messages. - # - # Performs the following steps: - # - Retrieves the current workflow run. - # - Determines the conclusion of the previous workflow run or run attempt. - # - Sets the previous conclusion as an output. - # - Prepares the commit message. - # - Constructs and stores a message payload as an output. - prepare: - name: Prepare notifications - runs-on: ubuntu-26.04 - permissions: - actions: read - contents: read - timeout-minutes: 5 - if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event.workflow_run.event != 'pull_request' }} - outputs: - previous_conclusion: ${{ steps.previous-attempt-result.outputs.result }} - payload: ${{ steps.create-payload.outputs.payload }} - - steps: - - name: Determine the status of the previous attempt - id: previous-attempt-result - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 - with: - retries: 2 - retry-exempt-status-codes: 418 - result-encoding: string - script: | - const workflow_run = await github.rest.actions.getWorkflowRun({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: `${context.runId}`, - }); - - if ( process.env.CALLING_STATUS == 'failure' && workflow_run.data.run_attempt == 1 ) { - return 'first-failure'; - } - - // When a workflow has been restarted, check the previous run attempt. Because workflows are automatically - // restarted once and a failure on the first run is not reported, failures on the second run should not be - // considered. - if ( workflow_run.data.run_attempt > 2 ) { - const previous_run = await github.rest.actions.getWorkflowRunAttempt({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: `${context.runId}`, - attempt_number: workflow_run.data.run_attempt - 1 - }); - - return previous_run.data.conclusion; - } - - // Otherwise, check the previous workflow run. - const previous_runs = await github.rest.actions.listWorkflowRuns({ - owner: context.repo.owner, - repo: context.repo.repo, - workflow_id: workflow_run.data.workflow_id, - branch: process.env.CURRENT_BRANCH, - exclude_pull_requests: true, - }); - - // This is the first workflow run for this branch or tag. - if ( previous_runs.data.workflow_runs.length < 2 ) { - return 'none'; - } - - const expected_events = new Array( 'push', 'schedule', 'workflow_dispatch' ); - - // Find the workflow run for the commit that immediately preceded this one. - for ( let i = 0; i < previous_runs.data.workflow_runs.length; i++ ) { - if ( previous_runs.data.workflow_runs[ i ].run_number == workflow_run.data.run_number ) { - let next_index = i; - do { - next_index++; - - // Protects against a false notification when contributors use the trunk branch as the pull request head_ref. - if ( expected_events.indexOf( previous_runs.data.workflow_runs[ next_index ].event ) == -1 ) { - continue; - } - - return previous_runs.data.workflow_runs[ next_index ].conclusion; - } while ( next_index < previous_runs.data.workflow_runs.length ); - } - } - - // Can't determine previous workflow conclusion. - return 'unknown'; - env: - CALLING_STATUS: ${{ inputs.calling_status }} - - - name: Get the commit message - id: current-commit-message - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 - if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' }} - with: - retries: 2 - retry-exempt-status-codes: 418 - result-encoding: string - script: | - const commit_details = await github.rest.repos.getCommit({ - owner: context.repo.owner, - repo: context.repo.repo, - ref: context.sha, - }); - return commit_details.data.commit.message; - - - name: Construct payload and store as an output - id: create-payload - run: | - COMMIT_MSG="$(echo "${COMMIT_MSG_RAW}" | awk 'NR==1')" - WORKFLOW_NAME="${GITHUB_WORKFLOW}${VERSION:+ (WordPress ${VERSION})}" - PAYLOAD="$( jq \ - -n \ - --arg workflow_name "${WORKFLOW_NAME}" \ - --arg ref_name "${CURRENT_BRANCH}" \ - --arg run_url "https://github.com/WordPress/wordpress-develop/actions/runs/${GITHUB_RUN_ID}/attempts/${GITHUB_RUN_ATTEMPT}" \ - --arg commit_message "${COMMIT_MSG}" \ - '{workflow_name: $workflow_name, ref_name: $ref_name, run_url: $run_url, commit_message: $commit_message}' | jq -c . - )" - echo "payload=$PAYLOAD" >> "$GITHUB_OUTPUT" - env: - COMMIT_MSG_RAW: ${{ ( github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' ) && steps.current-commit-message.outputs.result || github.event.head_commit.message }} - VERSION: ${{ inputs.version }} - - # Posts notifications when a workflow fails. - failure: - name: Failure notifications - permissions: {} - runs-on: ubuntu-26.04 - timeout-minutes: 20 - needs: [ prepare ] - if: ${{ needs.prepare.outputs.previous_conclusion != 'first-failure' && inputs.calling_status == 'failure' || failure() }} - - steps: - - name: Post failure notifications to Slack - uses: slackapi/slack-github-action@45a88b9581bfab2566dc881e2cd66d334e621e2c # v3.0.3 - with: - webhook-type: webhook-trigger - webhook: ${{ secrets.SLACK_GHA_FAILURE_WEBHOOK }} - payload: ${{ needs.prepare.outputs.payload }} - - # Posts notifications the first time a workflow run succeeds after previously failing. - fixed: - name: Fixed notifications - permissions: {} - runs-on: ubuntu-26.04 - timeout-minutes: 20 - needs: [ prepare ] - if: ${{ contains( fromJson( '["failure", "cancelled", "none"]' ), needs.prepare.outputs.previous_conclusion ) && inputs.calling_status == 'success' && success() }} - - steps: - - name: Post failure notifications to Slack - uses: slackapi/slack-github-action@45a88b9581bfab2566dc881e2cd66d334e621e2c # v3.0.3 - with: - webhook-type: webhook-trigger - webhook: ${{ secrets.SLACK_GHA_FIXED_WEBHOOK }} - payload: ${{ needs.prepare.outputs.payload }} - - # Posts notifications when a workflow is successful. - success: - name: Success notifications - permissions: {} - runs-on: ubuntu-26.04 - timeout-minutes: 20 - needs: [ prepare ] - if: ${{ inputs.calling_status == 'success' && success() }} - - steps: - - name: Post success notifications to Slack - uses: slackapi/slack-github-action@45a88b9581bfab2566dc881e2cd66d334e621e2c # v3.0.3 - with: - webhook-type: webhook-trigger - webhook: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }} - payload: ${{ needs.prepare.outputs.payload }} - - # Posts notifications when a workflow is cancelled. - cancelled: - name: Cancelled notifications - permissions: {} - runs-on: ubuntu-26.04 - timeout-minutes: 20 - needs: [ prepare ] - if: ${{ inputs.calling_status == 'cancelled' && github.run_attempt == 2 || cancelled() }} - - steps: - - name: Post cancelled notifications to Slack - uses: slackapi/slack-github-action@45a88b9581bfab2566dc881e2cd66d334e621e2c # v3.0.3 - with: - webhook-type: webhook-trigger - webhook: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }} - payload: ${{ needs.prepare.outputs.payload }} diff --git a/.github/workflows/test-and-zip-default-themes.yml b/.github/workflows/test-and-zip-default-themes.yml deleted file mode 100644 index 9ef0f98821dd9..0000000000000 --- a/.github/workflows/test-and-zip-default-themes.yml +++ /dev/null @@ -1,425 +0,0 @@ -name: Test Default Themes & Create ZIPs - -on: - push: - branches: - - trunk - - '3.[89]' - - '[4-9].[0-9]' - paths: - # Changing the preferred version of Node.js could affect themes with build processes. - - '.npmrc' - - '.nvmrc' - - '.github/actions/setup-npm/**' - # Changes to any themes with a build script should be confirmed. - - 'src/wp-content/themes/twentynineteen/**' - - 'src/wp-content/themes/twentytwenty/**' - - 'src/wp-content/themes/twentytwentyone/**' - - 'src/wp-content/themes/twentytwentytwo/**' - - 'src/wp-content/themes/twentytwentyfive/**' - - 'src/wp-content/themes/ipsum/**' - # Changes to this workflow file should always verify success. - - '.github/workflows/test-and-zip-default-themes.yml' - pull_request: - branches: - - trunk - - '3.[89]' - - '[4-9].[0-9]' - paths: - # Changing the preferred version of Node.js could affect themes with build processes. - - '.npmrc' - - '.nvmrc' - - '.github/actions/setup-npm/**' - # Changes to any themes with a build script should be confirmed. - - 'src/wp-content/themes/twentynineteen/**' - - 'src/wp-content/themes/twentytwenty/**' - - 'src/wp-content/themes/twentytwentyone/**' - - 'src/wp-content/themes/twentytwentytwo/**' - - 'src/wp-content/themes/twentytwentyfive/**' - - 'src/wp-content/themes/ipsum/**' - # Changes to this workflow file should always verify success. - - '.github/workflows/test-and-zip-default-themes.yml' - workflow_dispatch: - inputs: - branch: - description: 'The branch to create ZIP files from' - required: true - type: string - default: 'trunk' - theme: - description: 'The theme to test and zip' - required: true - type: choice - default: 'all' - options: - - all - - ipsum - - twentytwentyfive - - twentytwentyfour - - twentytwentythree - - twentytwentytwo - - twentytwentyone - - twentytwenty - - twentynineteen - - twentyseventeen - - twentysixteen - - twentyfifteen - - twentyfourteen - - twentythirteen - - twentytwelve - - twentyeleven - - twentyten - -# Cancels all previous workflow runs for pull requests that have not completed. -concurrency: - # The concurrency group contains the workflow name and the pull request number for pull requests - # or the commit hash for any other events, plus the selected branch and theme. - group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.sha }}-${{ inputs.branch }}-${{ inputs.theme }} - cancel-in-progress: true - -# Disable permissions for all available scopes by default. -# Any needed permissions should be configured at the job level. -permissions: {} - -jobs: - # Selects the themes to check, build, and package. - determine-themes: - name: Determine Themes - runs-on: ubuntu-26.04 - permissions: {} - timeout-minutes: 5 - if: | - github.repository == 'WordPress/wordpress-develop' || ( - github.event_name == 'pull_request' && ( - ! github.event.repository.private || - ! github.event.pull_request.draft || - contains( github.event.pull_request.labels.*.name, 'Draft Workflow Runs' ) - ) - ) - outputs: - themes: ${{ steps.set-themes.outputs.themes }} - build_themes: ${{ steps.set-themes.outputs.build_themes }} - has_build_themes: ${{ steps.set-themes.outputs.has_build_themes }} - steps: - - name: Determine themes to test and zip - id: set-themes - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 - with: - script: | - const allThemes = [ - 'ipsum', - 'twentytwentyfive', - 'twentytwentyfour', - 'twentytwentythree', - 'twentytwentytwo', - 'twentytwentyone', - 'twentytwenty', - 'twentynineteen', - 'twentyseventeen', - 'twentysixteen', - 'twentyfifteen', - 'twentyfourteen', - 'twentythirteen', - 'twentytwelve', - 'twentyeleven', - 'twentyten', - ]; - const buildThemes = [ - 'ipsum', - 'twentytwentyfive', - 'twentytwentytwo', - 'twentytwentyone', - 'twentytwenty', - 'twentynineteen', - ]; - const selected = context.eventName === 'workflow_dispatch' ? ( context.payload.inputs?.theme || 'all' ) : 'all'; - - if ( selected !== 'all' && ! allThemes.includes( selected ) ) { - core.setFailed( 'Unknown theme selected.' ); - return; - } - - const themes = selected === 'all' ? allThemes : [ selected ]; - const filteredBuildThemes = buildThemes.filter( ( theme ) => themes.includes( theme ) ); - - core.setOutput( 'themes', JSON.stringify( themes ) ); - core.setOutput( 'build_themes', JSON.stringify( filteredBuildThemes ) ); - core.setOutput( 'has_build_themes', filteredBuildThemes.length > 0 ); - - # Checks for zero-byte files. - # - # Occasionally, binary files such as images and fonts are added to themes incorrectly. - # This checks that all files contain contents. - # - # Performs the following steps: - # - Checks out the repository. - # - Checks for zero-byte (empty) files. - check-for-empty-files: - name: ${{ matrix.theme }} empty file check - runs-on: ubuntu-26.04 - permissions: - contents: read - needs: [ determine-themes ] - timeout-minutes: 10 - strategy: - fail-fast: false - matrix: - theme: ${{ fromJson( needs.determine-themes.outputs.themes ) }} - - steps: - - name: Checkout repository - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - ref: ${{ github.event_name == 'workflow_dispatch' && inputs.branch || github.ref }} - show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - persist-credentials: false - - - name: Check whether theme exists - id: theme-exists - working-directory: . - run: | - if [[ -d "src/wp-content/themes/${THEME}" ]]; then - echo "exists=true" >> "$GITHUB_OUTPUT" - else - echo "exists=false" >> "$GITHUB_OUTPUT" - echo "Theme ${THEME} does not exist on the selected branch." - fi - env: - THEME: ${{ matrix.theme }} - - - name: Check for zero-byte (empty) files - if: ${{ steps.theme-exists.outputs.exists == 'true' }} - run: | - [[ ! $(find "src/wp-content/themes/${THEME}" -empty) ]] - env: - THEME: ${{ matrix.theme }} - - # Tests the build script for themes that have one. - # - # Performs the following steps: - # - Checks out the repository. - # - Sets up Node.js. - # - Installs npm dependencies. - # - Runs the theme build script. - # - Ensures version-controlled files are not modified or deleted. - test-build-scripts: - name: Test ${{ matrix.theme }} build script - runs-on: ubuntu-26.04 - permissions: - contents: read - needs: [ determine-themes ] - timeout-minutes: 10 - # Skip this job before expanding an empty build matrix. - if: ${{ needs.determine-themes.outputs.has_build_themes == 'true' }} - strategy: - fail-fast: false - matrix: - theme: ${{ fromJson( needs.determine-themes.outputs.build_themes ) }} - - defaults: - run: - working-directory: src/wp-content/themes/${{ matrix.theme }} - - steps: - - name: Checkout repository - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - ref: ${{ github.event_name == 'workflow_dispatch' && inputs.branch || github.ref }} - show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - persist-credentials: false - - - name: Check whether theme exists - id: theme-exists - working-directory: . - run: | - if [[ -d "src/wp-content/themes/${THEME}" ]]; then - echo "exists=true" >> "$GITHUB_OUTPUT" - else - echo "exists=false" >> "$GITHUB_OUTPUT" - echo "Theme ${THEME} does not exist on the selected branch." - fi - env: - THEME: ${{ matrix.theme }} - - - name: Set up Node.js - if: ${{ steps.theme-exists.outputs.exists == 'true' }} - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 - with: - node-version-file: 'src/wp-content/themes/${{ matrix.theme }}/.nvmrc' - package-manager-cache: false - - - name: Set up npm - # A workflow_dispatch run can check out a release branch, which lacks the action. - if: ${{ steps.theme-exists.outputs.exists == 'true' && hashFiles('.github/actions/setup-npm/action.yml') != '' }} - uses: ./.github/actions/setup-npm - with: - working-directory: src/wp-content/themes/${{ matrix.theme }} - - - name: Install npm dependencies - if: ${{ steps.theme-exists.outputs.exists == 'true' }} - run: npm ci - - - name: Build theme - if: ${{ steps.theme-exists.outputs.exists == 'true' }} - run: npm run build - - - name: Check for changes to versioned files - id: built-file-check - if: ${{ steps.theme-exists.outputs.exists == 'true' && github.event_name == 'pull_request' }} - run: | - if git diff --quiet; then - echo "uncommitted_changes=false" >> "$GITHUB_OUTPUT" - else - echo "uncommitted_changes=true" >> "$GITHUB_OUTPUT" - fi - - - name: Display changes to versioned files - if: ${{ steps.built-file-check.outputs.uncommitted_changes == 'true' }} - run: git diff - - - name: Save diff to a file - if: ${{ steps.built-file-check.outputs.uncommitted_changes == 'true' }} - run: git diff > ./changes.diff - - # Uploads the diff file as an artifact. - - name: Upload diff file as artifact - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 - if: ${{ steps.built-file-check.outputs.uncommitted_changes == 'true' }} - with: - name: pr-built-file-changes - path: src/wp-content/themes/${{ matrix.theme }}/changes.diff - - - name: Ensure version-controlled files are not modified or deleted - if: ${{ steps.theme-exists.outputs.exists == 'true' }} - run: git diff --exit-code - - # Prepares bundled themes for release. - # - # Performs the following steps: - # - Checks out the repository. - # - Uploads the theme files as a workflow artifact (files uploaded as an artifact are automatically zipped). - bundle-theme: - name: Create ${{ matrix.theme }} ZIP file - runs-on: ubuntu-26.04 - permissions: - contents: read - needs: [ determine-themes, check-for-empty-files, test-build-scripts ] - timeout-minutes: 10 - if: | - ! cancelled() && - github.repository == 'WordPress/wordpress-develop' && - needs.determine-themes.result == 'success' && - needs.check-for-empty-files.result == 'success' && - ( needs.test-build-scripts.result == 'success' || needs.test-build-scripts.result == 'skipped' ) - strategy: - fail-fast: false - matrix: - theme: ${{ fromJson( needs.determine-themes.outputs.themes ) }} - - steps: - - name: Checkout repository - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - ref: ${{ github.event_name == 'workflow_dispatch' && inputs.branch || github.ref }} - show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - persist-credentials: false - - - name: Check whether theme exists - id: theme-exists - working-directory: . - run: | - if [[ -d "src/wp-content/themes/${THEME}" ]]; then - echo "exists=true" >> "$GITHUB_OUTPUT" - else - echo "exists=false" >> "$GITHUB_OUTPUT" - echo "Theme ${THEME} does not exist on the selected branch." - if [[ "${SELECTED_THEME}" != 'all' ]]; then - exit 1 - fi - fi - env: - THEME: ${{ matrix.theme }} - SELECTED_THEME: ${{ github.event_name == 'workflow_dispatch' && inputs.theme || 'all' }} - - - name: Set up Node.js for themes needing minification - if: ${{ steps.theme-exists.outputs.exists == 'true' && ( matrix.theme == 'twentytwentytwo' || matrix.theme == 'twentytwentyfive' || matrix.theme == 'ipsum' ) }} - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 - with: - node-version-file: 'src/wp-content/themes/${{ matrix.theme }}/.nvmrc' - package-manager-cache: false - - - name: Set up npm - # A workflow_dispatch run can check out a release branch, which lacks the action. - if: ${{ steps.theme-exists.outputs.exists == 'true' && ( matrix.theme == 'twentytwentytwo' || matrix.theme == 'twentytwentyfive' || matrix.theme == 'ipsum' ) && hashFiles('.github/actions/setup-npm/action.yml') != '' }} - uses: ./.github/actions/setup-npm - with: - working-directory: src/wp-content/themes/${{ matrix.theme }} - - - name: Install npm dependencies - if: ${{ steps.theme-exists.outputs.exists == 'true' && ( matrix.theme == 'twentytwentytwo' || matrix.theme == 'twentytwentyfive' || matrix.theme == 'ipsum' ) }} - run: npm ci - working-directory: src/wp-content/themes/${{ matrix.theme }} - - - name: Build theme assets - if: ${{ steps.theme-exists.outputs.exists == 'true' && ( matrix.theme == 'twentytwentytwo' || matrix.theme == 'twentytwentyfive' || matrix.theme == 'ipsum' ) }} - run: npm run build - working-directory: src/wp-content/themes/${{ matrix.theme }} - - - name: Upload theme ZIP as an artifact - if: ${{ steps.theme-exists.outputs.exists == 'true' }} - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 - with: - name: ${{ matrix.theme }} - path: | - src/wp-content/themes/${{ matrix.theme }} - !src/wp-content/themes/${{ matrix.theme }}/node_modules - if-no-files-found: error - - slack-notifications: - name: Slack Notifications - uses: ./.github/workflows/slack-notifications.yml - permissions: - actions: read - contents: read - needs: [ determine-themes, check-for-empty-files, bundle-theme, test-build-scripts ] - if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }} - with: - calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }} - secrets: - SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }} - SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }} - SLACK_GHA_FIXED_WEBHOOK: ${{ secrets.SLACK_GHA_FIXED_WEBHOOK }} - SLACK_GHA_FAILURE_WEBHOOK: ${{ secrets.SLACK_GHA_FAILURE_WEBHOOK }} - - failed-workflow: - name: Failed workflow tasks - runs-on: ubuntu-26.04 - permissions: - actions: write - needs: [ slack-notifications ] - if: | - always() && - github.repository == 'WordPress/wordpress-develop' && - github.event_name != 'pull_request' && - github.run_attempt < 2 && - ( - contains( needs.*.result, 'cancelled' ) || - contains( needs.*.result, 'failure' ) - ) - - steps: - - name: Dispatch workflow run - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 - with: - retries: 2 - retry-exempt-status-codes: 418 - script: | - github.rest.actions.createWorkflowDispatch({ - owner: context.repo.owner, - repo: context.repo.repo, - workflow_id: 'failed-workflow.yml', - ref: 'trunk', - inputs: { - run_id: `${context.runId}`, - } - }); diff --git a/.github/workflows/test-build-processes.yml b/.github/workflows/test-build-processes.yml index c64bc260c7439..021bbcdb0b1c8 100644 --- a/.github/workflows/test-build-processes.yml +++ b/.github/workflows/test-build-processes.yml @@ -63,7 +63,7 @@ jobs: # Tests the WordPress Core build process. test-core-build-process: name: Core running from ${{ matrix.directory }} - uses: ./.github/workflows/reusable-test-core-build-process.yml + uses: WordPress/wordpress-develop/.github/workflows/reusable-test-core-build-process.yml@trunk permissions: contents: read if: | @@ -105,7 +105,7 @@ jobs: # See https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability. test-core-build-process-additional-os: name: Core running from ${{ matrix.directory }} - uses: ./.github/workflows/reusable-test-core-build-process.yml + uses: WordPress/wordpress-develop/.github/workflows/reusable-test-core-build-process.yml@trunk permissions: contents: read if: ${{ github.repository == 'WordPress/wordpress-develop' }} @@ -120,7 +120,7 @@ jobs: slack-notifications: name: Slack Notifications - uses: ./.github/workflows/slack-notifications.yml + uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk permissions: actions: read contents: read diff --git a/.github/workflows/test-coverage.yml b/.github/workflows/test-coverage.yml deleted file mode 100644 index 583a6045213dc..0000000000000 --- a/.github/workflows/test-coverage.yml +++ /dev/null @@ -1,134 +0,0 @@ -name: Code Coverage Report - -on: - # Verify - push: - branches: - - trunk - paths: - - '.github/actions/setup-npm/**' - - '.github/workflows/test-coverage.yml' - - '.github/workflows/reusable-phpunit-tests-v3.yml' - - '.github/workflows/reusable-prepare-gutenberg.yml' - - 'tools/gutenberg/**' - - 'package*.json' - - '.nvmrc' - - 'docker-compose.yml' - - 'phpunit.xml.dist' - - 'tests/phpunit/multisite.xml' - pull_request: - branches: - - trunk - paths: - - '.github/actions/setup-npm/**' - - '.github/workflows/test-coverage.yml' - - '.github/workflows/reusable-phpunit-tests-v3.yml' - - '.github/workflows/reusable-prepare-gutenberg.yml' - - 'tools/gutenberg/**' - - 'package*.json' - - '.nvmrc' - - 'docker-compose.yml' - - 'phpunit.xml.dist' - - 'tests/phpunit/multisite.xml' - # Once daily at 00:00 UTC. - schedule: - - cron: '0 0 * * *' - # Allow manually triggering the workflow. - workflow_dispatch: - -# Cancels all previous workflow runs for pull requests that have not completed. -concurrency: - # The concurrency group contains the workflow name and the pull request number for pull requests - # or the commit hash for any other events. - group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.sha }} - cancel-in-progress: true - -# Disable permissions for all available scopes by default. -# Any needed permissions should be configured at the job level. -permissions: {} - -env: - LOCAL_PHP_MEMCACHED: false - PUPPETEER_SKIP_DOWNLOAD: true - -jobs: - # Downloads and verifies the Gutenberg build once for all coverage jobs. - prepare-gutenberg: - name: Prepare Gutenberg Assets - uses: ./.github/workflows/reusable-prepare-gutenberg.yml - permissions: - contents: read - if: ${{ github.repository == 'WordPress/wordpress-develop' }} - - # - # Creates a PHPUnit test jobs for generating code coverage reports. - # - test-coverage-report: - name: ${{ matrix.multisite && 'Multisite' || 'Single site' }} report - uses: ./.github/workflows/reusable-phpunit-tests-v3.yml - needs: prepare-gutenberg - permissions: - contents: read - if: ${{ github.repository == 'WordPress/wordpress-develop' }} - strategy: - fail-fast: false - matrix: - multisite: [ false, true ] - coverage-report: [ true ] - with: - php: '8.3' - multisite: ${{ matrix.multisite }} - coverage-report: ${{ matrix.coverage-report }} - gutenberg-artifact: ${{ needs.prepare-gutenberg.result != 'skipped' }} - gutenberg-sha: ${{ needs.prepare-gutenberg.outputs.gutenberg-sha }} - secrets: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - - slack-notifications: - name: Slack Notifications - uses: ./.github/workflows/slack-notifications.yml - permissions: - actions: read - contents: read - needs: [ prepare-gutenberg, test-coverage-report ] - if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }} - with: - calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }} - secrets: - SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }} - SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }} - SLACK_GHA_FIXED_WEBHOOK: ${{ secrets.SLACK_GHA_FIXED_WEBHOOK }} - SLACK_GHA_FAILURE_WEBHOOK: ${{ secrets.SLACK_GHA_FAILURE_WEBHOOK }} - - failed-workflow: - name: Failed workflow tasks - runs-on: ubuntu-26.04 - permissions: - actions: write - needs: [ slack-notifications ] - if: | - always() && - github.repository == 'WordPress/wordpress-develop' && - github.event_name != 'pull_request' && - github.run_attempt < 2 && - ( - contains( needs.*.result, 'cancelled' ) || - contains( needs.*.result, 'failure' ) - ) - - steps: - - name: Dispatch workflow run - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 - with: - retries: 2 - retry-exempt-status-codes: 418 - script: | - github.rest.actions.createWorkflowDispatch({ - owner: context.repo.owner, - repo: context.repo.repo, - workflow_id: 'failed-workflow.yml', - ref: 'trunk', - inputs: { - run_id: `${context.runId}`, - } - }); diff --git a/.github/workflows/test-old-branches.yml b/.github/workflows/test-old-branches.yml deleted file mode 100644 index a7d2ddcb01836..0000000000000 --- a/.github/workflows/test-old-branches.yml +++ /dev/null @@ -1,160 +0,0 @@ -name: Test old branches - -on: - # Verify the workflow is successful when this file is updated. - push: - branches: - - trunk - paths: - - '.github/workflows/test-old-branches.yml' - - '.github/workflows/reusable-*.yml' - # Run twice a month on the 1st and 15th at 00:00 UTC. - schedule: - - cron: '0 0 1 * *' - - cron: '0 0 15 * *' - workflow_dispatch: - inputs: - strategy: - description: 'The branches to test. Accepts X.Y branch names, or "all". Defaults to only the currently supported branch.' - required: false - type: string - default: '' - -# Disable permissions for all available scopes by default. -# Any needed permissions should be configured at the job level. -permissions: {} - -env: - CURRENTLY_SUPPORTED_BRANCH: '7.1' - -jobs: - dispatch-workflows-for-old-branches: - name: ${{ matrix.workflow }} for ${{ matrix.branch }} - runs-on: ubuntu-26.04 - permissions: - actions: write - timeout-minutes: 20 - if: ${{ github.repository == 'WordPress/wordpress-develop' }} - strategy: - fail-fast: false - matrix: - workflow: [ - 'coding-standards.yml', - 'javascript-tests.yml', - 'phpunit-tests.yml', - 'test-build-processes.yml' - ] - branch: [ - '7.1', '7.0', - '6.9', '6.8', '6.7', '6.6', '6.5', '6.4', '6.3', '6.2', '6.1','6.0', - '5.9', '5.8', '5.7', '5.6', '5.5', '5.4', '5.3', '5.2', '5.1', '5.0', - '4.9', '4.8', '4.7' - ] - include: - # PHP Compatibility testing was introduced in 5.5. - - branch: '7.1' - workflow: 'php-compatibility.yml' - - branch: '7.0' - workflow: 'php-compatibility.yml' - - branch: '6.9' - workflow: 'php-compatibility.yml' - - branch: '6.8' - workflow: 'php-compatibility.yml' - - branch: '6.7' - workflow: 'php-compatibility.yml' - - branch: '6.6' - workflow: 'php-compatibility.yml' - - branch: '6.5' - workflow: 'php-compatibility.yml' - - branch: '6.4' - workflow: 'php-compatibility.yml' - - branch: '6.3' - workflow: 'php-compatibility.yml' - - branch: '6.2' - workflow: 'php-compatibility.yml' - - branch: '6.1' - workflow: 'php-compatibility.yml' - - branch: '6.0' - workflow: 'php-compatibility.yml' - - branch: '5.9' - workflow: 'php-compatibility.yml' - - branch: '5.8' - workflow: 'php-compatibility.yml' - - branch: '5.7' - workflow: 'php-compatibility.yml' - - branch: '5.6' - workflow: 'php-compatibility.yml' - - branch: '5.5' - workflow: 'php-compatibility.yml' - - # End-to-end testing was introduced in 5.3 but was later removed as there were no meaningful assertions. - # Starting in 5.8 with #52905, some additional tests with real assertions were introduced. - # Branches 5.8 and newer should be tested to confirm no regressions are introduced. - - branch: '7.1' - workflow: 'end-to-end-tests.yml' - - branch: '7.0' - workflow: 'end-to-end-tests.yml' - - branch: '6.9' - workflow: 'end-to-end-tests.yml' - - branch: '6.8' - workflow: 'end-to-end-tests.yml' - - branch: '6.7' - workflow: 'end-to-end-tests.yml' - - branch: '6.6' - workflow: 'end-to-end-tests.yml' - - branch: '6.5' - workflow: 'end-to-end-tests.yml' - - branch: '6.4' - workflow: 'end-to-end-tests.yml' - - branch: '6.3' - workflow: 'end-to-end-tests.yml' - - branch: '6.2' - workflow: 'end-to-end-tests.yml' - - branch: '6.1' - workflow: 'end-to-end-tests.yml' - - branch: '6.0' - workflow: 'end-to-end-tests.yml' - - branch: '5.9' - workflow: 'end-to-end-tests.yml' - - branch: '5.8' - workflow: 'end-to-end-tests.yml' - - # Performance testing was introduced in 6.2 using Puppeteer but was overhauled to use Playwright instead in 6.4. - # Since the workflow frequently failed for 6.2 and 6.3 due to the flaky nature of the Puppeteer tests, - # the workflow was removed from those two branches. - - branch: '7.1' - workflow: 'performance.yml' - - branch: '7.0' - workflow: 'performance.yml' - - # Run all branches monthly, but only the currently supported one twice per month. - steps: - - name: Dispatch workflow run - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 - if: ${{ github.event_name == 'push' || ( github.event_name == 'workflow_dispatch' && matrix.branch == inputs.strategy || inputs.strategy == 'all' ) || github.event.schedule == '0 0 15 * *' || matrix.branch == env.CURRENTLY_SUPPORTED_BRANCH }} - with: - retries: 2 - retry-exempt-status-codes: 418 - script: | - github.rest.actions.createWorkflowDispatch({ - owner: context.repo.owner, - repo: context.repo.repo, - workflow_id: '${{ matrix.workflow }}', - ref: '${{ matrix.branch }}' - }); - - slack-notifications: - name: Slack Notifications - uses: ./.github/workflows/slack-notifications.yml - permissions: - actions: read - contents: read - needs: [ dispatch-workflows-for-old-branches ] - if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }} - with: - calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }} - secrets: - SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }} - SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }} - SLACK_GHA_FIXED_WEBHOOK: ${{ secrets.SLACK_GHA_FIXED_WEBHOOK }} - SLACK_GHA_FAILURE_WEBHOOK: ${{ secrets.SLACK_GHA_FAILURE_WEBHOOK }} diff --git a/.github/workflows/upgrade-develop-testing.yml b/.github/workflows/upgrade-develop-testing.yml index dcd921c2e6c7e..678d3e8700ffb 100644 --- a/.github/workflows/upgrade-develop-testing.yml +++ b/.github/workflows/upgrade-develop-testing.yml @@ -54,7 +54,7 @@ jobs: # Build WordPress from the current branch ready for the upgrade tests. build: name: Build - uses: ./.github/workflows/reusable-build-package.yml + uses: WordPress/wordpress-develop/.github/workflows/reusable-build-package.yml@trunk if: | startsWith( github.repository, 'WordPress/' ) && ( github.repository == 'WordPress/wordpress-develop' || ( @@ -79,7 +79,7 @@ jobs: # being updated to keep the matrix as small as is reasonable. upgrade-tests-develop: name: Upgrade from ${{ matrix.wp }} - uses: ./.github/workflows/reusable-upgrade-testing.yml + uses: WordPress/wordpress-develop/.github/workflows/reusable-upgrade-testing.yml@trunk if: ${{ github.repository == 'WordPress/wordpress-develop' }} needs: [ build ] permissions: @@ -109,7 +109,7 @@ jobs: # for forks. upgrade-tests-develop-forks: name: Upgrade from ${{ matrix.wp }} - uses: ./.github/workflows/reusable-upgrade-testing.yml + uses: WordPress/wordpress-develop/.github/workflows/reusable-upgrade-testing.yml@trunk if: | github.repository != 'WordPress/wordpress-develop' && github.event_name == 'pull_request' && ( ! github.event.repository.private || @@ -139,7 +139,7 @@ jobs: slack-notifications: name: Slack Notifications - uses: ./.github/workflows/slack-notifications.yml + uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk permissions: actions: read contents: read diff --git a/.github/workflows/upgrade-testing.yml b/.github/workflows/upgrade-testing.yml deleted file mode 100644 index 3765692707b16..0000000000000 --- a/.github/workflows/upgrade-testing.yml +++ /dev/null @@ -1,359 +0,0 @@ -# Confirms that updating WordPress using WP-CLI works successfully. -# -# This workflow is not meant to test wordpress-develop checkouts, but rather tagged versions officially available on WordPress.org. -name: Upgrade Tests - -on: - push: - branches: - - trunk - # Always test the workflow after it's updated. - paths: - - '.github/actions/setup-wp-cli/**' - - '.github/actions/run-with-retry/**' - - '.github/actions/smoke-check/**' - - '.github/workflows/upgrade-testing.yml' - - '.github/workflows/reusable-upgrade-testing.yml' - - '.github/workflows/reusable-download-wordpress-release.yml' - pull_request: - # This workflow is only meant to run from trunk. Pull requests changing this file with different BASE branches should be ignored. - branches: - - trunk - # Always test the workflow when changes are suggested. - paths: - - '.github/actions/setup-wp-cli/**' - - '.github/actions/run-with-retry/**' - - '.github/workflows/upgrade-testing.yml' - - '.github/workflows/reusable-upgrade-testing.yml' - - '.github/workflows/reusable-download-wordpress-release.yml' - workflow_dispatch: - inputs: - new-version: - description: 'The version to test installing. Accepts major and minor versions, "latest", or "nightly". Major releases must not end with ".0".' - type: string - default: 'latest' - -# Cancels all previous workflow runs for pull requests that have not completed. -concurrency: - # The concurrency group contains the workflow name and the pull request number for pull requests - # or the commit hash for any other events. - group: ${{ github.workflow }}-${{ inputs.new-version || github.event_name == 'pull_request' && github.event.pull_request.number || github.sha }} - cancel-in-progress: true - -# Disable permissions for all available scopes by default. -# Any needed permissions should be configured at the job level. -permissions: {} - -# Because the number of jobs spawned can quickly balloon out of control, the following methodology is applied when -# building out the matrix below: -# -# - The two most recent releases of WordPress are tested against all PHP/MySQL LTS version combinations and the -# most recent innovation release. -# - The next 6 oldest versions of WordPress are tested against both the oldest and newest releases of PHP currently -# supported for both PHP 7 & 8 along with the oldest and newest MySQL LTS versions currently supported (no innovation -# releases). At the current 3 releases per year pace, this accounts for 2 additional years worth of releases. -# - Of the remaining versions of WordPress still receiving security updates, only test the ones where the database -# version was updated since the previous major release. -# - The oldest version of WordPress receiving security updates should always be tested against the same combinations as -# detailed for the two most recent releases. - -# Notes about chosen MySQL versions: -# - Only the most recent innovation release should be included in testing. -# - Even though MySQL >= 5.5.5 is currently supported, there are no 5.5.x Docker containers available that work on -# modern architectures. -# - 5.6.x Docker containers are available and work, but 5.6 only accounts for ~2.3% of installs as of 12/6/2024.defaults: -# - 5.7.x accounts for ~20% of installs, so this is used below instead. -jobs: - # Builds the list of starting versions for each matrix below. Drops every version that is not older than the target - # version, because upgrading from one of those is a downgrade. A job whose list ends up empty is skipped. - # - # A major target (6.4 or 6.4.0) drops its own branch, because no upgrade would occur. - # - # A minor target (6.4.4) keeps its own branch, because 6.4 to 6.4.4 is a real upgrade. The called workflow runs - # `wp core update --minor` before the final upgrade step, so the minor update performs that upgrade and the final - # upgrade step is a no-op. When the target is not the newest release on its branch, the minor update overshoots - # the target and the target is never installed. - # - # "latest" and "nightly" drop nothing. Any other unrecognized target is treated the same way, with a warning. - build-test-matrix: - name: Build Test Matrix - runs-on: ubuntu-26.04 - permissions: {} - if: ${{ github.repository == 'WordPress/wordpress-develop' }} - timeout-minutes: 5 - outputs: - recent-releases: ${{ steps.versions.outputs.recent-releases }} - wp-6x: ${{ steps.versions.outputs.wp-6x }} - wp-5x-php-7x: ${{ steps.versions.outputs.wp-5x-php-7x }} - wp-5x-php-8x: ${{ steps.versions.outputs.wp-5x-php-8x }} - oldest-wp: ${{ steps.versions.outputs.oldest-wp }} - - steps: - - name: Drop the versions that are not older than the version being tested - id: versions - env: - NEW_VERSION: ${{ inputs.new-version && inputs.new-version || 'latest' }} - # The versions each job below starts from. See the comment on the job for why those versions are tested. - RECENT_RELEASES: '7.0 7.1' # upgrade-tests-recent-releases - WP_6X: '6.0 6.3 6.4 6.5' # upgrade-tests-wp-6x-mysql - WP_5X_PHP_7X: '5.0 5.1 5.3 5.4 5.5 5.6 5.9' # upgrade-tests-wp-5x-php-7x-mysql - WP_5X_PHP_8X: '5.3 5.4 5.5 5.6 5.9' # upgrade-tests-wp-5x-php-8x-mysql - OLDEST_WP: '4.7' # upgrade-tests-oldest-wp-mysql - run: | - # Branches are compared as a single number so that 7.0 sorts above 6.9. The spacing leaves room for a - # pre-release to sort between its own branch and the one before it. The base is forced to 10 so that a - # version number with a leading zero is not read as an invalid octal value. - if [[ "$NEW_VERSION" =~ ^v?([0-9]+)\.([0-9]+)(\.([0-9]+))?$ ]]; then - target=$(( 10#${BASH_REMATCH[1]} * 10000 + 10#${BASH_REMATCH[2]} * 100 )) - - # A version with no patch number, or a patch number of 0, is a major release: drop its own branch too. - if [[ -z "${BASH_REMATCH[4]}" || "${BASH_REMATCH[4]}" == "0" ]]; then - target=$(( target - 1 )) - fi - else - # Sorts above every version in the lists above, so nothing is dropped. - target=999999 - - if [[ "$NEW_VERSION" != 'latest' && "$NEW_VERSION" != 'nightly' ]]; then - echo "::warning::\"${NEW_VERSION}\" was not read as a version number, so every version will be tested." - fi - fi - - # Writes the versions of $2 that are older than the target to the $1 output, as a JSON array. - filter() { - local kept='' wp branch - local -a versions - - # Guards against a list being renamed in the environment above without updating the call below, which - # would otherwise skip the whole job in silence. - [[ -n "$2" ]] || { echo "::error::No versions are listed for the ${1} matrix."; exit 1; } - - read -ra versions <<< "$2" - - for wp in "${versions[@]}"; do - [[ "$wp" =~ ^([0-9]+)\.([0-9]+) ]] || continue - branch=$(( 10#${BASH_REMATCH[1]} * 10000 + 10#${BASH_REMATCH[2]} * 100 )) - - # A pre-release sorts just below its own branch, so 7.1-RC2 is tested against a target of 7.1 but - # not against 7.0.1. - if [[ "$wp" == *-* ]]; then - branch=$(( branch - 1 )) - fi - - if (( branch <= target )); then - kept+="\"${wp}\"," - fi - done - - echo "$1=[${kept%,}]" >> "$GITHUB_OUTPUT" - } - - filter recent-releases "$RECENT_RELEASES" - filter wp-6x "$WP_6X" - filter wp-5x-php-7x "$WP_5X_PHP_7X" - filter wp-5x-php-8x "$WP_5X_PHP_8X" - filter oldest-wp "$OLDEST_WP" - - # Downloads a release zip once for every matrix job, waiting until WordPress.org serves it. - download-wordpress: - name: Download WordPress - uses: $/.github/workflows/reusable-download-wordpress-release.yml - permissions: - contents: read - if: ${{ github.repository == 'WordPress/wordpress-develop' }} - with: - version: ${{ inputs.new-version && inputs.new-version || 'latest' }} - - # Tests the full list of PHP/MySQL combinations for the two most recent versions of WordPress. - upgrade-tests-recent-releases: - name: ${{ matrix.wp }} to ${{ inputs.new-version && inputs.new-version || 'latest' }} - uses: ./.github/workflows/reusable-upgrade-testing.yml - if: ${{ github.repository == 'WordPress/wordpress-develop' && needs.build-test-matrix.outputs.recent-releases != '[]' }} - needs: [ build-test-matrix, download-wordpress ] - permissions: - contents: read - strategy: - fail-fast: false - matrix: - os: [ 'ubuntu-26.04' ] - php: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5' ] - db-type: [ 'mysql' ] - db-version: [ '5.7', '8.0', '8.4', '9.7', '26.10' ] - wp: ${{ fromJSON( needs.build-test-matrix.outputs.recent-releases ) }} - multisite: [ false, true ] - with: - os: ${{ matrix.os }} - php: ${{ matrix.php }} - db-type: ${{ matrix.db-type }} - db-version: ${{ matrix.db-version }} - wp: ${{ matrix.wp }} - new-version: ${{ inputs.new-version && inputs.new-version || 'latest' }} - multisite: ${{ matrix.multisite }} - new-version-artifact: ${{ needs.download-wordpress.outputs.artifact }} - - # Tests 6.x releases where the WordPress database version changed on the oldest and newest supported versions of PHP 7 & 8. - upgrade-tests-wp-6x-mysql: - name: ${{ matrix.wp }} to ${{ inputs.new-version && inputs.new-version || 'latest' }} - uses: ./.github/workflows/reusable-upgrade-testing.yml - if: ${{ github.repository == 'WordPress/wordpress-develop' && needs.build-test-matrix.outputs.wp-6x != '[]' }} - needs: [ build-test-matrix, download-wordpress ] - permissions: - contents: read - strategy: - fail-fast: false - matrix: - os: [ 'ubuntu-26.04' ] - php: [ '7.4', '8.0', '8.4' ] - db-type: [ 'mysql' ] - db-version: [ '5.7', '8.4' ] - wp: ${{ fromJSON( needs.build-test-matrix.outputs.wp-6x ) }} - multisite: [ false, true ] - with: - os: ${{ matrix.os }} - php: ${{ matrix.php }} - db-type: ${{ matrix.db-type }} - db-version: ${{ matrix.db-version }} - wp: ${{ matrix.wp }} - new-version: ${{ inputs.new-version && inputs.new-version || 'latest' }} - multisite: ${{ matrix.multisite }} - new-version-artifact: ${{ needs.download-wordpress.outputs.artifact }} - - # Tests 5.x releases where the WordPress database version changed on the only supported version of PHP 7. - upgrade-tests-wp-5x-php-7x-mysql: - name: ${{ matrix.wp }} to ${{ inputs.new-version && inputs.new-version || 'latest' }} - uses: ./.github/workflows/reusable-upgrade-testing.yml - if: ${{ github.repository == 'WordPress/wordpress-develop' && needs.build-test-matrix.outputs.wp-5x-php-7x != '[]' }} - needs: [ build-test-matrix, download-wordpress ] - permissions: - contents: read - strategy: - fail-fast: false - matrix: - os: [ 'ubuntu-26.04' ] - php: [ '7.4' ] - db-type: [ 'mysql' ] - db-version: [ '5.7', '8.4' ] - wp: ${{ fromJSON( needs.build-test-matrix.outputs.wp-5x-php-7x ) }} - multisite: [ false, true ] - with: - os: ${{ matrix.os }} - php: ${{ matrix.php }} - db-type: ${{ matrix.db-type }} - db-version: ${{ matrix.db-version }} - wp: ${{ matrix.wp }} - new-version: ${{ inputs.new-version && inputs.new-version || 'latest' }} - multisite: ${{ matrix.multisite }} - new-version-artifact: ${{ needs.download-wordpress.outputs.artifact }} - - # Tests 5.x releases where the WordPress database version changed on the oldest and newest supported versions of PHP 8. - # - # WordPress 5.0-5.2 are excluded from PHP 8+ testing because of the following fatal errors: - # - Use of __autoload(). - # - array/string offset with curly braces. - upgrade-tests-wp-5x-php-8x-mysql: - name: ${{ matrix.wp }} to ${{ inputs.new-version && inputs.new-version || 'latest' }} - uses: ./.github/workflows/reusable-upgrade-testing.yml - if: ${{ github.repository == 'WordPress/wordpress-develop' && needs.build-test-matrix.outputs.wp-5x-php-8x != '[]' }} - needs: [ build-test-matrix, download-wordpress ] - permissions: - contents: read - strategy: - fail-fast: false - matrix: - os: [ 'ubuntu-26.04' ] - php: [ '8.0', '8.4' ] - db-type: [ 'mysql' ] - db-version: [ '5.7', '8.4' ] - wp: ${{ fromJSON( needs.build-test-matrix.outputs.wp-5x-php-8x ) }} - multisite: [ false, true ] - with: - os: ${{ matrix.os }} - php: ${{ matrix.php }} - db-type: ${{ matrix.db-type }} - db-version: ${{ matrix.db-version }} - wp: ${{ matrix.wp }} - new-version: ${{ inputs.new-version && inputs.new-version || 'latest' }} - multisite: ${{ matrix.multisite }} - new-version-artifact: ${{ needs.download-wordpress.outputs.artifact }} - - # The oldest version of WordPress receiving security updates should always be tested against - # the widest possible list of PHP/MySQL combinations. - # - # WordPress 4.7 is excluded from PHP 8+ testing because of the following fatal errors: - # - Use of __autoload(). - # - array/string offset with curly braces. - upgrade-tests-oldest-wp-mysql: - name: ${{ matrix.wp }} to ${{ inputs.new-version && inputs.new-version || 'latest' }} - uses: ./.github/workflows/reusable-upgrade-testing.yml - if: ${{ github.repository == 'WordPress/wordpress-develop' && needs.build-test-matrix.outputs.oldest-wp != '[]' }} - needs: [ build-test-matrix, download-wordpress ] - permissions: - contents: read - strategy: - fail-fast: false - matrix: - os: [ 'ubuntu-26.04' ] - php: [ '7.4' ] - db-type: [ 'mysql' ] - db-version: [ '5.7', '8.0', '8.4', '9.7', '26.10' ] - wp: ${{ fromJSON( needs.build-test-matrix.outputs.oldest-wp ) }} - multisite: [ false, true ] - with: - os: ${{ matrix.os }} - php: ${{ matrix.php }} - db-type: ${{ matrix.db-type }} - db-version: ${{ matrix.db-version }} - wp: ${{ matrix.wp }} - new-version: ${{ inputs.new-version && inputs.new-version || 'latest' }} - multisite: ${{ matrix.multisite }} - new-version-artifact: ${{ needs.download-wordpress.outputs.artifact }} - - slack-notifications: - name: Slack Notifications - uses: ./.github/workflows/slack-notifications.yml - permissions: - actions: read - contents: read - needs: [ build-test-matrix, download-wordpress, upgrade-tests-recent-releases, upgrade-tests-wp-6x-mysql, upgrade-tests-wp-5x-php-7x-mysql, upgrade-tests-wp-5x-php-8x-mysql, upgrade-tests-oldest-wp-mysql ] - if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }} - with: - calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }} - version: ${{ inputs.new-version && inputs.new-version || 'latest' }} - secrets: - SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }} - SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }} - SLACK_GHA_FIXED_WEBHOOK: ${{ secrets.SLACK_GHA_FIXED_WEBHOOK }} - SLACK_GHA_FAILURE_WEBHOOK: ${{ secrets.SLACK_GHA_FAILURE_WEBHOOK }} - - failed-workflow: - name: Failed workflow tasks - runs-on: ubuntu-26.04 - permissions: - actions: write - needs: [ slack-notifications ] - if: | - always() && - github.repository == 'WordPress/wordpress-develop' && - github.event_name != 'pull_request' && - github.run_attempt < 2 && - ( - contains( needs.*.result, 'cancelled' ) || - contains( needs.*.result, 'failure' ) - ) - - steps: - - name: Dispatch workflow run - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 - with: - retries: 2 - retry-exempt-status-codes: 418 - script: | - github.rest.actions.createWorkflowDispatch({ - owner: context.repo.owner, - repo: context.repo.repo, - workflow_id: 'failed-workflow.yml', - ref: 'trunk', - inputs: { - run_id: `${context.runId}`, - } - }); diff --git a/.github/workflows/workflow-lint.yml b/.github/workflows/workflow-lint.yml index ea58b4cb50980..8571d78304284 100644 --- a/.github/workflows/workflow-lint.yml +++ b/.github/workflows/workflow-lint.yml @@ -34,7 +34,7 @@ permissions: {} jobs: lint: name: Lint GitHub Action files - uses: ./.github/workflows/reusable-workflow-lint.yml + uses: WordPress/wordpress-develop/.github/workflows/reusable-workflow-lint.yml@trunk if: | github.repository == 'WordPress/wordpress-develop' || ( github.event_name == 'pull_request' && ( @@ -50,7 +50,7 @@ jobs: slack-notifications: name: Slack Notifications - uses: ./.github/workflows/slack-notifications.yml + uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk permissions: actions: read contents: read diff --git a/docker-compose.yml b/docker-compose.yml index 62bce43174293..5fd775d7ad8ef 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -34,7 +34,7 @@ services: # The PHP container. ## php: - image: wordpressdevelop/php:${LOCAL_PHP-latest} + image: wordpressdevelop/php:${LOCAL_PHP-8.6-fpm} networks: - wpdevnet @@ -80,7 +80,7 @@ services: # The MySQL container. ## mysql: - image: ${LOCAL_DB_TYPE-mysql}:${LOCAL_DB_VERSION-latest} + image: ${LOCAL_DB_TYPE-mysql}:${LOCAL_DB_VERSION-9.7} networks: - wpdevnet @@ -112,7 +112,7 @@ services: # The WP CLI container. ## cli: - image: wordpressdevelop/cli:${LOCAL_PHP-latest} + image: wordpressdevelop/cli:${LOCAL_PHP-8.6-fpm} networks: - wpdevnet