|
| 1 | +name: Test |
| 2 | + |
| 3 | +on: |
| 4 | + # Run on all pushes and on all pull requests. |
| 5 | + # Prevent the "push" build from running when there are only irrelevant changes. |
| 6 | + push: |
| 7 | + paths-ignore: |
| 8 | + - '**.md' |
| 9 | + pull_request: |
| 10 | + # Allow manually triggering the workflow. |
| 11 | + workflow_dispatch: |
| 12 | + |
| 13 | +jobs: |
| 14 | + test: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + strategy: |
| 18 | + # Keys: |
| 19 | + # - php: The PHP versions to test against. |
| 20 | + # - phpcs_version: The PHPCS versions to test against. |
| 21 | + # IMPORTANT: test runs shouldn't fail because of PHPCS being incompatible with a PHP version. |
| 22 | + # - PHPCS will run without errors on PHP 5.4 - 7.4 on any supported version. |
| 23 | + # - PHP 8.0 needs PHPCS 3.5.7+ to run without errors. |
| 24 | + # - The `wpcs_version` key is added to allow additional test builds when multiple WPCS versions |
| 25 | + # would be supported. As, at this time, only the latest stable release of WPCS is supported, |
| 26 | + # no additional versions are included in the array. |
| 27 | + # - experimental: Whether the build is "allowed to fail". |
| 28 | + matrix: |
| 29 | + php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4'] |
| 30 | + phpcs_version: ['3.5.5', 'dev-master'] |
| 31 | + wpcs_version: ['2.3.*'] |
| 32 | + experimental: [false] |
| 33 | + |
| 34 | + include: |
| 35 | + # Complete the matrix by adding PHP 8.0, but only test against compatible PHPCS versions. |
| 36 | + - php: '8.0' |
| 37 | + phpcs_version: 'dev-master' |
| 38 | + wpcs_version: '2.3.*' |
| 39 | + experimental: false |
| 40 | + - php: '8.0' |
| 41 | + # PHPCS 3.5.7 is the lowest version of PHPCS which supports PHP 8.0. |
| 42 | + phpcs_version: '3.5.7' |
| 43 | + wpcs_version: '2.3.*' |
| 44 | + experimental: false |
| 45 | + |
| 46 | + # Experimental builds. These are allowed to fail. |
| 47 | + #- php: '8.1' |
| 48 | + # phpcs_version: 'dev-master' |
| 49 | + # wpcs_version: '2.3.*' |
| 50 | + # experimental: true |
| 51 | + |
| 52 | + name: "Test: PHP ${{ matrix.php }} - PHPCS ${{ matrix.phpcs_version }} - WPCS ${{ matrix.wpcs_version }}" |
| 53 | + |
| 54 | + continue-on-error: ${{ matrix.experimental }} |
| 55 | + |
| 56 | + steps: |
| 57 | + - name: Checkout code |
| 58 | + uses: actions/checkout@v2 |
| 59 | + |
| 60 | + # On stable PHPCS versions, allow for PHP deprecation notices. |
| 61 | + # Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore. |
| 62 | + - name: Setup ini config |
| 63 | + id: set_ini |
| 64 | + run: | |
| 65 | + if [[ "${{ matrix.phpcs_version }}" != "dev-master" ]]; then |
| 66 | + echo '::set-output name=PHP_INI::error_reporting=E_ALL & ~E_DEPRECATED' |
| 67 | + else |
| 68 | + echo '::set-output name=PHP_INI::error_reporting=E_ALL' |
| 69 | + fi |
| 70 | +
|
| 71 | + - name: Install PHP |
| 72 | + uses: shivammathur/setup-php@v2 |
| 73 | + with: |
| 74 | + php-version: ${{ matrix.php }} |
| 75 | + ini-values: ${{ steps.set_ini.outputs.PHP_INI }} |
| 76 | + coverage: none |
| 77 | + |
| 78 | + - name: 'Composer: set PHPCS and WPCS versions for tests' |
| 79 | + run: | |
| 80 | + composer require --no-update --no-scripts squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" |
| 81 | + composer require --no-update --no-scripts wp-coding-standards/wpcs:"${{ matrix.wpcs_version }}" |
| 82 | +
|
| 83 | + # Install dependencies and handle caching in one go. |
| 84 | + # @link https://github.com/marketplace/actions/install-composer-dependencies |
| 85 | + - name: Install Composer dependencies - normal |
| 86 | + if: ${{ startsWith( matrix.php, '8' ) == false }} |
| 87 | + uses: "ramsey/composer-install@v1" |
| 88 | + |
| 89 | + # PHPUnit 7.x does not allow for installation on PHP 8, so ignore platform |
| 90 | + # requirements to get PHPUnit 7.x to install on nightly. |
| 91 | + - name: Install Composer dependencies - with ignore platform |
| 92 | + if: ${{ startsWith( matrix.php, '8' ) }} |
| 93 | + uses: "ramsey/composer-install@v1" |
| 94 | + with: |
| 95 | + composer-options: --ignore-platform-reqs |
| 96 | + |
| 97 | + - name: Run the unit tests |
| 98 | + run: ./bin/unit-tests |
| 99 | + |
| 100 | + - name: Run the ruleset tests |
| 101 | + run: ./bin/ruleset-tests |
0 commit comments