From 91f06068abe5a1f5ddd341a73b6fdca7f88ad882 Mon Sep 17 00:00:00 2001 From: Anton Vlasenko Date: Thu, 30 Mar 2023 21:02:41 +0200 Subject: [PATCH] 1. Remove the Unit Tests workflow and the unit-test.yml file. 2. Move the PHPUnit CI job from unit-test.yml to phpunit-tests.yml. 3. Move the JavaScript Tests from unit-test.yml to javascript-tests.yml. 4. Rename the Static Analysis (Linting, License, Type checks...) workflow to Coding Standards and move it to coding-standards.yml. 5. Move the PHP coding standards job from unit-tests.yml to coding-standards.yml. 6. Rename the All job to JavaScript coding standards and move it to coding-standards.yml. 7. Rename the JavaScript job to Jest Tests. 8. Change the composer versions of squizlabs/php_codesniffer, phpcompatibility/phpcompatibility-wp, and wp-coding-standards/wpcs to use the same package versions as in Core. --- .github/workflows/coding-standards.yml | 107 +++++++++++ .github/workflows/javascript-tests.yml | 71 +++++++ .github/workflows/php-compatibility.yml | 72 +++++++ .github/workflows/phpunit-tests.yml | 126 +++++++++++++ .github/workflows/static-checks.yml | 52 ----- .github/workflows/unit-test.yml | 240 ------------------------ composer.json | 7 +- phpcompat.xml.dist | 40 ++++ phpcs.xml.dist | 19 +- 9 files changed, 436 insertions(+), 298 deletions(-) create mode 100644 .github/workflows/coding-standards.yml create mode 100644 .github/workflows/javascript-tests.yml create mode 100644 .github/workflows/php-compatibility.yml create mode 100644 .github/workflows/phpunit-tests.yml delete mode 100644 .github/workflows/static-checks.yml delete mode 100644 .github/workflows/unit-test.yml create mode 100644 phpcompat.xml.dist diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml new file mode 100644 index 0000000000000..e2fd274b6ab89 --- /dev/null +++ b/.github/workflows/coding-standards.yml @@ -0,0 +1,107 @@ +name: Coding Standards + +on: + pull_request: + push: + branches: + - trunk + - 'release/**' + - 'wp/**' + # 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 branch name for pull requests + # or the commit hash for any other events. + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + +jobs: + # Runs PHP coding standards checks. + # + # Violations are reported inline with annotations. + phpcs: + name: PHP coding standards + runs-on: ubuntu-latest + timeout-minutes: 20 + if: ${{ github.repository == 'WordPress/gutenberg' || 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: 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@6998d139ddd3e68c71e9e398d8e40b71a2f39812 # v3.2.5 + with: + path: .cache/phpcs.json + key: ${{ runner.os }}-date-${{ steps.get-date.outputs.date }}-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@83af392bf5f031813d25e6fe4cd626cdba9a2df6 # v2.2.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 Gutenberg files + id: phpcs-gutenberg + run: phpcs --report-full --report-checkstyle=./.cache/phpcs-report.xml + + - name: Show PHPCS results in PR + if: ${{ always() && steps.phpcs-gutenberg.outcome == 'failure' }} + run: cs2pr ./.cache/phpcs-report.xml + + - name: Ensure version-controlled files are not modified during the tests + run: git diff --exit-code + + check: + name: JavaScript coding standards + runs-on: ubuntu-latest + if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }} + + steps: + - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 + + - name: Use desired version of Node.js + uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 + with: + node-version-file: '.nvmrc' + cache: npm + + - name: Npm install + # A "full" install is executed, since `npm ci` does not always exit + # with an error status code if the lock file is inaccurate. This also + # helps to catch dependencies not being installed with exact version. + # + # See: https://github.com/WordPress/gutenberg/issues/16157 + # See: https://github.com/WordPress/gutenberg/pull/39865 + run: npm install + + - name: Lint JavaScript and Styles + run: npm run lint + + - name: Type checking + run: npm run build:package-types + + - name: Check local changes + run: npm run other:check-local-changes + + - name: License compatibility + run: npm run other:check-licenses diff --git a/.github/workflows/javascript-tests.yml b/.github/workflows/javascript-tests.yml new file mode 100644 index 0000000000000..313983d4996f5 --- /dev/null +++ b/.github/workflows/javascript-tests.yml @@ -0,0 +1,71 @@ +name: JavaScript Tests + +# Since Unit Tests are required to pass for each PR, +# we cannot disable them for documentation-only changes. +on: + pull_request: + push: + branches: + - trunk + - 'release/**' + - 'wp/**' + # 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 branch name for pull requests + # or the commit hash for any other events. + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + +jobs: + unit-js: + name: Jest Tests + runs-on: ubuntu-latest + if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }} + + strategy: + fail-fast: false + matrix: + node: ['14'] + + steps: + - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 + + - name: Setup Node.js and install dependencies + uses: ./.github/setup-node + with: + node-version: ${{ matrix.node }} + + - name: Npm build + # It's not necessary to run the full build, since Jest can interpret + # source files with `babel-jest`. Some packages have their own custom + # build tasks, however. These must be run. + run: npx lerna run build + + - name: Running the tests + run: npm run test:unit -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache" + + - name: Running the date tests + run: npm run test:unit:date -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache" + + mobile-unit-js: + name: Mobile + runs-on: ubuntu-latest + if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }} + + steps: + - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 + + - name: Setup Node.js and install dependencies + uses: ./.github/setup-node + + - name: Npm build + # It's not necessary to run the full build, since Jest can interpret + # source files with `babel-jest`. Some packages have their own custom + # build tasks, however. These must be run. + run: npx lerna run build + + - name: Running the tests + run: npm run native test -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache" diff --git a/.github/workflows/php-compatibility.yml b/.github/workflows/php-compatibility.yml new file mode 100644 index 0000000000000..4eae1c6943ab0 --- /dev/null +++ b/.github/workflows/php-compatibility.yml @@ -0,0 +1,72 @@ +name: PHP Compatibility + +on: + pull_request: + push: + branches: + - trunk + - 'release/**' + - 'wp/**' + # 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 branch name for pull requests + # or the commit hash for any other events. + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + +jobs: + # Runs PHP compatibility testing. + # + # Violations are reported inline with annotations. + php-compatibility: + name: Check PHP compatibility + runs-on: ubuntu-latest + timeout-minutes: 20 + if: ${{ github.repository == 'WordPress/gutenberg' || 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: cs2pr + + # 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@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 # v3.0.11 + with: + path: .cache/phpcompat.json + key: ${{ runner.os }}-date-${{ steps.get-date.outputs.date }}-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@83af392bf5f031813d25e6fe4cd626cdba9a2df6 # v2.2.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 --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 during the tests + run: git diff --exit-code diff --git a/.github/workflows/phpunit-tests.yml b/.github/workflows/phpunit-tests.yml new file mode 100644 index 0000000000000..4e3d01046d055 --- /dev/null +++ b/.github/workflows/phpunit-tests.yml @@ -0,0 +1,126 @@ +name: PHPUnit Tests + +# Since Unit Tests are required to pass for each PR, +# we cannot disable them for documentation-only changes. +on: + pull_request: + push: + branches: + - trunk + - 'release/**' + - 'wp/**' + # 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 branch name for pull requests + # or the commit hash for any other events. + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + +jobs: + test-php: + name: PHP ${{ matrix.php }}${{ matrix.multisite && ' multisite' || '' }} on ubuntu-latest + runs-on: ubuntu-latest + timeout-minutes: 20 + if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }} + strategy: + fail-fast: true + matrix: + php: + - '5.6' + - '7.0' + - '7.1' + - '7.2' + - '7.3' + - '7.4' + - '8.0' + - '8.1' + - '8.2' + multisite: [false, true] + + env: + WP_ENV_PHP_VERSION: ${{ matrix.php }} + + steps: + - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + + - name: Set up Node.js + uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 + with: + node-version-file: '.nvmrc' + cache: 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@d30ad8b1843ace22e6698ab99bbafaa747b6bd0d # v2.24.0 + with: + php-version: '${{ matrix.php }}' + ini-file: development + coverage: none + + # Ensure that Composer installs the correct versions of packages. + - name: Override PHP version in composer.json + run: composer config platform.php ${{ matrix.php }} + + # The spatie/phpunit-watcher package is not compatible with PHP < 7.2. + # It must be removed before running the tests. + - name: Remove incompatible Composer packages + if: ${{ matrix.php < '7.2' }} + run: composer remove spatie/phpunit-watcher --dev --no-update + + # 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@83af392bf5f031813d25e6fe4cd626cdba9a2df6 # v2.2.0 + with: + custom-cache-suffix: $(/bin/date -u --date='last Mon' "+%F") + + - name: Install npm dependencies + run: | + npm ci + npm run build + + - name: Docker debug information + run: | + docker -v + docker-compose -v + + - name: General debug information + run: | + npm --version + node --version + curl --version + git --version + svn --version + locale -a + + - name: Start Docker environment + run: npm run wp-env start + + - name: Log running Docker containers + run: docker ps -a + + - name: Docker container debug information + run: | + npm run wp-env run tests-mysql "mysql --version" + npm run wp-env run tests-wordpress "php --version" + npm run wp-env run tests-wordpress "php -m" + npm run wp-env run tests-wordpress "php -i" + npm run wp-env run tests-wordpress "/var/www/html/wp-content/plugins/gutenberg/vendor/bin/phpunit --version" + npm run wp-env run tests-wordpress "locale -a" + + - name: Running single site unit tests + if: ${{ ! matrix.multisite }} + run: npm run test:unit:php + + - name: Running multisite unit tests + if: ${{ matrix.multisite }} + run: npm run test:unit:php:multisite diff --git a/.github/workflows/static-checks.yml b/.github/workflows/static-checks.yml deleted file mode 100644 index 3b457401560a8..0000000000000 --- a/.github/workflows/static-checks.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: Static Analysis (Linting, License, Type checks...) - -on: - pull_request: - push: - branches: - - trunk - - 'release/**' - - 'wp/**' - -# Cancels all previous workflow runs for pull requests that have not completed. -concurrency: - # The concurrency group contains the workflow name and the branch name for pull requests - # or the commit hash for any other events. - group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} - cancel-in-progress: true - -jobs: - check: - name: All - runs-on: ubuntu-latest - if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }} - - steps: - - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 - - - name: Use desired version of Node.js - uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 - with: - node-version-file: '.nvmrc' - cache: npm - - - name: Npm install - # A "full" install is executed, since `npm ci` does not always exit - # with an error status code if the lock file is inaccurate. This also - # helps to catch dependencies not being installed with exact version. - # - # See: https://github.com/WordPress/gutenberg/issues/16157 - # See: https://github.com/WordPress/gutenberg/pull/39865 - run: npm install - - - name: Lint JavaScript and Styles - run: npm run lint - - - name: Type checking - run: npm run build:package-types - - - name: Check local changes - run: npm run other:check-local-changes - - - name: License compatibility - run: npm run other:check-licenses diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml deleted file mode 100644 index acb7417ac78ff..0000000000000 --- a/.github/workflows/unit-test.yml +++ /dev/null @@ -1,240 +0,0 @@ -name: Unit Tests - -# Since Unit Tests are required to pass for each PR, -# we cannot disable them for documentation-only changes. -on: - pull_request: - push: - branches: - - trunk - - 'release/**' - - 'wp/**' - # 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 branch name for pull requests - # or the commit hash for any other events. - group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} - cancel-in-progress: true - -jobs: - unit-js: - name: JavaScript - runs-on: ubuntu-latest - if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }} - - strategy: - fail-fast: false - matrix: - node: ['14'] - - steps: - - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 - - - name: Setup Node.js and install dependencies - uses: ./.github/setup-node - with: - node-version: ${{ matrix.node }} - - - name: Npm build - # It's not necessary to run the full build, since Jest can interpret - # source files with `babel-jest`. Some packages have their own custom - # build tasks, however. These must be run. - run: npx lerna run build - - - name: Running the tests - run: npm run test:unit -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache" - - - name: Running the date tests - run: npm run test:unit:date -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache" - - test-php: - name: PHP ${{ matrix.php }}${{ matrix.multisite && ' multisite' || '' }} on ubuntu-latest - runs-on: ubuntu-latest - timeout-minutes: 20 - if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }} - strategy: - fail-fast: true - matrix: - php: - - '5.6' - - '7.0' - - '7.1' - - '7.2' - - '7.3' - - '7.4' - - '8.0' - - '8.1' - - '8.2' - multisite: [false, true] - - env: - WP_ENV_PHP_VERSION: ${{ matrix.php }} - - steps: - - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 - - - name: Setup Node.js and install dependencies - uses: ./.github/setup-node - - ## - # 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@d30ad8b1843ace22e6698ab99bbafaa747b6bd0d # v2.24.0 - with: - php-version: '${{ matrix.php }}' - ini-file: development - coverage: none - - # Ensure that Composer installs the correct versions of packages. - - name: Override PHP version in composer.json - run: composer config platform.php ${{ matrix.php }} - - # The spatie/phpunit-watcher package is not compatible with PHP < 7.2. - # It must be removed before running the tests. - - name: Remove incompatible Composer packages - if: ${{ matrix.php < '7.2' }} - run: composer remove spatie/phpunit-watcher --dev --no-update - - # 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@83af392bf5f031813d25e6fe4cd626cdba9a2df6 # v2.2.0 - with: - custom-cache-suffix: $(/bin/date -u --date='last Mon' "+%F") - - - name: Npm build - run: npm run build - - - name: Docker debug information - run: | - docker -v - docker-compose -v - - - name: General debug information - run: | - npm --version - node --version - curl --version - git --version - svn --version - locale -a - - - name: Start Docker environment - run: npm run wp-env start - - - name: Log running Docker containers - run: docker ps -a - - - name: Docker container debug information - run: | - npm run wp-env run tests-mysql "mysql --version" - npm run wp-env run tests-wordpress "php --version" - npm run wp-env run tests-wordpress "php -m" - npm run wp-env run tests-wordpress "php -i" - npm run wp-env run tests-wordpress "/var/www/html/wp-content/plugins/gutenberg/vendor/bin/phpunit --version" - npm run wp-env run tests-wordpress "locale -a" - - - name: Running single site unit tests - if: ${{ ! matrix.multisite }} - run: npm run test:unit:php - - - name: Running multisite unit tests - if: ${{ matrix.multisite }} - run: npm run test:unit:php:multisite - - phpcs: - name: PHP coding standards - runs-on: ubuntu-latest - timeout-minutes: 20 - if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }} - - steps: - - name: Checkout repository - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 - - - name: Set up PHP - uses: shivammathur/setup-php@d30ad8b1843ace22e6698ab99bbafaa747b6bd0d # v2.24.0 - with: - php-version: '7.4' - 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@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 - with: - path: .cache/phpcs.json - key: ${{ runner.os }}-date-${{ steps.get-date.outputs.date }}-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@83af392bf5f031813d25e6fe4cd626cdba9a2df6 # v2.2.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 Gutenberg files - id: phpcs-gutenberg - run: phpcs --report-full --report-checkstyle=./.cache/phpcs-report.xml - - - name: Show PHPCS results in PR - if: ${{ always() && steps.phpcs-gutenberg.outcome == 'failure' }} - run: cs2pr ./.cache/phpcs-report.xml - - - name: Ensure version-controlled files are not modified during the tests - run: git diff --exit-code - - # This job is deprecated but be present for compatibility reasons. - unit-php: - name: PHP - runs-on: ubuntu-latest - needs: [test-php, phpcs] - if: ${{ always() }} - steps: - - name: Fail the job if the PHPUnit tests fail - if: ${{ needs.test-php.result != 'success' }} - run: exit 1 - - - name: "Fail the job if the code doesn't conform to the coding standards" - if: ${{ needs.phpcs.result != 'success' }} - run: exit 1 - - - name: Mark the job as passed if all the checks pass - if: ${{ needs.test-php.result == 'success' && needs.phpcs.result == 'success' }} - run: exit 0 - - mobile-unit-js: - name: Mobile - runs-on: ubuntu-latest - if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }} - - steps: - - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 - - - name: Setup Node.js and install dependencies - uses: ./.github/setup-node - - - name: Npm build - # It's not necessary to run the full build, since Jest can interpret - # source files with `babel-jest`. Some packages have their own custom - # build tasks, however. These must be run. - run: npx lerna run build - - - name: Running the tests - run: npm run native test -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache" diff --git a/composer.json b/composer.json index 3f16ba495a94c..cb785056f9926 100644 --- a/composer.json +++ b/composer.json @@ -27,9 +27,9 @@ }, "require-dev": { "dealerdirect/phpcodesniffer-composer-installer": "^0.7", - "squizlabs/php_codesniffer": "^3.5", - "phpcompatibility/phpcompatibility-wp": "^2.1.3", - "wp-coding-standards/wpcs": "^2.2", + "squizlabs/php_codesniffer": "3.6.0", + "phpcompatibility/phpcompatibility-wp": "~2.1.3", + "wp-coding-standards/wpcs": "~2.3.0", "sirbrillig/phpcs-variable-analysis": "^2.8", "spatie/phpunit-watcher": "^1.23", "yoast/phpunit-polyfills": "^1.0" @@ -38,6 +38,7 @@ "composer/installers": "~1.0" }, "scripts": { + "compat": "phpcs --standard=phpcompat.xml.dist --report=full", "format": "phpcbf --standard=phpcs.xml.dist --report-summary --report-source", "lint": "phpcs --standard=phpcs.xml.dist", "test": "phpunit", diff --git a/phpcompat.xml.dist b/phpcompat.xml.dist new file mode 100644 index 0000000000000..9170d63e459f5 --- /dev/null +++ b/phpcompat.xml.dist @@ -0,0 +1,40 @@ + + + Apply PHP compatibility checks to all Gutenberg files + + + *\.php$ + + + + + + + + + + + + ./bin + ./gutenberg.php + ./lib + ./packages + ./phpunit + ./post-content.php + + + + + + + + + + + + + + diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 5520b6898f15a..1db060e3c2726 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -3,9 +3,6 @@ Sniffs for WordPress plugins, with minor modifications for Gutenberg - - *\.php$ - @@ -43,6 +40,22 @@ ./phpunit ./post-content.php + + + warning + + + warning + + + warning + + + + ./packages/block-serialization-spec-parser/parser.php