|
| 1 | +name: build |
| 2 | + |
| 3 | +on: |
| 4 | + - push |
| 5 | + - pull_request |
| 6 | + |
| 7 | +jobs: |
| 8 | + tests: |
| 9 | + name: PHP ${{ matrix.php }} Test on ${{ matrix.os }} |
| 10 | + |
| 11 | + env: |
| 12 | + extensions: bz2, dom, iconv, fileinfo, openssl, xml, zlib |
| 13 | + key: cache-v1 |
| 14 | + PHPUNIT_COVERAGE: 0 |
| 15 | + PHP_INI: date.timezone='UTC', memory_limit=-1, opcache.enable=1, opcache.enable_cli=1 |
| 16 | + |
| 17 | + strategy: |
| 18 | + matrix: |
| 19 | + os: |
| 20 | + - ubuntu-latest |
| 21 | + - windows-latest |
| 22 | + - macos-latest |
| 23 | + php: |
| 24 | + - '7.4' |
| 25 | + - '8.0' |
| 26 | + |
| 27 | + runs-on: ${{ matrix.os }} |
| 28 | + |
| 29 | + steps: |
| 30 | + - |
| 31 | + name: Checkout |
| 32 | + uses: actions/checkout@v1 |
| 33 | + |
| 34 | + - |
| 35 | + name: Install linux dependencies |
| 36 | + if: matrix.os == 'ubuntu-latest' |
| 37 | + run: sudo apt-get install unzip p7zip-full |
| 38 | + |
| 39 | + - |
| 40 | + name: Install windows dependencies |
| 41 | + if: matrix.os == 'windows-latest' |
| 42 | + run: choco install zip unzip 7zip |
| 43 | + |
| 44 | + - |
| 45 | + name: Install macos dependencies |
| 46 | + if: matrix.os == 'macos-latest' |
| 47 | + run: brew install zip unzip p7zip |
| 48 | + |
| 49 | + - |
| 50 | + name: Install PHP with extensions |
| 51 | + uses: shivammathur/setup-php@v2 |
| 52 | + with: |
| 53 | + php-version: 7.4 |
| 54 | + extensions: ${{ env.extensions }} |
| 55 | + coverage: pcov |
| 56 | + ini-values: ${{ env.PHP_INI }} |
| 57 | + tools: composer:v2, cs2pr |
| 58 | + |
| 59 | + - |
| 60 | + name: Determine composer cache directory on Linux or MacOS |
| 61 | + if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' |
| 62 | + run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV |
| 63 | + |
| 64 | + - |
| 65 | + name: Determine composer cache directory on Windows |
| 66 | + if: matrix.os == 'windows-latest' |
| 67 | + run: echo "COMPOSER_CACHE_DIR=~\AppData\Local\Composer" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
| 68 | + |
| 69 | + - |
| 70 | + name: Set coverage args |
| 71 | + if: matrix.os == 'ubuntu-latest' && matrix.php == '8.0' |
| 72 | + run: echo "PHPUNIT_COVERAGE=1" >> $GITHUB_ENV |
| 73 | + |
| 74 | + - |
| 75 | + name: Cache composer dependencies |
| 76 | + uses: actions/cache@v2 |
| 77 | + with: |
| 78 | + path: ${{ env.COMPOSER_CACHE_DIR }} |
| 79 | + key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }} |
| 80 | + restore-keys: php${{ matrix.php }}-composer- |
| 81 | + |
| 82 | + - |
| 83 | + name: Check PHP Version |
| 84 | + run: php -v |
| 85 | + |
| 86 | + - |
| 87 | + name: Check Composer Version |
| 88 | + run: composer -V |
| 89 | + |
| 90 | + - |
| 91 | + name: Check PHP Extensions |
| 92 | + run: php -m |
| 93 | + |
| 94 | + - |
| 95 | + name: Validate composer.json and composer.lock |
| 96 | + run: composer validate |
| 97 | + |
| 98 | + - |
| 99 | + name: Install dependencies with composer |
| 100 | + run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi |
| 101 | + |
| 102 | + - |
| 103 | + name: Run tests with phpunit |
| 104 | + if: env.PHPUNIT_COVERAGE == 0 |
| 105 | + run: vendor/bin/phpunit -v --testsuite "all_tests" --group small,medium,large |
| 106 | + |
| 107 | + - |
| 108 | + name: Run tests with phpunit and coverage |
| 109 | + if: env.PHPUNIT_COVERAGE == 1 |
| 110 | + run: vendor/bin/phpunit -v --coverage-clover=coverage.clover --testsuite "all_tests" --group small,medium,large |
| 111 | + |
| 112 | + - |
| 113 | + name: Static analysis |
| 114 | + run: vendor/bin/psalm --shepherd --stats --output-format=checkstyle | cs2pr --graceful-warnings --colorize |
| 115 | + |
| 116 | + - |
| 117 | + name: Upload code coverage scrutinizer |
| 118 | + if: env.PHPUNIT_COVERAGE == 1 |
| 119 | + run: | |
| 120 | + wget https://scrutinizer-ci.com/ocular.phar |
| 121 | + php ocular.phar code-coverage:upload --format=php-clover coverage.clover |
0 commit comments