|
| 1 | +name: Test |
| 2 | + |
| 3 | +on: |
| 4 | + # Run on all pushes and on all pull requests. |
| 5 | + # Prevent the build from running when there are only irrelevant changes. |
| 6 | + push: |
| 7 | + paths-ignore: |
| 8 | + - '**.md' |
| 9 | + pull_request: |
| 10 | + paths-ignore: |
| 11 | + - '**.md' |
| 12 | + |
| 13 | +jobs: |
| 14 | + test: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + strategy: |
| 18 | + # Keys: |
| 19 | + # - custom_ini: Whether to run with specific custom ini settings to hit very specific |
| 20 | + # code conditions. |
| 21 | + # - experimental: Whether the build is "allowed to fail". |
| 22 | + matrix: |
| 23 | + php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0'] |
| 24 | + custom_ini: [false] |
| 25 | + experimental: [false] |
| 26 | + |
| 27 | + include: |
| 28 | + # Builds running the basic tests with different PHP ini settings. |
| 29 | + - php: '5.5' |
| 30 | + custom_ini: true |
| 31 | + experimental: false |
| 32 | + - php: '7.0' |
| 33 | + custom_ini: true |
| 34 | + experimental: false |
| 35 | + |
| 36 | + # Nightly. |
| 37 | + - php: '8.1' |
| 38 | + custom_ini: false |
| 39 | + experimental: true |
| 40 | + |
| 41 | + name: "PHP: ${{ matrix.php }} ${{ matrix.custom_ini && ' with custom ini settings' || '' }}" |
| 42 | + |
| 43 | + continue-on-error: ${{ matrix.experimental }} |
| 44 | + |
| 45 | + steps: |
| 46 | + - name: Checkout code |
| 47 | + uses: actions/checkout@v2 |
| 48 | + |
| 49 | + - name: Setup ini config |
| 50 | + id: set_ini |
| 51 | + run: | |
| 52 | + # On stable PHPCS versions, allow for PHP deprecation notices. |
| 53 | + # Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore. |
| 54 | + # Also set the "short_open_tag" ini to make sure specific conditions are tested. |
| 55 | + if [[ ${{ matrix.custom_ini }} == true && "${{ matrix.php }}" == '5.5' ]]; then |
| 56 | + echo '::set-output name=PHP_INI::phar.readonly=Off, date.timezone=Australia/Sydney, short_open_tag=On, asp_tags=On' |
| 57 | + elif [[ ${{ matrix.custom_ini }} == true && "${{ matrix.php }}" == '7.0' ]]; then |
| 58 | + echo '::set-output name=PHP_INI::phar.readonly=Off, date.timezone=Australia/Sydney, short_open_tag=On' |
| 59 | + else |
| 60 | + echo '::set-output name=PHP_INI::phar.readonly=Off' |
| 61 | + fi |
| 62 | +
|
| 63 | + - name: Install PHP |
| 64 | + uses: shivammathur/setup-php@v2 |
| 65 | + with: |
| 66 | + php-version: ${{ matrix.php }} |
| 67 | + ini-values: ${{ steps.set_ini.outputs.PHP_INI }} |
| 68 | + coverage: none |
| 69 | + |
| 70 | + # Install dependencies and handle caching in one go. |
| 71 | + # @link https://github.com/marketplace/actions/install-composer-dependencies |
| 72 | + - name: Install Composer dependencies - normal |
| 73 | + if: ${{ matrix.php < 8.0 }} |
| 74 | + uses: "ramsey/composer-install@v1" |
| 75 | + |
| 76 | + # For PHP 8.0+, we need to install with ignore platform reqs as PHPUnit 7 is still used. |
| 77 | + - name: Install Composer dependencies - with ignore platform |
| 78 | + if: ${{ matrix.php >= 8.0 }} |
| 79 | + uses: "ramsey/composer-install@v1" |
| 80 | + with: |
| 81 | + composer-options: --ignore-platform-reqs |
| 82 | + |
| 83 | + # Note: The code style check is run multiple times against every PHP version |
| 84 | + # as it also acts as an integration test. |
| 85 | + - name: 'PHPCS: set the path to PHP' |
| 86 | + run: php bin/phpcs --config-set php_path php |
| 87 | + |
| 88 | + - name: 'PHPUnit: run the tests' |
| 89 | + run: vendor/bin/phpunit tests/AllTests.php |
| 90 | + |
| 91 | + - name: 'PHPCS: check code style without cache, no parallel' |
| 92 | + if: ${{ matrix.custom_ini == false }} |
| 93 | + run: php bin/phpcs --no-cache --parallel=1 |
| 94 | + |
| 95 | + - name: 'Composer: validate config' |
| 96 | + if: ${{ matrix.custom_ini == false }} |
| 97 | + run: composer validate --no-check-all --strict |
| 98 | + |
| 99 | + - name: Build the phar |
| 100 | + if: ${{ matrix.custom_ini == false }} |
| 101 | + run: php scripts/build-phar.php |
| 102 | + |
| 103 | + - name: 'PHPCS: check code style using the Phar file' |
| 104 | + if: ${{ matrix.custom_ini == false }} |
| 105 | + run: php phpcs.phar |
0 commit comments