Skip to content

Commit

Permalink
Merge pull request #772 from Automattic/release/2.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
GaryJones authored Aug 24, 2023
2 parents 6cd0a6a + ef8d4b3 commit b8610e3
Showing 107 changed files with 550 additions and 463 deletions.
16 changes: 8 additions & 8 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -4,14 +4,14 @@
# If you develop for VIPCS using Composer, use `--prefer-source`.
# https://blog.madewithlove.be/post/gitattributes/
#
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.phpcs.xml.dist export-ignore
/phpunit.xml.dist export-ignore
/.github export-ignore
/bin export-ignore
/tests export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.phpcs.xml.dist export-ignore
/phpunit.xml.dist export-ignore
/.github export-ignore
/bin export-ignore
/tests export-ignore
/WordPressVIPMinimum/Tests export-ignore

#
14 changes: 8 additions & 6 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -34,11 +34,13 @@ This package contains Composer scripts to quickly run the developer checks which

After `composer install`, you can do:

- `composer test`: **Run all checks and tests** - this should pass cleanly before you submit a pull request.
- `composer lint`: Just run PHP and XML linters.
- `composer phpcs`: Just run PHPCS against this package.
- `composer phpunit`: Just run the unit tests.
- `composer ruleset`: Just run the ruleset tests.
- `composer lint`: Lint PHP and XML files in against parse errors.
- `composer cs`: Check the code style and code quality of the codebase via PHPCS.
- `composer test`: Run the unit tests for the VIPCS sniffs.
- `composer test-coverage`: Run the unit tests for the VIPCS sniffs with coverage enabled.
- `composer test-ruleset`: Run the ruleset tests for the VIPCS sniffs.
- `composer feature-completeness`: Check if all the VIPCS sniffs have tests.
- `composer check`: Run all checks (lint, CS, feature completeness) and tests - this should pass cleanly before you submit a pull request.

## Branches

@@ -190,7 +192,7 @@ The ruleset tests, previously named here as _integration tests_, are our way of

An example where it might not would be when a ruleset references a local sniff or a sniff from upstream (WPCS or PHPCS), but that the violation code, sniff name or category name has changed. Without a ruleset test, this would go unnoticed.

The `composer test` or `composer ruleset` commands run the `ruleset-test.php` files (one for each standard), which internally run `phpcs` against the "dirty" test files (`ruleset-test.inc`), and looks out for a known number of errors, warnings, and messages on each line. This is then compared against the expected errors, warnings and messages to see if there are any missing or unexpected violations or difference in messages.
The `composer check` or `composer test-ruleset` commands run the `ruleset-test.php` files (one for each standard), which internally run `phpcs` against the "dirty" test files (`ruleset-test.inc`), and looks out for a known number of errors, warnings, and messages on each line. This is then compared against the expected errors, warnings and messages to see if there are any missing or unexpected violations or difference in messages.

When adding or changing a sniff, the ruleset test files should be updated to match.

12 changes: 7 additions & 5 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -40,11 +40,13 @@ e.g. `WordPressVIPMinimum.PHP.NoSilencedErrors.Discouraged`

Use `php -v` and `composer show` to get versions.

| Question | Answer
| ------------------------| -------
| PHP version | x.y.z
| PHP_CodeSniffer version | x.y.z
| VIPCS version | x.y.z
| Question | Answer
| ------------------------ | -------
| PHP version | x.y.z
| PHP_CodeSniffer version | x.y.z
| VIPCS version | x.y.z
| WordPressCS version | x.y.z
| VariableAnalysis version | x.y.z

## Additional Context (optional)

25 changes: 19 additions & 6 deletions .github/workflows/basics.yml
Original file line number Diff line number Diff line change
@@ -7,17 +7,24 @@ on:
paths-ignore:
- '**.md'
pull_request:

# Allow manually triggering the workflow.
workflow_dispatch:

# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
checkcs:
name: 'Basic CS and QA checks'
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Install PHP
uses: shivammathur/setup-php@v2
@@ -27,7 +34,9 @@ jobs:
tools: cs2pr

- name: Install xmllint
run: sudo apt-get install --no-install-recommends -y libxml2-utils
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y libxml2-utils
# Show XML violations inline in the file diff.
# @link https://github.com/marketplace/actions/xmllint-problem-matcher
@@ -40,26 +49,30 @@ jobs:

- name: 'Composer: adjust dependencies'
# Using PHPCS `master` as an early detection system for bugs upstream.
run: composer require --no-update --no-scripts squizlabs/php_codesniffer:"dev-master"
run: composer require --no-update --no-scripts squizlabs/php_codesniffer:"dev-master" --no-interaction

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
- name: Install Composer dependencies
uses: "ramsey/composer-install@v1"
uses: "ramsey/composer-install@v2"
with:
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")

- name: 'Validate XML against schema and check code style'
run: ./bin/xml-lint

