Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
5d0319f
Issue template: mention PHPCSExtra
jrfnl Sep 4, 2023
008bf9a
Merge pull request #795 from Automattic/feature/issue-template-tweak
GaryJones Sep 4, 2023
6060fe5
Merge pull request #794 from Automattic/release/3.0.0
GaryJones Sep 5, 2023
d6fe1d4
Contributing: add notes for how to checkout the files
GaryJones Sep 6, 2023
18d3a4c
Merge pull request #796 from Automattic/docs/update-contributing
GaryJones Sep 6, 2023
263d13c
Add dependabot configuration file
jrfnl Sep 12, 2023
eb2d837
Merge pull request #797 from Automattic/feature/enable-and-configure-…
GaryJones Sep 14, 2023
910d24a
GH Actions: Bump actions/checkout from 3 to 4
dependabot[bot] Sep 14, 2023
9749b01
Merge pull request #798 from Automattic/dependabot/github_actions/act…
GaryJones Sep 14, 2023
ff14488
Classes/DeclarationCompatibility: sync with WP Core
jrfnl Sep 19, 2023
fbcc951
Merge pull request #799 from Automattic/feature/declarationcompatibil…
GaryJones Sep 19, 2023
6c9995e
GH Actions: minor tweaks
jrfnl Nov 14, 2023
64a020c
Merge pull request #802 from Automattic/feature/ghactions-minor-tweaks
rebeccahum Nov 17, 2023
4790990
GH Actions: update for the release of PHP 8.3
jrfnl Nov 23, 2023
88a55f8
Merge pull request #803 from Automattic/feature/ghactions-php-8.3-update
GaryJones Nov 23, 2023
d11b304
Switch to PHPCSStandards/PHP_CodeSniffer
jrfnl Nov 7, 2023
a3d7a2c
Composer: raise the minimum supported PHPCS version to 3.8.0
jrfnl Nov 14, 2023
873e28e
Composer: update various version constraints
jrfnl Nov 14, 2023
185d514
Update install instructions
terriann Feb 2, 2024
aac66ce
Correct use of semantic heading
terriann Feb 2, 2024
550ec3c
Merge pull request #805 from Automattic/feature/switch-to-fork-of-phpcs
GaryJones Feb 10, 2024
83d152e
Tests: allow for PHPUnit 8/9
jrfnl Dec 8, 2023
5ee0bce
Merge pull request #809 from Automattic/feature/phpunit-cross-version
GaryJones Feb 11, 2024
f34f465
CONTRIBUTING: minor tweak
jrfnl Dec 8, 2023
d388671
Merge pull request #810 from Automattic/feature/contributing-minor-tweak
GaryJones Feb 11, 2024
26312cf
Docs: Fix name of WPVIP
GaryJones Feb 16, 2024
cf5dc95
Docs: Fix links
GaryJones Feb 16, 2024
d323dc1
Merge pull request #808 from Automattic/docs/install-update
GaryJones Feb 16, 2024
b8a8877
Merge pull request #811 from Automattic/fix/docs-links
GaryJones Feb 16, 2024
cd82f3e
End restricting usage of term_exists()
GaryJones Feb 16, 2024
7e51538
Docs: Fix changelog heading
GaryJones Feb 16, 2024
f2a6b2e
Merge pull request #812 from Automattic/fix/remove-term-exists-error
rebeccahum Feb 16, 2024
cd46915
Merge pull request #813 from Automattic/docs/changelog
GaryJones Feb 16, 2024
4c83c0b
End restricting usage of get_page_by_title()
GaryJones Feb 16, 2024
73d8e6d
Merge pull request #814 from Automattic/fix/remove-get-page-by-title-…
rebeccahum Feb 16, 2024
fe947b0
GH Actions: Bump ramsey/composer-install from 2 to 3
dependabot[bot] Mar 4, 2024
8687674
Merge pull request #815 from Automattic/dependabot/github_actions/ram…
GaryJones Mar 4, 2024
ab56662
Deprecate suggesting using wpcom_vip_get_page_by_path
rebeccahum Apr 8, 2024
7d3768c
Merge pull request #817 from Automattic/deprecate/get_page_by_path
GaryJones Apr 15, 2024
f60ed12
GH Actions: work around intermittent apt-get errors
jrfnl Apr 24, 2024
463dc53
Merge pull request #818 from Automattic/feature/ghactions-xmllint-byp…
GaryJones Apr 24, 2024
b14551f
Update dependencies per https://github.com/Automattic/VIP-Coding-Stan…
rebeccahum May 8, 2024
627c179
Merge pull request #821 from Automattic/3.0.1/update-dependencies
rebeccahum May 9, 2024
65ef15a
Add changelog for 3.0.1 release
rebeccahum May 2, 2024
9e91528
Merge pull request #820 from Automattic/3.0.1/changelog
rebeccahum May 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 [email protected]: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://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="VIP Coding Standards" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/master/phpcs.xsd">
<description>The custom ruleset for the VIP Coding Standards itself.</description>

<file>.</file>
Expand Down
Loading