Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
79 changes: 79 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Test Rulesets

on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop
schedule:
# Run weekly on Mondays at 00:00 UTC
- cron: '0 0 * * 1'
workflow_dispatch: # Allow manual triggering

# 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:
test-rulesets:
name: Test rulesets
runs-on: ubuntu-latest

strategy:
matrix:
php: [8.4, 8.3, 8.2, 8.1, 8.0, 7.4]

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, xml, zip
tools: composer:v2
# Allow for PHP deprecation notices.
ini-values: error_reporting = E_ALL & ~E_DEPRECATED
coverage: none
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Validate composer.json file
run: composer validate --no-check-all --strict

- 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")

- name: Download latest WPGraphQL from GitHub Releases
run: |
# Download the latest release
mkdir -p temp/wp-graphql
curl -L -o temp/wp-graphql/wp-graphql.zip https://github.com/wp-graphql/wp-graphql/releases/latest/download/wp-graphql.zip
# Unzip the downloaded file
cd temp/wp-graphql
unzip wp-graphql.zip
# List files to verify extraction
ls -la

# Validate the Ruleset XML files.
- name: Validate the WordPress rulesets
uses: phpcsstandards/xmllint-validate@v1
with:
pattern: "./*/ruleset.xml"
xsd-file: "vendor/squizlabs/php_codesniffer/phpcs.xsd"

- name: Lint WPGraphQL Core
run: |
# Run the PHP CodeSniffer tests against the WPGraphQL Core ruleset.
vendor/bin/phpcs --standard=./WPGraphQL-Core/ruleset.xml --basepath=temp/wp-graphql/wp-graphql --runtime-set ignore_warnings_on_exit 1 -s temp/wp-graphql/wp-graphql/src --report-full --report-width=120

5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a

## [ Unreleased ]

- fix: Disable `Squiz.Commenting.VariableComment.MissingVar` in favor of `SlevomatCodingStandard.TypeHints.PropertyTypeHint`.
- fix: Ignore `SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation` for PHPStan annotations.
- fix: Fix incorrect excludes in `WPGraphQL-Core` ruleset.
- ci: Add ruleset testing Workflow.

## [2.0.0] - 2025-02-15

This release updates the `WPGraphQL-Core` ruleset to match the latest changes included in WPGraphQL [v2.0.0](https://github.com/wp-graphql/wp-graphql/releases/tag/v2.0.0).
Expand Down
10 changes: 5 additions & 5 deletions WPGraphQL-Core/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@
<exclude name="WordPress.WP.Capabilities.Undetermined" />
<!-- Most would require breaking changes to fix in core. Tracking: https://github.com/wp-graphql/wp-graphql/issues/2925 -->
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter" />

<!-- Depends on Squiz.Commenting.FunctionComment.MissingParamComment -->
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.UselessAnnotation" />
</rule>

<rule ref="WPGraphQL-Docs" />
<rule ref="WPGraphQL-Docs">
<!-- Conflicts with b/c in AbstractConnectionResolver -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidNoReturn" />

Expand All @@ -27,5 +24,8 @@
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment" />
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullStop" />
<exclude name="Squiz.Commenting.InlineComment.InvalidEndChar" />
<rule />

<!-- Depends on Squiz.Commenting.FunctionComment.MissingParamComment -->
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.UselessAnnotation" />
</rule>
</ruleset>
2 changes: 2 additions & 0 deletions WPGraphQL-Docs/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<exclude name="Squiz.Commenting.FunctionComment.IncorrectTypeHint" />
<!-- Conflicts with b/c in AbstractConnectionResolver -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidNoReturn" />
<!-- Better handled by SlevomatCodingStandard.TypeHints.PropertyTypeHint -->
<exclude name="Squiz.Commenting.VariableComment.MissingVar" />
</rule>
<rule ref="Squiz.Commenting.FunctionComment">
<properties>
Expand Down
10 changes: 9 additions & 1 deletion WPGraphQL-Minimum/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,15 @@
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure" />
<rule ref="SlevomatCodingStandard.Functions.UselessParameterDefaultValue" />

<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation"/>
<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation">
<properties>
<property name="ignoredAnnotationNames" type="array">
<element value="@phpstan-var" />
<element value="@phpstan-param" />
<element value="@phpstan-return" />
</property>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash" />

<rule ref="SlevomatCodingStandard.PHP.OptimizedFunctionsWithoutUnpacking" />
Expand Down