|
| 1 | +name: CI |
| 2 | +on: |
| 3 | + push: |
| 4 | + pull_request: |
| 5 | + schedule: |
| 6 | + - cron: '0 0 * * 0' |
| 7 | + |
| 8 | +jobs: |
| 9 | + |
| 10 | + unit-tests: |
| 11 | + name: Unit Tests |
| 12 | + strategy: |
| 13 | + fail-fast: false |
| 14 | + matrix: |
| 15 | + php-version: |
| 16 | + - 7.2 |
| 17 | + - 7.3 |
| 18 | + - 7.4 |
| 19 | + - 8.0 |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - name: Checkout |
| 23 | + uses: actions/checkout@v2 |
| 24 | + |
| 25 | + - name: Setup PHP |
| 26 | + uses: shivammathur/setup-php@v2 |
| 27 | + with: |
| 28 | + php-version: ${{ matrix.php-version }} |
| 29 | + coverage: xdebug |
| 30 | + |
| 31 | + - name: Get composer cache directory |
| 32 | + id: composer-cache |
| 33 | + run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 34 | + |
| 35 | + - name: Cache composer dependencies |
| 36 | + uses: actions/cache@v2 |
| 37 | + with: |
| 38 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 39 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} |
| 40 | + restore-keys: ${{ runner.os }}-composer- |
| 41 | + |
| 42 | + - name: Setup problem matchers |
| 43 | + run: | |
| 44 | + echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" |
| 45 | + echo "::add-matcher::.github/problem-matchers/coverage-check.json" |
| 46 | +
|
| 47 | + - name: Update dependencies |
| 48 | + run: composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader |
| 49 | + |
| 50 | + - name: Run phpunit |
| 51 | + run: vendor/bin/phpunit --testsuite unit-test --coverage-clover=coverage.xml |
| 52 | + |
| 53 | + - name: Check coverage.xml existence |
| 54 | + id: check-coverage-file |
| 55 | + uses: andstor/file-existence-action@v1 |
| 56 | + with: |
| 57 | + files: coverage.xml |
| 58 | + |
| 59 | + - name: Run coverage-check |
| 60 | + if: ${{ always() && steps.check-coverage-file.outputs.files_exists == 'true' }} |
| 61 | + run: vendor/bin/coverage-check coverage.xml 100 |
| 62 | + |
| 63 | + - name: Upload coverage as artifacts |
| 64 | + if: ${{ always() && steps.check-coverage-file.outputs.files_exists == 'true' }} |
| 65 | + uses: actions/upload-artifact@v2 |
| 66 | + with: |
| 67 | + name: coverage-${{ matrix.php-version }} |
| 68 | + path: coverage.xml |
| 69 | + |
| 70 | + - name: Upload coverage to Codecov |
| 71 | + if: ${{ always() && steps.check-coverage-file.outputs.files_exists == 'true' }} |
| 72 | + uses: codecov/codecov-action@v1 |
| 73 | + with: |
| 74 | + name: coverage-${{ matrix.php-version }} |
| 75 | + file: coverage.xml |
| 76 | + |
| 77 | + coding-guidelines: |
| 78 | + name: Coding Guidelines |
| 79 | + runs-on: ubuntu-latest |
| 80 | + steps: |
| 81 | + - name: checkout |
| 82 | + uses: actions/checkout@v2 |
| 83 | + |
| 84 | + - name: Setup PHP |
| 85 | + uses: shivammathur/setup-php@v2 |
| 86 | + with: |
| 87 | + php-version: 7.4 |
| 88 | + tools: cs2pr |
| 89 | + coverage: none |
| 90 | + |
| 91 | + - name: Get composer cache directory |
| 92 | + id: composer-cache |
| 93 | + run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 94 | + |
| 95 | + - name: Cache composer dependencies |
| 96 | + uses: actions/cache@v2 |
| 97 | + with: |
| 98 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 99 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} |
| 100 | + restore-keys: ${{ runner.os }}-composer- |
| 101 | + |
| 102 | + - name: Update dependencies |
| 103 | + run: composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader |
| 104 | + |
| 105 | + - name: Run phpcs |
| 106 | + run: vendor/bin/phpcs -q --report=checkstyle | cs2pr |
| 107 | + |
| 108 | + type-checker: |
| 109 | + name: Type Checker |
| 110 | + runs-on: ubuntu-latest |
| 111 | + steps: |
| 112 | + - name: Checkout |
| 113 | + uses: actions/checkout@v2 |
| 114 | + |
| 115 | + - name: Setup PHP |
| 116 | + uses: shivammathur/setup-php@v2 |
| 117 | + with: |
| 118 | + php-version: 7.4 |
| 119 | + coverage: none |
| 120 | + |
| 121 | + - name: Get composer cache directory |
| 122 | + id: composer-cache |
| 123 | + run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 124 | + |
| 125 | + - name: Cache composer dependencies |
| 126 | + uses: actions/cache@v2 |
| 127 | + with: |
| 128 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 129 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} |
| 130 | + restore-keys: ${{ runner.os }}-composer- |
| 131 | + |
| 132 | + - name: Update dependencies |
| 133 | + run: composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader |
| 134 | + |
| 135 | + - name: Run phpstan |
| 136 | + run: vendor/bin/phpstan analyse --no-interaction |
0 commit comments