|
1 | | -name: test |
| 1 | +name: Unit Tests |
2 | 2 |
|
3 | | -on: push |
| 3 | +on: |
| 4 | + pull_request: null |
| 5 | + |
| 6 | +env: |
| 7 | + # see https://github.com/composer/composer/issues/9368#issuecomment-718112361 |
| 8 | + COMPOSER_ROOT_VERSION: "dev-master" |
4 | 9 |
|
5 | 10 | jobs: |
6 | | - phpunit: |
| 11 | + provide_php_versions_json: |
7 | 12 | runs-on: ubuntu-latest |
8 | 13 |
|
9 | 14 | steps: |
10 | | - - name: Checkout |
11 | | - uses: actions/checkout@v2 |
| 15 | + # git clone + use PHP + composer install |
| 16 | + - uses: actions/checkout@v2 |
| 17 | + - uses: shivammathur/setup-php@v2 |
| 18 | + with: |
| 19 | + php-version: 8.0 |
| 20 | + tools: composer:v2 |
12 | 21 |
|
13 | | - - name: Setup PHP |
14 | | - uses: shivammathur/setup-php@v2 |
15 | | - with: |
16 | | - php-version: '8.0' |
17 | | - extensions: mbstring, intl |
18 | | - ini-values: post_max_size=256M, max_execution_time=180 |
19 | | - coverage: xdebug |
20 | | - tools: php-cs-fixer, phpunit |
| 22 | + - run: composer install --no-progress --ansi |
| 23 | + |
| 24 | + - |
| 25 | + # to see the output |
| 26 | + run: vendor/bin/easy-ci php-versions-json |
| 27 | + |
| 28 | + # here we create the json, we need the "id:" so we can use it in "outputs" bellow |
| 29 | + |
| 30 | + - |
| 31 | + id: output_data |
| 32 | + run: echo "::set-output name=matrix::$(vendor/bin/easy-ci php-versions-json)" |
| 33 | + |
| 34 | + # here, we save the result of this 1st phase to the "outputs" |
| 35 | + outputs: |
| 36 | + matrix: ${{ steps.output_data.outputs.matrix }} |
| 37 | + |
| 38 | + unit_tests: |
| 39 | + needs: provide_php_versions_json |
| 40 | + |
| 41 | + runs-on: ubuntu-latest |
21 | 42 |
|
22 | | - - name: Composer dependencies |
23 | | - run: composer install --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist |
| 43 | + strategy: |
| 44 | + fail-fast: false |
| 45 | + matrix: |
| 46 | + php: ${{ fromJson(needs.provide_php_versions_json.outputs.matrix) }} |
| 47 | + |
| 48 | + name: PHP ${{ matrix.php }} tests |
| 49 | + |
| 50 | + steps: |
| 51 | + - uses: actions/checkout@v2 |
| 52 | + # required for "git tag" presence for changelog-linker git tags resolver; default is 1 |
| 53 | + # https://github.com/actions/checkout#fetch-all-tags |
| 54 | + - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* |
| 55 | + |
| 56 | + # see https://github.com/shivammathur/setup-php |
| 57 | + - uses: shivammathur/setup-php@v2 |
| 58 | + with: |
| 59 | + php-version: ${{ matrix.php }} |
| 60 | + extensions: mbstring, intl |
| 61 | + ini-values: post_max_size=256M, max_execution_time=180 |
| 62 | + coverage: xdebug |
| 63 | + tools: php-cs-fixer, phpunit, composer:v2 |
| 64 | + |
| 65 | + # composer install cache - https://github.com/ramsey/composer-install |
| 66 | + - |
| 67 | + if: "matrix.php == 7.3" |
| 68 | + run: composer update --no-progress --ansi --prefer-lowest |
| 69 | + |
| 70 | + - |
| 71 | + if: "matrix.php == 7.4" |
| 72 | + uses: "ramsey/composer-install@v2" |
| 73 | + |
| 74 | + - |
| 75 | + if: "matrix.php >= 8" |
| 76 | + uses: "ramsey/composer-install@v2" |
| 77 | + with: |
| 78 | + composer-options: "--ignore-platform-req php" |
24 | 79 |
|
25 | | - - name: Run Testsuite |
26 | | - run: vendor/bin/phpunit tests/ |
| 80 | + - |
| 81 | + run: vendor/bin/phpunit |
0 commit comments