From ada7891e07b46dbf8e7a907c32300b486d471093 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Fri, 7 Jun 2024 13:05:07 -0400 Subject: [PATCH 01/15] Update to Docker Compose v2. --- tools/local-env/scripts/docker.js | 4 ++-- tools/local-env/scripts/install.js | 4 ++-- tools/local-env/scripts/start.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/local-env/scripts/docker.js b/tools/local-env/scripts/docker.js index 60cb305b7f498..e4c382140a498 100644 --- a/tools/local-env/scripts/docker.js +++ b/tools/local-env/scripts/docker.js @@ -4,5 +4,5 @@ const { execSync } = require( 'child_process' ); dotenvExpand( dotenv.config() ); -// Execute any docker-compose command passed to this script. -execSync( 'docker-compose ' + process.argv.slice( 2 ).join( ' ' ), { stdio: 'inherit' } ); +// Execute any docker compose command passed to this script. +execSync( 'docker compose ' + process.argv.slice( 2 ).join( ' ' ), { stdio: 'inherit' } ); diff --git a/tools/local-env/scripts/install.js b/tools/local-env/scripts/install.js index 2bce37b03bd6d..5b60d4c11ab26 100644 --- a/tools/local-env/scripts/install.js +++ b/tools/local-env/scripts/install.js @@ -45,7 +45,7 @@ wait_on( { resources: [ `tcp:localhost:${process.env.LOCAL_PORT}`] } ) * @param {string} cmd The WP-CLI command to run. */ function wp_cli( cmd ) { - execSync( `docker-compose run --rm cli ${cmd}`, { stdio: 'inherit' } ); + execSync( `docker compose run --rm cli ${cmd}`, { stdio: 'inherit' } ); } /** @@ -54,5 +54,5 @@ function wp_cli( cmd ) { function install_wp_importer() { const test_plugin_directory = 'tests/phpunit/data/plugins/wordpress-importer'; - execSync( `docker-compose exec -T php rm -rf ${test_plugin_directory} && svn checkout -r ${process.env.WP_IMPORTER_REVISION} https://plugins.svn.wordpress.org/wordpress-importer/trunk/ ${test_plugin_directory}`, { stdio: 'inherit' } ); + execSync( `docker compose exec -T php rm -rf ${test_plugin_directory} && svn checkout -r ${process.env.WP_IMPORTER_REVISION} https://plugins.svn.wordpress.org/wordpress-importer/trunk/ ${test_plugin_directory}`, { stdio: 'inherit' } ); } diff --git a/tools/local-env/scripts/start.js b/tools/local-env/scripts/start.js index cf184354507ef..c8131037d6a8f 100644 --- a/tools/local-env/scripts/start.js +++ b/tools/local-env/scripts/start.js @@ -5,7 +5,7 @@ const { execSync } = require( 'child_process' ); dotenvExpand( dotenv.config() ); // Start the local-env containers. -execSync( 'docker-compose up -d wordpress-develop', { stdio: 'inherit' } ); +execSync( 'docker compose up -d wordpress-develop', { stdio: 'inherit' } ); // If Docker Toolbox is being used, we need to manually forward LOCAL_PORT to the Docker VM. if ( process.env.DOCKER_TOOLBOX_INSTALL_PATH ) { From a275d593095e3edcefdf2e6b259c5c0ad5df0cd6 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Fri, 7 Jun 2024 13:05:24 -0400 Subject: [PATCH 02/15] Make Coding Standards reusable. --- .github/workflows/coding-standards.yml | 106 ++++--------------------- 1 file changed, 17 insertions(+), 89 deletions(-) diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 36b0135d41e8e..7effa3838b8c3 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -40,109 +40,35 @@ concurrency: group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || 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: # Runs PHP coding standards checks. - # - # Violations are reported inline with annotations. - # - # Performs the following steps: - # - Checks out the repository. - # - Sets up PHP. - # - Logs debug information. - # - Installs Composer dependencies (use cache if possible). - # - Make Composer packages available globally. - # - Logs PHP_CodeSniffer debug information. - # - Runs PHPCS on the full codebase with warnings suppressed. - # - Runs PHPCS on the `tests` directory without warnings suppressed. phpcs: name: PHP coding standards - runs-on: ubuntu-latest - timeout-minutes: 20 + uses: WordPress/wordpress-develop/.github/workflows/reusable-coding-standards-php.yml@trunk + permissions: + contents: read if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} - - steps: - - name: Checkout repository - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - - - name: Set up PHP - uses: shivammathur/setup-php@d30ad8b1843ace22e6698ab99bbafaa747b6bd0d # v2.24.0 - with: - php-version: '7.4' - coverage: none - tools: composer, cs2pr - - - name: Log debug information - run: | - php --version - composer --version - - - name: Install Composer dependencies - uses: ramsey/composer-install@83af392bf5f031813d25e6fe4cd626cdba9a2df6 # v2.2.0 - with: - composer-options: "--no-progress --no-ansi" - - - name: Make Composer packages available globally - run: echo "${PWD}/vendor/bin" >> $GITHUB_PATH - - - name: Log PHPCS debug information - run: phpcs -i - - - name: Run PHPCS on all Core files - run: phpcs -q -n --report=checkstyle | cs2pr - - - name: Check test suite files for warnings - run: phpcs tests -q --report=checkstyle | cs2pr + with: + php-version: '7.4' # Runs the JavaScript coding standards checks. - # - # JSHint violations are not currently reported inline with annotations. - # - # Performs the following steps: - # - Checks out the repository. - # - Logs debug information about the GitHub Action runner. - # - Installs Node.js. - # - Logs updated debug information. - # _ Installs npm dependencies. - # - Run the WordPress JSHint checks. jshint: name: JavaScript coding standards - runs-on: ubuntu-latest - timeout-minutes: 20 + uses: WordPress/wordpress-develop/.github/workflows/reusable-coding-standards-javascript.yml@trunk + permissions: + contents: read if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} - env: - PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: ${{ true }} - - steps: - - name: Checkout repository - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - - - name: Log debug information - run: | - npm --version - node --version - git --version - svn --version - - - name: Install Node.js - uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 - with: - node-version-file: '.nvmrc' - cache: npm - - - name: Log debug information - run: | - npm --version - node --version - - - name: Install Dependencies - run: npm ci - - - name: Run JSHint - run: npm run grunt jshint slack-notifications: name: Slack Notifications uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk + permissions: + actions: read + contents: read needs: [ phpcs, jshint ] if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }} with: @@ -156,6 +82,8 @@ jobs: failed-workflow: name: Failed workflow tasks runs-on: ubuntu-latest + permissions: + actions: write needs: [ phpcs, jshint, slack-notifications ] if: | always() && From 7e8e71cf0cbb0c7b2c8628b3e93ed74726b9ace1 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Fri, 7 Jun 2024 13:05:44 -0400 Subject: [PATCH 03/15] Make JavaScript testing reusable. --- .github/workflows/javascript-tests.yml | 50 +++++++------------------- 1 file changed, 12 insertions(+), 38 deletions(-) diff --git a/.github/workflows/javascript-tests.yml b/.github/workflows/javascript-tests.yml index cde2a884ab843..a881b8e6fa2be 100644 --- a/.github/workflows/javascript-tests.yml +++ b/.github/workflows/javascript-tests.yml @@ -38,53 +38,25 @@ concurrency: group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || 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: # Runs the QUnit tests for WordPress. - # - # Performs the following steps: - # - Checks out the repository. - # - Logs debug information about the GitHub Action runner. - # - Installs Node.js. - # - Logs updated debug information. - # _ Installs npm dependencies. - # - Run the WordPress QUnit tests. test-js: name: QUnit Tests - runs-on: ubuntu-latest - timeout-minutes: 20 + uses: WordPress/wordpress-develop/.github/workflows/reusable-javascript-tests.yml@trunk + permissions: + contents: read if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} - steps: - - name: Checkout repository - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - - - name: Log debug information - run: | - npm --version - node --version - git --version - svn --version - - - name: Set up Node.js - uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 - with: - node-version-file: '.nvmrc' - cache: npm - - - name: Log debug information - run: | - npm --version - node --version - - - name: Install Dependencies - run: npm ci - - - name: Run QUnit tests - run: npm run grunt qunit:compiled - slack-notifications: name: Slack Notifications uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk + permissions: + actions: read + contents: read needs: [ test-js ] if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }} with: @@ -98,6 +70,8 @@ jobs: failed-workflow: name: Failed workflow tasks runs-on: ubuntu-latest + permissions: + actions: write needs: [ test-js, slack-notifications ] if: | always() && From c70bbd5541ea20a02bdbedd71f105baa84de1ed4 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Fri, 7 Jun 2024 13:37:17 -0400 Subject: [PATCH 04/15] Make PHP compatibility reusable. --- .github/workflows/php-compatibility.yml | 60 +++++++------------------ 1 file changed, 15 insertions(+), 45 deletions(-) diff --git a/.github/workflows/php-compatibility.yml b/.github/workflows/php-compatibility.yml index 792c14d7251a6..0a501e05baa76 100644 --- a/.github/workflows/php-compatibility.yml +++ b/.github/workflows/php-compatibility.yml @@ -22,7 +22,7 @@ on: - '**.php' # These files configure Composer. Changes could affect the outcome. - 'composer.*' - # This file configures PHP Compatibility scanning. Changes could affect the outcome. + # This file configures PHP compatibility scanning. Changes could affect the outcome. - 'phpcompat.xml.dist' # Changes to workflow files should always verify all workflows are successful. - '.github/workflows/*.yml' @@ -35,59 +35,27 @@ concurrency: group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} cancel-in-progress: true -jobs: +# Disable permissions for all available scopes by default. +# Any needed permissions should be configured at the job level. +permissions: {} +jobs: # Runs PHP compatibility testing. - # - # Violations are reported inline with annotations. - # - # Performs the following steps: - # - Checks out the repository. - # - Sets up PHP. - # - Logs debug information about the GitHub Action runner. - # - Installs Composer dependencies (use cache if possible). - # - Make Composer packages available globally. - # - Logs PHP_CodeSniffer debug information. - # - Runs the PHP compatibility tests. php-compatibility: name: Check PHP compatibility - runs-on: ubuntu-latest - timeout-minutes: 20 + uses: WordPress/wordpress-develop/.github/workflows/reusable-php-compatibility.yml@trunk + permissions: + contents: read if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} - - steps: - - name: Checkout repository - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - - - name: Set up PHP - uses: shivammathur/setup-php@d30ad8b1843ace22e6698ab99bbafaa747b6bd0d # v2.24.0 - with: - php-version: '7.4' - coverage: none - tools: composer, cs2pr - - - name: Log debug information - run: | - php --version - composer --version - - - name: Install Composer dependencies - uses: ramsey/composer-install@83af392bf5f031813d25e6fe4cd626cdba9a2df6 # v2.2.0 - with: - composer-options: "--no-progress --no-ansi" - - - name: Make Composer packages available globally - run: echo "${PWD}/vendor/bin" >> $GITHUB_PATH - - - name: Log PHPCS debug information - run: phpcs -i - - - name: Run PHP compatibility tests - run: phpcs --standard=phpcompat.xml.dist -q --report=checkstyle | cs2pr + with: + php-version: '7.4' slack-notifications: name: Slack Notifications uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk + permissions: + actions: read + contents: read needs: [ php-compatibility ] if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }} with: @@ -101,6 +69,8 @@ jobs: failed-workflow: name: Failed workflow tasks runs-on: ubuntu-latest + permissions: + actions: write needs: [ php-compatibility, slack-notifications ] if: | always() && From 1e4e4ca08314b7e536fd3edfe5d58a0f3982876f Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Fri, 7 Jun 2024 13:38:09 -0400 Subject: [PATCH 05/15] Account for caching in PHPCS scans. --- .gitignore | 1 + phpcompat.xml.dist | 2 +- phpcs.xml.dist | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 2eca5aa47e73e..c1ccc55f72551 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ wp-tests-config.php /phpunit.xml /.phpcs.xml /phpcs.xml +.cache/* /tests/phpunit/data/plugins/wordpress-importer /tests/phpunit/data/.trac-ticket-cache* /tests/qunit/compiled.html diff --git a/phpcompat.xml.dist b/phpcompat.xml.dist index 5af8e2a5039ae..47760305a9676 100644 --- a/phpcompat.xml.dist +++ b/phpcompat.xml.dist @@ -11,7 +11,7 @@ - + - +