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