# Check the code-style consistency of the PHP files.
- name: Check PHP code style
continue-on-error: true
id: phpcs
run: vendor/bin/phpcs --report-full --report-checkstyle=./phpcs-report.xml

- name: Show PHPCS results in PR
if: ${{ always() && steps.phpcs.outcome == 'failure' }}
run: cs2pr ./phpcs-report.xml

# Check that the sniffs available are feature complete.
# For now, just check that all sniffs have unit tests.
# At a later stage the documentation check can be activated.
- name: Check sniff feature completeness
run: composer check-complete
run: composer feature-completeness
41 changes: 27 additions & 14 deletions .github/workflows/quicktest.yml
Original file line number Diff line number Diff line change
@@ -10,6 +10,12 @@ on:
# Allow manually triggering the workflow.
workflow_dispatch:

# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
#### QUICK TEST STAGE ####
# This is a much quicker test which only runs the unit tests and linting against the low/high
@@ -24,60 +30,67 @@ jobs:
phpcs_version: 'dev-master'
wpcs_version: '2.3.*'
- php: '5.4'
phpcs_version: '3.5.5'
phpcs_version: '3.7.1'
wpcs_version: '2.3.*'

- php: 'latest'
phpcs_version: 'dev-master'
wpcs_version: '2.3.*'
- php: 'latest'
# PHPCS 3.5.7 is the lowest version of PHPCS which supports PHP 8.0.
phpcs_version: '3.5.7'
phpcs_version: '3.7.1'
wpcs_version: '2.3.*'

name: "QTest${{ matrix.phpcs_version == 'dev-master' && ' + Lint' || '' }}: PHP ${{ matrix.php }} - PHPCS ${{ matrix.phpcs_version }}"


steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

# On stable PHPCS versions, allow for PHP deprecation notices.
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
# Note: the "elif" condition is temporary and should be removed once VIPCS updates to WPCS 3.0+.
- name: Setup ini config
id: set_ini
run: |
if [[ "${{ matrix.phpcs_version }}" != "dev-master" ]]; then
echo '::set-output name=PHP_INI::error_reporting=E_ALL & ~E_DEPRECATED'
echo 'PHP_INI=error_reporting=E_ALL & ~E_DEPRECATED, display_errors=On' >> $GITHUB_OUTPUT
else
echo '::set-output name=PHP_INI::error_reporting=E_ALL'
echo 'PHP_INI=error_reporting=-1, display_errors=On' >> $GITHUB_OUTPUT
fi
- name: Install PHP
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
ini-values: ${{ steps.set_ini.outputs.PHP_INI }}
coverage: none

- name: 'Composer: set PHPCS and WPCS versions for tests'
run: |
composer require --no-update --no-scripts squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}"
composer require --no-update --no-scripts wp-coding-standards/wpcs:"${{ matrix.wpcs_version }}"
- name: 'Composer: set PHPCS version for tests'
run: composer require squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-update --no-scripts --no-interaction

- name: 'Composer: set WPCS version for tests'
run: composer require wp-coding-standards/wpcs:"${{ matrix.wpcs_version }}" --no-update --no-scripts --no-interaction

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
- name: Install Composer dependencies - normal
if: ${{ startsWith( matrix.php, '8' ) == false && matrix.php != 'latest' }}
uses: "ramsey/composer-install@v1"
uses: "ramsey/composer-install@v2"
with:
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")

# PHPUnit 7.x does not allow for installation on PHP 8, so ignore platform
# requirements to get PHPUnit 7.x to install on nightly.
- name: Install Composer dependencies - with ignore platform
if: ${{ startsWith( matrix.php, '8' ) || matrix.php == 'latest' }}
uses: "ramsey/composer-install@v1"
uses: "ramsey/composer-install@v2"
with:
composer-options: --ignore-platform-reqs
custom-cache-suffix: $(date -u "+%Y-%m")

- name: Display PHPCS installed standards
run: ./vendor/bin/phpcs -i

- name: Lint against parse errors
if: matrix.phpcs_version == 'dev-master'
75 changes: 37 additions & 38 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -9,9 +9,16 @@ on:
paths-ignore:
- '**.md'
pull_request:

# Allow manually triggering the workflow.
workflow_dispatch:

# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
#### PHP LINT STAGE ####
# Linting against high/low PHP versions should catch everything.
@@ -21,19 +28,14 @@ jobs:

strategy:
matrix:
php: ['5.4', 'latest']
experimental: [false]

include:
- php: '8.1'
experimental: true
php: ['5.4', 'latest', '8.3']

name: "Lint: PHP ${{ matrix.php }}"
continue-on-error: ${{ matrix.experimental }}
continue-on-error: ${{ matrix.php == '8.3' }}

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Install PHP
uses: shivammathur/setup-php@v2
@@ -43,7 +45,10 @@ jobs:
tools: cs2pr

- name: Install Composer dependencies
uses: "ramsey/composer-install@v1"
uses: "ramsey/composer-install@v2"
with:
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")

