|
| 1 | +name: 'Run tests' |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - '**/*.php' |
| 7 | + - '.github/workflows/*' |
| 8 | + push: |
| 9 | + paths: |
| 10 | + - '**/*.php' |
| 11 | + - '.github/workflows/*' |
| 12 | + |
| 13 | +jobs: |
| 14 | + cs: |
| 15 | + name: 'Check coding style' |
| 16 | + runs-on: 'ubuntu-20.04' |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: 'Checkout current revision' |
| 20 | + uses: 'actions/checkout@v3' |
| 21 | + |
| 22 | + - name: 'Setup PHP' |
| 23 | + uses: 'shivammathur/setup-php@v2' |
| 24 | + with: |
| 25 | + php-version: '8.1' |
| 26 | + tools: 'composer' |
| 27 | + coverage: 'none' |
| 28 | + |
| 29 | + - name: 'Discover Composer cache directory' |
| 30 | + id: 'cachedir' |
| 31 | + run: 'echo "::set-output name=path::$(composer global config cache-dir)"' |
| 32 | + |
| 33 | + - name: 'Share Composer cache across runs' |
| 34 | + uses: 'actions/cache@v3' |
| 35 | + with: |
| 36 | + path: '${{ steps.cachedir.outputs.path }}' |
| 37 | + key: "composer-${{ github.job }}-${{ hashFiles('**/composer.json') }}" |
| 38 | + restore-keys: | |
| 39 | + composer-${{ github.job }}- |
| 40 | + composer- |
| 41 | +
|
| 42 | + - name: 'Install dependencies with Composer' |
| 43 | + run: 'composer install --prefer-dist --no-interaction' |
| 44 | + |
| 45 | + - name: 'Run PHP CodeSniffer' |
| 46 | + run: 'composer run-script cs-check -- -n' |
| 47 | + |
| 48 | + stan: |
| 49 | + name: 'Static code analyzer' |
| 50 | + runs-on: 'ubuntu-20.04' |
| 51 | + continue-on-error: true |
| 52 | + |
| 53 | + steps: |
| 54 | + - name: 'Checkout current revision' |
| 55 | + uses: 'actions/checkout@v3' |
| 56 | + |
| 57 | + - name: 'Setup PHP' |
| 58 | + uses: 'shivammathur/setup-php@v2' |
| 59 | + with: |
| 60 | + php-version: '8.1' |
| 61 | + tools: 'composer' |
| 62 | + coverage: 'none' |
| 63 | + |
| 64 | + - name: 'Discover Composer cache directory' |
| 65 | + id: 'cachedir' |
| 66 | + run: 'echo "::set-output name=path::$(composer global config cache-dir)"' |
| 67 | + |
| 68 | + - name: 'Share Composer cache across runs' |
| 69 | + uses: 'actions/cache@v3' |
| 70 | + with: |
| 71 | + path: '${{ steps.cachedir.outputs.path }}' |
| 72 | + key: "composer-${{ github.job }}-${{ hashFiles('**/composer.json') }}" |
| 73 | + restore-keys: | |
| 74 | + composer-${{ github.job }}- |
| 75 | + composer- |
| 76 | +
|
| 77 | + - name: 'Install dependencies with Composer' |
| 78 | + run: 'composer install --prefer-dist --no-interaction' |
| 79 | + |
| 80 | + - name: 'Run PHP STAN' |
| 81 | + run: 'composer run-script stan -- --no-progress --error-format=github' |
| 82 | + |
| 83 | + unit: |
| 84 | + name: 'Run unit tests' |
| 85 | + if: "!contains(github.event.commits[0].message, '[skip ci]') && !contains(github.event.commits[0].message, '[ci skip]')" |
| 86 | + runs-on: 'ubuntu-20.04' |
| 87 | + |
| 88 | + strategy: |
| 89 | + fail-fast: false |
| 90 | + matrix: |
| 91 | + php: |
| 92 | + - '7.4' |
| 93 | + - '8.0' |
| 94 | + - '8.1' |
| 95 | + |
| 96 | + env: |
| 97 | + PHP_VERSION: '${{ matrix.php }}' |
| 98 | + |
| 99 | + steps: |
| 100 | + - name: 'Checkout current revision' |
| 101 | + uses: 'actions/checkout@v3' |
| 102 | + |
| 103 | + - name: 'Setup PHP' |
| 104 | + uses: 'shivammathur/setup-php@v2' |
| 105 | + with: |
| 106 | + php-version: '${{ matrix.php }}' |
| 107 | + tools: 'composer' |
| 108 | + coverage: 'xdebug' |
| 109 | + |
| 110 | + - name: 'Discover Composer cache directory' |
| 111 | + id: 'cachedir' |
| 112 | + run: 'echo "::set-output name=path::$(composer global config cache-dir)"' |
| 113 | + |
| 114 | + - name: 'Share Composer cache across runs' |
| 115 | + uses: 'actions/cache@v3' |
| 116 | + with: |
| 117 | + path: '${{ steps.cachedir.outputs.path }}' |
| 118 | + key: "composer-${{ matrix.php }}-${{ hashFiles('**/composer.json') }}" |
| 119 | + restore-keys: | |
| 120 | + composer-${{ matrix.php }}- |
| 121 | + composer- |
| 122 | +
|
| 123 | + - name: 'Install dependencies with Composer' |
| 124 | + run: 'composer install --prefer-dist --no-interaction' |
| 125 | + |
| 126 | + - name: 'Dump Composer autoloader' |
| 127 | + run: 'composer dump-autoload --classmap-authoritative --no-cache' |
| 128 | + |
| 129 | + - name: 'Run PHPUnit' |
| 130 | + run: 'phpdbg -qrr vendor/bin/phpunit --coverage-clover=clover.xml' |
| 131 | + |
| 132 | + - name: 'Export coverage results' |
| 133 | + uses: 'codecov/codecov-action@v3' |
| 134 | + with: |
| 135 | + file: './clover.xml' |
| 136 | + env_vars: PHP_VERSION |
| 137 | + |
| 138 | + - name: 'Archive code coverage results' |
| 139 | + uses: 'actions/upload-artifact@v3' |
| 140 | + with: |
| 141 | + name: 'PHP ${{ matrix.php }}' |
| 142 | + path: 'clover.xml' |
| 143 | + |
| 144 | + unit-lowest: |
| 145 | + name: 'Run unit tests with lowest-matching dependencies versions' |
| 146 | + if: "!contains(github.event.commits[0].message, '[skip ci]') && !contains(github.event.commits[0].message, '[ci skip]')" |
| 147 | + runs-on: 'ubuntu-20.04' |
| 148 | + |
| 149 | + steps: |
| 150 | + - name: 'Checkout current revision' |
| 151 | + uses: 'actions/checkout@v3' |
| 152 | + |
| 153 | + - name: 'Setup PHP' |
| 154 | + uses: 'shivammathur/setup-php@v2' |
| 155 | + with: |
| 156 | + php-version: '8.1' |
| 157 | + tools: 'composer' |
| 158 | + |
| 159 | + - name: 'Discover Composer cache directory' |
| 160 | + id: 'cachedir' |
| 161 | + run: 'echo "::set-output name=path::$(composer global config cache-dir)"' |
| 162 | + |
| 163 | + - name: 'Share Composer cache across runs' |
| 164 | + uses: 'actions/cache@v3' |
| 165 | + with: |
| 166 | + path: '${{ steps.cachedir.outputs.path }}' |
| 167 | + key: "composer-lowest-${{ hashFiles('**/composer.json') }}" |
| 168 | + restore-keys: | |
| 169 | + composer-lowest- |
| 170 | + composer- |
| 171 | +
|
| 172 | + - name: 'Update dependencies with Composer' |
| 173 | + run: 'composer update --prefer-lowest --prefer-dist --no-interaction' |
| 174 | + |
| 175 | + - name: 'Dump Composer autoloader' |
| 176 | + run: 'composer dump-autoload --classmap-authoritative --no-cache' |
| 177 | + |
| 178 | + - name: 'Run PHPUnit' |
| 179 | + run: 'vendor/bin/phpunit' |
0 commit comments