|
| 1 | +name: 'build' |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - 'master' |
| 10 | + |
| 11 | +env: |
| 12 | + extensions: 'json' |
| 13 | + cache-version: '1' |
| 14 | + composer-version: 'v2' |
| 15 | + composer-install: 'composer update --no-interaction --no-progress --no-suggest --prefer-dist --prefer-stable' |
| 16 | + |
| 17 | +jobs: |
| 18 | + coding_style: |
| 19 | + name: 'Coding style' |
| 20 | + runs-on: '${{ matrix.operating-system }}' |
| 21 | + |
| 22 | + strategy: |
| 23 | + matrix: |
| 24 | + php-version: [ '7.4' ] |
| 25 | + operating-system: [ 'ubuntu-latest' ] |
| 26 | + fail-fast: false |
| 27 | + |
| 28 | + steps: |
| 29 | + - name: 'Checkout' |
| 30 | + uses: 'actions/checkout@v2' |
| 31 | + |
| 32 | + - name: 'Setup PHP cache environment' |
| 33 | + id: 'extcache' |
| 34 | + uses: 'shivammathur/cache-extensions@v1' |
| 35 | + with: |
| 36 | + php-version: '${{ matrix.php-version }}' |
| 37 | + extensions: '${{ env.extensions }}' |
| 38 | + key: '${{ env.cache-version }}' |
| 39 | + |
| 40 | + - name: 'Cache PHP extensions' |
| 41 | + uses: 'actions/cache@v2' |
| 42 | + with: |
| 43 | + path: '${{ steps.extcache.outputs.dir }}' |
| 44 | + key: '${{ steps.extcache.outputs.key }}' |
| 45 | + restore-keys: '${{ steps.extcache.outputs.key }}' |
| 46 | + |
| 47 | + - name: 'Install PHP' |
| 48 | + uses: 'shivammathur/setup-php@v2' |
| 49 | + with: |
| 50 | + php-version: '${{ matrix.php-version }}' |
| 51 | + extensions: '${{ env.extensions }}' |
| 52 | + tools: 'composer:${{ env.composer-version }}' |
| 53 | + |
| 54 | + - name: "Setup problem matchers for PHP" |
| 55 | + run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"' |
| 56 | + |
| 57 | + - name: 'Get Composer cache directory' |
| 58 | + id: 'composercache' |
| 59 | + run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"' |
| 60 | + |
| 61 | + - name: 'Cache PHP dependencies' |
| 62 | + uses: "actions/cache@v2" |
| 63 | + with: |
| 64 | + path: '${{ steps.composercache.outputs.dir }}' |
| 65 | + key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}" |
| 66 | + restore-keys: '${{ runner.os }}-composer-' |
| 67 | + |
| 68 | + - name: 'Validate Composer' |
| 69 | + run: 'composer validate' |
| 70 | + |
| 71 | + - name: 'Install dependencies' |
| 72 | + run: '${{ env.composer-install }}' |
| 73 | + |
| 74 | + - name: 'Coding Standard' |
| 75 | + run: 'bin/cs' |
| 76 | + |
| 77 | + php_stan: |
| 78 | + name: 'PHP Stan' |
| 79 | + runs-on: '${{ matrix.operating-system }}' |
| 80 | + |
| 81 | + strategy: |
| 82 | + matrix: |
| 83 | + php-version: [ '7.4' ] |
| 84 | + operating-system: [ 'ubuntu-latest' ] |
| 85 | + fail-fast: false |
| 86 | + |
| 87 | + steps: |
| 88 | + - name: 'Checkout' |
| 89 | + uses: 'actions/checkout@v2' |
| 90 | + |
| 91 | + - name: 'Setup PHP cache environment' |
| 92 | + id: 'extcache' |
| 93 | + uses: 'shivammathur/cache-extensions@v1' |
| 94 | + with: |
| 95 | + php-version: '${{ matrix.php-version }}' |
| 96 | + extensions: '${{ env.extensions }}' |
| 97 | + key: '${{ env.cache-version }}' |
| 98 | + |
| 99 | + - name: 'Cache PHP extensions' |
| 100 | + uses: 'actions/cache@v2' |
| 101 | + with: |
| 102 | + path: '${{ steps.extcache.outputs.dir }}' |
| 103 | + key: '${{ steps.extcache.outputs.key }}' |
| 104 | + restore-keys: '${{ steps.extcache.outputs.key }}' |
| 105 | + |
| 106 | + - name: 'Install PHP' |
| 107 | + uses: 'shivammathur/setup-php@v2' |
| 108 | + with: |
| 109 | + php-version: '${{ matrix.php-version }}' |
| 110 | + extensions: '${{ env.extensions }}' |
| 111 | + tools: 'composer:${{ env.composer-version }}' |
| 112 | + |
| 113 | + - name: 'Setup problem matchers for PHP' |
| 114 | + run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"' |
| 115 | + |
| 116 | + - name: 'Get Composer cache directory' |
| 117 | + id: 'composercache' |
| 118 | + run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"' |
| 119 | + |
| 120 | + - name: 'Cache PHP dependencies' |
| 121 | + uses: 'actions/cache@v2' |
| 122 | + with: |
| 123 | + path: '${{ steps.composercache.outputs.dir }}' |
| 124 | + key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}" |
| 125 | + restore-keys: '${{ runner.os }}-composer-' |
| 126 | + |
| 127 | + - name: 'Install dependencies' |
| 128 | + run: '${{ env.composer-install }}' |
| 129 | + |
| 130 | + - name: 'PHPStan' |
| 131 | + run: 'bin/stan' |
| 132 | + |
| 133 | + tests: |
| 134 | + name: 'Tests' |
| 135 | + runs-on: '${{ matrix.operating-system }}' |
| 136 | + |
| 137 | + strategy: |
| 138 | + matrix: |
| 139 | + php-version: [ '7.1', '7.2', '7.3', '7.4', '8.0' ] |
| 140 | + operating-system: [ 'ubuntu-latest' ] |
| 141 | + composer-args: [ '' ] |
| 142 | + |
| 143 | + fail-fast: false |
| 144 | + |
| 145 | + steps: |
| 146 | + - name: 'Checkout' |
| 147 | + uses: 'actions/checkout@v2' |
| 148 | + |
| 149 | + - name: 'Setup PHP cache environment' |
| 150 | + id: 'extcache' |
| 151 | + uses: 'shivammathur/cache-extensions@v1' |
| 152 | + with: |
| 153 | + php-version: '${{ matrix.php-version }}' |
| 154 | + extensions: '${{ env.extensions }}' |
| 155 | + key: '${{ env.cache-version }}' |
| 156 | + |
| 157 | + - name: 'Cache PHP extensions' |
| 158 | + uses: 'actions/cache@v2' |
| 159 | + with: |
| 160 | + path: '${{ steps.extcache.outputs.dir }}' |
| 161 | + key: '${{ steps.extcache.outputs.key }}' |
| 162 | + restore-keys: '${{ steps.extcache.outputs.key }}' |
| 163 | + |
| 164 | + - name: 'Install PHP' |
| 165 | + uses: 'shivammathur/setup-php@v2' |
| 166 | + with: |
| 167 | + php-version: '${{ matrix.php-version }}' |
| 168 | + extensions: '${{ env.extensions }}' |
| 169 | + tools: 'composer:${{ env.composer-version }}' |
| 170 | + |
| 171 | + - name: 'Setup problem matchers for PHP' |
| 172 | + run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"' |
| 173 | + |
| 174 | + - name: 'Get Composer cache directory' |
| 175 | + id: 'composercache' |
| 176 | + run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"' |
| 177 | + |
| 178 | + - name: 'Cache PHP dependencies' |
| 179 | + uses: 'actions/cache@v2' |
| 180 | + with: |
| 181 | + path: '${{ steps.composercache.outputs.dir }}' |
| 182 | + key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}" |
| 183 | + restore-keys: '${{ runner.os }}-composer-' |
| 184 | + |
| 185 | + - name: 'Install dependencies' |
| 186 | + run: '${{ env.composer-install }} ${{ matrix.composer-args }}' |
| 187 | + |
| 188 | + - name: 'Tests' |
| 189 | + run: 'vendor/bin/tester tests -C' |
| 190 | + |
| 191 | + tests_code_coverage: |
| 192 | + name: 'Tests with code coverage' |
| 193 | + runs-on: '${{ matrix.operating-system }}' |
| 194 | + |
| 195 | + strategy: |
| 196 | + matrix: |
| 197 | + php-version: [ '7.4' ] |
| 198 | + operating-system: [ 'ubuntu-latest' ] |
| 199 | + fail-fast: false |
| 200 | + |
| 201 | + if: "github.event_name == 'push'" |
| 202 | + |
| 203 | + steps: |
| 204 | + - name: 'Checkout' |
| 205 | + uses: 'actions/checkout@v2' |
| 206 | + |
| 207 | + - name: 'Setup PHP cache environment' |
| 208 | + id: 'extcache' |
| 209 | + uses: 'shivammathur/cache-extensions@v1' |
| 210 | + with: |
| 211 | + php-version: '${{ matrix.php-version }}' |
| 212 | + extensions: '${{ env.extensions }}' |
| 213 | + key: '${{ env.cache-version }}' |
| 214 | + |
| 215 | + - name: 'Cache PHP extensions' |
| 216 | + uses: 'actions/cache@v2' |
| 217 | + with: |
| 218 | + path: '${{ steps.extcache.outputs.dir }}' |
| 219 | + key: '${{ steps.extcache.outputs.key }}' |
| 220 | + restore-keys: '${{ steps.extcache.outputs.key }}' |
| 221 | + |
| 222 | + - name: 'Install PHP' |
| 223 | + uses: 'shivammathur/setup-php@v2' |
| 224 | + with: |
| 225 | + php-version: '${{ matrix.php-version }}' |
| 226 | + extensions: '${{ env.extensions }}' |
| 227 | + tools: 'composer:${{ env.composer-version }}' |
| 228 | + |
| 229 | + - name: 'Setup problem matchers for PHP' |
| 230 | + run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"' |
| 231 | + |
| 232 | + - name: 'Get Composer cache directory' |
| 233 | + id: 'composercache' |
| 234 | + run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"' |
| 235 | + |
| 236 | + - name: 'Cache PHP dependencies' |
| 237 | + uses: 'actions/cache@v2' |
| 238 | + with: |
| 239 | + path: '${{ steps.composercache.outputs.dir }}' |
| 240 | + key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}" |
| 241 | + restore-keys: '${{ runner.os }}-composer-' |
| 242 | + |
| 243 | + - name: 'Install dependencies' |
| 244 | + run: '${{ env.composer-install }}' |
| 245 | + |
| 246 | + - name: 'Tests' |
| 247 | + run: vendor/bin/tester tests -C --coverage coverage.xml --coverage-src src |
| 248 | + |
| 249 | + - uses: codecov/codecov-action@v1 |
| 250 | + with: |
| 251 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 252 | + fail_ci_if_error: true |
0 commit comments