|
| 1 | +name: Test |
| 2 | + |
| 3 | +on: |
| 4 | + # Run on pushes to `master` and on all pull requests. |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - master |
| 8 | + pull_request: |
| 9 | + paths-ignore: |
| 10 | + - '**.md' |
| 11 | + |
| 12 | +jobs: |
| 13 | + #### TEST STAGE #### |
| 14 | + test: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + strategy: |
| 18 | + # Keys: |
| 19 | + # - experimental: Whether the build is "allowed to fail". |
| 20 | + matrix: |
| 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.2 on any version. |
| 23 | + # - PHP 7.3 needs PHPCS 3.3.1+ to run without errors. |
| 24 | + # - PHP 7.4 needs PHPCS 3.5.0+ to run without errors. |
| 25 | + # - PHP 8.0 needs PHPCS 3.5.7+ to run without errors. |
| 26 | + php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2'] |
| 27 | + phpcs_version: ['3.1.0', 'dev-master'] |
| 28 | + experimental: [false] |
| 29 | + |
| 30 | + include: |
| 31 | + # Complete the matrix, while preventing issues with PHPCS versions incompatible with certain PHP versions. |
| 32 | + - php: '8.0' |
| 33 | + phpcs_version: 'dev-master' |
| 34 | + experimental: false |
| 35 | + - php: '8.0' |
| 36 | + phpcs_version: '3.5.7' |
| 37 | + experimental: false |
| 38 | + |
| 39 | + - php: '7.4' |
| 40 | + phpcs_version: 'dev-master' |
| 41 | + experimental: false |
| 42 | + - php: '7.4' |
| 43 | + phpcs_version: '3.5.0' |
| 44 | + experimental: false |
| 45 | + |
| 46 | + - php: '7.3' |
| 47 | + phpcs_version: 'dev-master' |
| 48 | + experimental: false |
| 49 | + - php: '7.3' |
| 50 | + phpcs_version: '3.3.1' |
| 51 | + experimental: false |
| 52 | + |
| 53 | + # Experimental builds. These are allowed to fail. |
| 54 | + - php: '7.4' |
| 55 | + phpcs_version: '4.0.x-dev' |
| 56 | + experimental: true |
| 57 | + |
| 58 | + - php: '8.1' # Nightly. |
| 59 | + phpcs_version: 'dev-master' |
| 60 | + experimental: true |
| 61 | + |
| 62 | + name: "Test${{ matrix.phpcs_version == 'dev-master' && ' + Lint' || '' }}: PHP ${{ matrix.php }} - PHPCS ${{ matrix.phpcs_version }}" |
| 63 | + |
| 64 | + continue-on-error: ${{ matrix.experimental }} |
| 65 | + |
| 66 | + steps: |
| 67 | + - name: Checkout code |
| 68 | + uses: actions/checkout@v2 |
| 69 | + |
| 70 | + - name: Setup ini config |
| 71 | + id: set_ini |
| 72 | + run: | |
| 73 | + # On stable PHPCS versions, allow for PHP deprecation notices. |
| 74 | + # Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore. |
| 75 | + if [[ "${{ matrix.phpcs_version }}" != "dev-master" && "${{ matrix.phpcs_version }}" != "4.0.x-dev" ]]; then |
| 76 | + echo '::set-output name=PHP_INI::error_reporting=E_ALL & ~E_DEPRECATED' |
| 77 | + else |
| 78 | + echo '::set-output name=PHP_INI::error_reporting=E_ALL' |
| 79 | + fi |
| 80 | +
|
| 81 | + - name: Install PHP |
| 82 | + uses: shivammathur/setup-php@v2 |
| 83 | + with: |
| 84 | + php-version: ${{ matrix.php }} |
| 85 | + ini-values: ${{ steps.set_ini.outputs.PHP_INI }} |
| 86 | + coverage: none |
| 87 | + |
| 88 | + - name: 'Composer: adjust dependencies' |
| 89 | + run: | |
| 90 | + # Set the PHPCS version to be used in the tests. |
| 91 | + composer require --no-update squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-scripts |
| 92 | + # Remove the PHPCSDevCS dependency as it has different PHPCS requirements and would block installs. |
| 93 | + composer remove --no-update --dev phpcsstandards/phpcsdevcs --no-scripts |
| 94 | +
|
| 95 | + # Install dependencies and handle caching in one go. |
| 96 | + # @link https://github.com/marketplace/actions/install-composer-dependencies |
| 97 | + - name: Install Composer dependencies - normal |
| 98 | + if: ${{ matrix.php < 8.1 }} |
| 99 | + uses: "ramsey/composer-install@v1" |
| 100 | + |
| 101 | + # For PHP "nightly", we need to install with ignore platform reqs as not all dependencies allow installation. |
| 102 | + - name: Install Composer dependencies - with ignore platform |
| 103 | + if: ${{ matrix.php >= 8.1 }} |
| 104 | + uses: "ramsey/composer-install@v1" |
| 105 | + with: |
| 106 | + composer-options: --ignore-platform-reqs |
| 107 | + |
| 108 | + - name: Lint against parse errors |
| 109 | + if: matrix.phpcs_version == 'dev-master' |
| 110 | + run: composer lint |
| 111 | + |
| 112 | + # Check that any sniffs available are feature complete. |
| 113 | + # This also acts as an integration test for the feature completeness script, |
| 114 | + # which is why it is run against various PHP versions and not in the "Sniff" stage. |
| 115 | + - name: Check for feature completeness |
| 116 | + if: matrix.phpcs_version == 'dev-master' |
| 117 | + run: composer check-complete |
| 118 | + |
| 119 | + - name: Run the unit tests |
| 120 | + run: composer run-tests |
0 commit comments