diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..ee918fa --- /dev/null +++ b/.github/workflows/test.yml @@ -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 + diff --git a/CHANGELOG.md b/CHANGELOG.md index e3efdb1..180d266 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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). diff --git a/WPGraphQL-Core/ruleset.xml b/WPGraphQL-Core/ruleset.xml index bad7ee4..f6f17d2 100644 --- a/WPGraphQL-Core/ruleset.xml +++ b/WPGraphQL-Core/ruleset.xml @@ -10,12 +10,9 @@ - - - - + @@ -27,5 +24,8 @@ - + + + + diff --git a/WPGraphQL-Docs/ruleset.xml b/WPGraphQL-Docs/ruleset.xml index 1eeb2b2..5beb5ff 100644 --- a/WPGraphQL-Docs/ruleset.xml +++ b/WPGraphQL-Docs/ruleset.xml @@ -10,6 +10,8 @@ + + diff --git a/WPGraphQL-Minimum/ruleset.xml b/WPGraphQL-Minimum/ruleset.xml index d9d9fca..6bea293 100644 --- a/WPGraphQL-Minimum/ruleset.xml +++ b/WPGraphQL-Minimum/ruleset.xml @@ -63,7 +63,15 @@ - + + + + + + + + +