|
| 1 | +name: Test Rulesets |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - develop |
| 8 | + pull_request: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + - develop |
| 12 | + schedule: |
| 13 | + # Run weekly on Mondays at 00:00 UTC |
| 14 | + - cron: '0 0 * * 1' |
| 15 | + workflow_dispatch: # Allow manual triggering |
| 16 | + |
| 17 | +# Cancels all previous workflow runs for the same branch that have not yet completed. |
| 18 | +concurrency: |
| 19 | + # The concurrency group contains the workflow name and the branch name. |
| 20 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 21 | + cancel-in-progress: true |
| 22 | + |
| 23 | +jobs: |
| 24 | + test-rulesets: |
| 25 | + name: Test rulesets |
| 26 | + runs-on: ubuntu-latest |
| 27 | + |
| 28 | + strategy: |
| 29 | + matrix: |
| 30 | + php: [8.4, 8.3, 8.2, 8.1, 8.0, 7.4] |
| 31 | + |
| 32 | + steps: |
| 33 | + - name: Checkout code |
| 34 | + uses: actions/checkout@v4 |
| 35 | + |
| 36 | + - name: Setup PHP |
| 37 | + uses: shivammathur/setup-php@v2 |
| 38 | + with: |
| 39 | + php-version: ${{ matrix.php }} |
| 40 | + extensions: mbstring, xml, zip |
| 41 | + tools: composer:v2 |
| 42 | + # Allow for PHP deprecation notices. |
| 43 | + ini-values: error_reporting = E_ALL & ~E_DEPRECATED |
| 44 | + coverage: none |
| 45 | + env: |
| 46 | + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 47 | + |
| 48 | + - name: Validate composer.json file |
| 49 | + run: composer validate --no-check-all --strict |
| 50 | + |
| 51 | + - name: Install Composer dependencies |
| 52 | + uses: ramsey/composer-install@v3 |
| 53 | + with: |
| 54 | + # Bust the cache at least once a month - output format: YYYY-MM. |
| 55 | + custom-cache-suffix: $(date -u "+%Y-%m") |
| 56 | + |
| 57 | + - name: Download latest WPGraphQL from GitHub Releases |
| 58 | + run: | |
| 59 | + # Download the latest release |
| 60 | + mkdir -p temp/wp-graphql |
| 61 | + curl -L -o temp/wp-graphql/wp-graphql.zip https://github.com/wp-graphql/wp-graphql/releases/latest/download/wp-graphql.zip |
| 62 | + # Unzip the downloaded file |
| 63 | + cd temp/wp-graphql |
| 64 | + unzip wp-graphql.zip |
| 65 | + # List files to verify extraction |
| 66 | + ls -la |
| 67 | +
|
| 68 | + # Validate the Ruleset XML files. |
| 69 | + - name: Validate the WordPress rulesets |
| 70 | + uses: phpcsstandards/xmllint-validate@v1 |
| 71 | + with: |
| 72 | + pattern: "./*/ruleset.xml" |
| 73 | + xsd-file: "vendor/squizlabs/php_codesniffer/phpcs.xsd" |
| 74 | + |
| 75 | + - name: Lint WPGraphQL Core |
| 76 | + run: | |
| 77 | + # Run the PHP CodeSniffer tests against the WPGraphQL Core ruleset. |
| 78 | + 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 |
| 79 | +
|
0 commit comments