Skip to content

Commit

Permalink
Merge pull request #822 from Automattic/develop
Browse files Browse the repository at this point in the history
Release: 3.0.1
  • Loading branch information
rebeccahum authored May 10, 2024
2 parents 1b8960e + 9e91528 commit 2b1d206
Show file tree
Hide file tree
Showing 27 changed files with 189 additions and 163 deletions.
38 changes: 32 additions & 6 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,42 @@ To determine where best to report the bug, use the first part of the sniff name:

Sniff name starts with | Report to
--- | ---
`Generic` | [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer/issues/)
`PSR2` | [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer/issues/)
`Squiz` | [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer/issues/)
`Generic` | [PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/)
`PSR2` | [PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/)
`Squiz` | [PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/)
`Universal` | [PHPCSExtra](https://github.com/PHPCSStandards/PHPCSExtra/issues/)
`VariableAnalysis` | [VariableAnalysis](https://github.com/sirbrillig/phpcs-variable-analysis/issues/)
`WordPress` | [WordPressCS](https://github.com/WordPress/WordPress-Coding-Standards/issues/)
`WordPressVIPMinimum` | [VIPCS](https://github.com/Automattic/VIP-Coding-Standards/issues/) (this repo)

----

## Getting the source files

```sh
git clone git@github.com:Automattic/VIP-Coding-Standards.git vipcs
```

...or:

```sh
gh repo clone Automattic/VIP-Coding-Standards vipcs
```

Now `cd vipcs` and run:

```sh
composer install
```

You can now run:

```
composer check
```

... and all checks should pass.

## tl;dr Composer Scripts

This package contains Composer scripts to quickly run the developer checks which are described (with setups) further below.
Expand Down Expand Up @@ -67,7 +93,7 @@ When you introduce new `public` sniff properties, or your sniff extends a class
* WordPress-Coding-Standards
* PHPCSUtils 1.x
* PHP_CodeSniffer 3.x
* PHPUnit 4.x, 5.x, 6.x or 7.x
* PHPUnit 4.x - 9.x

The VIP Coding Standards use the PHP_CodeSniffer native unit test suite for unit testing the sniffs.

Expand All @@ -78,7 +104,7 @@ N.B.: If you installed VIPCS using Composer, make sure you used `--prefer-source
If you already have PHPUnit installed on your system: Congrats, you're all set.

If not, you can navigate to the directory where the `PHP_CodeSniffer` repo is checked out and do `composer install` to install the `dev` dependencies.
Alternatively, you can [install PHPUnit](https://phpunit.readthedocs.io/en/7.5/installation.html) as a PHAR file.
Alternatively, you can [install PHPUnit](https://phpunit.readthedocs.io/en/9.6/installation.html) as a PHAR file.

### Before running the unit tests

Expand Down Expand Up @@ -118,7 +144,7 @@ The easiest way to do this is to add a `phpunit.xml` file to the root of your VI

Expected output:
```
PHPUnit 7.5.20 by Sebastian Bergmann and contributors.
PHPUnit 9.6.15 by Sebastian Bergmann and contributors.

........................................ 40 / 40 (100%)

Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Use `php -v` and `composer show` to get versions.
| PHPCSUtils version | x.y.z
| VIPCS version | x.y.z
| WordPressCS version | x.y.z
| PHPCSExtra version | x.y.z
| VariableAnalysis version | x.y.z

## Additional Context (optional)
Expand Down
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Dependabot configuration.
#
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
time: "09:00"
commit-message:
prefix: "GH Actions:"
labels:
- "Type: Maintenance"
28 changes: 17 additions & 11 deletions .github/workflows/basics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

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

- name: Install PHP
uses: shivammathur/setup-php@v2
Expand All @@ -33,14 +33,20 @@ jobs:
coverage: none
tools: cs2pr

# Updating the lists can fail intermittently, typically after Microsoft has released a new package.
# This should not be blocking for this job, so ignore any errors from this step.
# Ref: https://github.com/dotnet/core/issues/4167
- name: Update the available packages list
continue-on-error: true
run: sudo apt-get update

- name: Install xmllint
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y libxml2-utils
run: 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
- uses: korelstar/xmllint-problem-matcher@v1
- name: Enable showing XML issues inline
uses: korelstar/xmllint-problem-matcher@v1

# Validate the composer.json file.
# @link https://getcomposer.org/doc/03-cli.md#validate
Expand All @@ -52,9 +58,9 @@ jobs:
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
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
- name: Install Composer dependencies
uses: "ramsey/composer-install@v2"
uses: "ramsey/composer-install@v3"
with:
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")
Expand Down Expand Up @@ -84,20 +90,20 @@ jobs:

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

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: 'latest'
coverage: none
tools: phpstan

# Install dependencies and handle caching in one go.
# Dependencies need to be installed to make sure the PHPCS and PHPUnit classes are recognized.
# @link https://github.com/marketplace/actions/install-composer-dependencies
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
- name: Install Composer dependencies
uses: "ramsey/composer-install@v2"
uses: "ramsey/composer-install@v3"
with:
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")
Expand Down
30 changes: 5 additions & 25 deletions .github/workflows/quicktest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:

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

- name: Set up PHP
uses: shivammathur/setup-php@v2
Expand All @@ -52,25 +52,15 @@ jobs:
coverage: none

# 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@v2"
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
- name: Install Composer dependencies
uses: "ramsey/composer-install@v3"
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@v2"
with:
composer-options: --ignore-platform-req=php+
custom-cache-suffix: $(date -u "+%Y-%m")

- name: "Composer: downgrade PHPCS dependencies for tests (lowest)"
if: ${{ matrix.php == '5.4' && matrix.dependencies == 'lowest' }}
if: ${{ matrix.dependencies == 'lowest' }}
run: >
composer update --prefer-lowest --no-scripts --no-interaction
squizlabs/php_codesniffer
Expand All @@ -79,16 +69,6 @@ jobs:
sirbrillig/phpcs-variable-analysis
wp-coding-standards/wpcs
- name: "Composer: downgrade PHPCS dependencies for tests (lowest) - with ignore platform"
if: ${{ matrix.php == 'latest' && matrix.dependencies == 'lowest' }}
run: >
composer update --prefer-lowest --no-scripts --no-interaction --ignore-platform-req=php+
squizlabs/php_codesniffer
phpcsstandards/phpcsutils
phpcsstandards/phpcsextra
sirbrillig/phpcs-variable-analysis
wp-coding-standards/wpcs
- name: Display PHPCS installed standards
run: ./vendor/bin/phpcs -i

Expand Down
47 changes: 14 additions & 33 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ jobs:

strategy:
matrix:
php: ['5.4', 'latest', '8.3']
php: ['5.4', 'latest', '8.4']

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

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

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

- name: Install Composer dependencies
uses: "ramsey/composer-install@v2"
uses: "ramsey/composer-install@v3"
with:
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")
Expand All @@ -67,8 +67,9 @@ jobs:
# - 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, 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.
# - PHP 8.2 and 8.3 need PHPCS 3.8.0+ to run without errors (though the errors don't affect the tests).
matrix:
php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
dependencies: ['lowest', 'stable']

include:
Expand All @@ -79,20 +80,20 @@ jobs:
dependencies: 'dev'
- php: '7.4'
dependencies: 'dev'
- php: '8.2'
- php: '8.3'
dependencies: 'dev'

# Test against upcoming PHP version.
- php: '8.3'
- php: '8.4'
dependencies: 'dev'

name: "Test: PHP ${{ matrix.php }} - PHPCS ${{ matrix.dependencies }}"

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

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

# With stable PHPCS dependencies, 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.
Expand Down Expand Up @@ -123,25 +124,15 @@ jobs:
wp-coding-standards/wpcs:"dev-develop"
# 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@v2"
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
- name: Install Composer dependencies
uses: "ramsey/composer-install@v3"
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@v2"
with:
composer-options: --ignore-platform-req=php+
custom-cache-suffix: $(date -u "+%Y-%m")

- name: "Composer: downgrade PHPCS dependencies for tests (lowest)"
if: ${{ ! startsWith( matrix.php, '8' ) && matrix.dependencies == 'lowest' }}
if: ${{ matrix.dependencies == 'lowest' }}
run: >
composer update --prefer-lowest --no-scripts --no-interaction
squizlabs/php_codesniffer
Expand All @@ -150,16 +141,6 @@ jobs:
sirbrillig/phpcs-variable-analysis
wp-coding-standards/wpcs
- name: "Composer: downgrade PHPCS dependencies for tests (lowest) - with ignore platform"
if: ${{ startsWith( matrix.php, '8' ) && matrix.dependencies == 'lowest' }}
run: >
composer update --prefer-lowest --no-scripts --no-interaction --ignore-platform-req=php+
squizlabs/php_codesniffer
phpcsstandards/phpcsutils
phpcsstandards/phpcsextra
sirbrillig/phpcs-variable-analysis
wp-coding-standards/wpcs
- name: Run the unit tests
run: ./bin/unit-tests

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ phpcs.xml
phpunit.xml
phpcs.cache
phpstan.neon
.phpunit.result.cache
2 changes: 1 addition & 1 deletion .phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="VIP Coding Standards" xsi:noNamespaceSchemaLocation="https://github.com/raw/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="VIP Coding Standards" xsi:noNamespaceSchemaLocation="https://github.com/raw/PHPCSStandards/PHP_CodeSniffer/master/phpcs.xsd">
<description>The custom ruleset for the VIP Coding Standards itself.</description>

<file>.</file>
Expand Down
Loading

0 comments on commit 2b1d206

Please sign in to comment.