|
| 1 | +name: Tests |
| 2 | +on: [pull_request] |
| 3 | + |
| 4 | +env: |
| 5 | + COMPOSER_TOKEN: false |
| 6 | + |
| 7 | +jobs: |
| 8 | + unit-tests: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + strategy: |
| 11 | + matrix: |
| 12 | + php-version: ["7.4", "8.0"] |
| 13 | + |
| 14 | + env: |
| 15 | + EXECUTE_COVERAGE: ${{ matrix.php == '7.4' }} |
| 16 | + MEASURE_COVERAGE: false |
| 17 | + CLOVER_PATH: ".clover.xml" |
| 18 | + |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v2 |
| 21 | + |
| 22 | + - name: Setup PHP |
| 23 | + uses: shivammathur/setup-php@v2 |
| 24 | + with: |
| 25 | + php-version: ${{ matrix.php-version }} |
| 26 | + extensions: mbstring, intl, curl, json |
| 27 | + tools: composer:v2 |
| 28 | + ini-values: xdebug.mode=coverage |
| 29 | + |
| 30 | + - name: Validate composer |
| 31 | + run: composer validate |
| 32 | + |
| 33 | + - name: Get Composer Cache Directory |
| 34 | + id: composer-cache |
| 35 | + run: | |
| 36 | + echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 37 | +
|
| 38 | + - uses: actions/cache@v2 |
| 39 | + with: |
| 40 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 41 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 42 | + restore-keys: | |
| 43 | + ${{ runner.os }}-composer- |
| 44 | +
|
| 45 | + - name: Login composer |
| 46 | + if: env.COMPOSER_TOKEN != 'false' |
| 47 | + run: composer config -g github-oauth.github.com ${{ secrets.COMPOSER_TOKEN }} |
| 48 | + |
| 49 | + - name: Install dependencies |
| 50 | + run: composer install -n --no-suggest |
| 51 | + |
| 52 | + - name: Run PhpUnit with coverage |
| 53 | + if: env.EXECUTE_COVERAGE == 'true' |
| 54 | + run: php vendor/bin/phpunit --testdox --colors=always --coverage-clover ${{ env.CLOVER_PATH }} |
| 55 | + |
| 56 | + - name: Run PhpUnit |
| 57 | + if: env.EXECUTE_COVERAGE != 'true' |
| 58 | + run: php vendor/bin/phpunit --testdox --colors=always |
| 59 | + |
| 60 | + - name: Coverage monitor |
| 61 | + if: env.EXECUTE_COVERAGE == 'true' |
| 62 | + uses: slavcodev/coverage-monitor-action@v1 |
| 63 | + with: |
| 64 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 65 | + clover_file: ${{ env.CLOVER_PATH }} |
| 66 | + threshold_alert: 0 |
| 67 | + threshold_warning: 50 |
| 68 | + comment: ${{ env.MEASURE_COVERAGE }} |
| 69 | + comment_mode: replace |
| 70 | + |
| 71 | + lint: |
| 72 | + runs-on: ubuntu-latest |
| 73 | + strategy: |
| 74 | + max-parallel: 1 |
| 75 | + matrix: |
| 76 | + php-version: ["7.4"] |
| 77 | + |
| 78 | + steps: |
| 79 | + - uses: actions/checkout@v2 |
| 80 | + |
| 81 | + - name: Setup PHP |
| 82 | + uses: shivammathur/setup-php@v2 |
| 83 | + with: |
| 84 | + php-version: ${{ matrix.php-version }} |
| 85 | + extensions: mbstring, intl, curl, json |
| 86 | + tools: composer:v1 |
| 87 | + ini-values: xdebug.mode=coverage |
| 88 | + |
| 89 | + - name: Get Composer Cache Directory |
| 90 | + id: composer-cache |
| 91 | + run: | |
| 92 | + echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 93 | + - uses: actions/cache@v2 |
| 94 | + with: |
| 95 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 96 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 97 | + restore-keys: | |
| 98 | + ${{ runner.os }}-composer- |
| 99 | +
|
| 100 | + - name: Install dependencies |
| 101 | + run: composer install -n --no-suggest |
| 102 | + |
| 103 | + - name: Lint code |
| 104 | + run: php vendor/bin/php-cs-fixer fix -vv --dry-run |
0 commit comments