- name: Lint against parse errors
run: ./bin/php-lint --checkstyle | cs2pr
@@ -60,52 +65,41 @@ jobs:
# - phpcs_version: The PHPCS versions to test against.
# IMPORTANT: test runs shouldn't fail because of PHPCS being incompatible with a PHP version.
# - PHPCS will run without errors on PHP 5.4 - 7.4 on any supported version.
# - PHP 8.0 needs PHPCS 3.5.7+ to run without errors.
# - PHP 8.0 needs PHPCS 3.5.7+ to run without errors, and we require a higher minimum version.
# - PHP 8.1 needs PHPCS 3.6.1+ to run without errors, but works best with 3.7.1+, and we require at least this minimum version.
# - The `wpcs_version` key is added to allow additional test builds when multiple WPCS versions
# would be supported. As, at this time, only the latest stable release of WPCS is supported,
# no additional versions are included in the array.
# - experimental: Whether the build is "allowed to fail".
matrix:
php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
phpcs_version: ['3.5.5', 'dev-master']
php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
phpcs_version: ['3.7.1', 'dev-master']
wpcs_version: ['2.3.*']
experimental: [false]

include:
# Complete the matrix by adding PHP 8.0, but only test against compatible PHPCS versions.
- php: '8.0'
- php: '8.3'
phpcs_version: 'dev-master'
wpcs_version: '2.3.*'
experimental: false
- php: '8.0'
# PHPCS 3.5.7 is the lowest version of PHPCS which supports PHP 8.0.
phpcs_version: '3.5.7'
wpcs_version: '2.3.*'
experimental: false

# Experimental builds. These are allowed to fail.
#- php: '8.1'
# phpcs_version: 'dev-master'
# wpcs_version: '2.3.*'
# experimental: true

name: "Test: PHP ${{ matrix.php }} - PHPCS ${{ matrix.phpcs_version }} - WPCS ${{ matrix.wpcs_version }}"

continue-on-error: ${{ matrix.experimental }}
continue-on-error: ${{ matrix.php == '8.3' }}

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

# On stable PHPCS versions, allow for PHP deprecation notices.
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
# Note: the "elif" condition is temporary and should be removed once VIPCS updates to WPCS 3.0+.
- name: Setup ini config
id: set_ini
run: |
if [[ "${{ matrix.phpcs_version }}" != "dev-master" ]]; then
echo '::set-output name=PHP_INI::error_reporting=E_ALL & ~E_DEPRECATED'
echo 'PHP_INI=error_reporting=E_ALL & ~E_DEPRECATED' >> $GITHUB_OUTPUT
elif [[ "${{ matrix.php }}" == "8.1" ]]; then
echo 'PHP_INI=error_reporting=E_ALL & ~E_DEPRECATED' >> $GITHUB_OUTPUT
else
echo '::set-output name=PHP_INI::error_reporting=E_ALL'
echo 'PHP_INI=error_reporting=-1' >> $GITHUB_OUTPUT
fi
- name: Install PHP
@@ -115,24 +109,29 @@ jobs:
ini-values: ${{ steps.set_ini.outputs.PHP_INI }}
coverage: none

- name: 'Composer: set PHPCS and WPCS versions for tests'
run: |
composer require --no-update --no-scripts squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}"
composer require --no-update --no-scripts wp-coding-standards/wpcs:"${{ matrix.wpcs_version }}"
- name: 'Composer: set PHPCS version for tests'
run: composer require squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-update --no-scripts --no-interaction

- name: 'Composer: set WPCS version for tests'
run: composer require wp-coding-standards/wpcs:"${{ matrix.wpcs_version }}" --no-update --no-scripts --no-interaction

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
- name: Install Composer dependencies - normal
if: ${{ startsWith( matrix.php, '8' ) == false }}
uses: "ramsey/composer-install@v1"
uses: "ramsey/composer-install@v2"
with:
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")

# PHPUnit 7.x does not allow for installation on PHP 8, so ignore platform
# requirements to get PHPUnit 7.x to install on nightly.
- name: Install Composer dependencies - with ignore platform
if: ${{ startsWith( matrix.php, '8' ) }}
uses: "ramsey/composer-install@v1"
uses: "ramsey/composer-install@v2"
with:
composer-options: --ignore-platform-reqs
custom-cache-suffix: $(date -u "+%Y-%m")

- name: Run the unit tests
run: ./bin/unit-tests
1 change: 1 addition & 0 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
<rule ref="WordPress-Extra">
<exclude name="WordPress.Files.FileName"/>
<exclude name="WordPress.NamingConventions.ValidVariableName"/>
<exclude name="WordPress.NamingConventions.PrefixAllGlobals"/>
<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
<exclude name="WordPress.PHP.YodaConditions"/>
</rule>
Loading

0 comments on commit b8610e3

Please sign in to comment.