|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +jobs: |
| 6 | + testsuite: |
| 7 | + runs-on: ubuntu-18.04 |
| 8 | + strategy: |
| 9 | + fail-fast: false |
| 10 | + matrix: |
| 11 | + php-version: ['7.2', '7.4'] |
| 12 | + db-type: [sqlite, mysql, pgsql] |
| 13 | + prefer-lowest: [''] |
| 14 | + include: |
| 15 | + - php-version: '7.2' |
| 16 | + db-type: 'sqlite' |
| 17 | + prefer-lowest: 'prefer-lowest' |
| 18 | + |
| 19 | + services: |
| 20 | + postgres: |
| 21 | + image: postgres |
| 22 | + ports: |
| 23 | + - 5432:5432 |
| 24 | + env: |
| 25 | + POSTGRES_PASSWORD: postgres |
| 26 | + |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v1 |
| 29 | + with: |
| 30 | + fetch-depth: 1 |
| 31 | + |
| 32 | + - name: Setup Service |
| 33 | + if: matrix.db-type == 'mysql' |
| 34 | + run: | |
| 35 | + sudo service mysql start |
| 36 | + mysql -h 127.0.0.1 -u root -proot -e 'CREATE DATABASE cakephp;' |
| 37 | +
|
| 38 | + - name: Setup PHP |
| 39 | + uses: shivammathur/setup-php@v2 |
| 40 | + with: |
| 41 | + php-version: ${{ matrix.php-version }} |
| 42 | + extensions: mbstring, intl, pdo_${{ matrix.db-type }} |
| 43 | + coverage: pcov |
| 44 | + |
| 45 | + - name: Composer install |
| 46 | + run: | |
| 47 | + if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then |
| 48 | + composer update --prefer-lowest --prefer-stable |
| 49 | + else |
| 50 | + composer install |
| 51 | + fi |
| 52 | +
|
| 53 | + - name: Run PHPUnit |
| 54 | + run: | |
| 55 | + if [[ ${{ matrix.db-type }} == 'sqlite' ]]; then export DB_URL='sqlite:///:memory:'; fi |
| 56 | + if [[ ${{ matrix.db-type }} == 'mysql' ]]; then export DB_URL='mysql://root:[email protected]/cakephp'; fi |
| 57 | + if [[ ${{ matrix.db-type }} == 'pgsql' ]]; then export DB_URL='postgres://postgres:[email protected]/postgres'; fi |
| 58 | +
|
| 59 | + if [[ ${{ matrix.php-version }} == '7.4' && ${{ matrix.db-type }} == 'sqlite' ]]; then |
| 60 | + vendor/bin/phpunit --coverage-clover=coverage.xml |
| 61 | + else |
| 62 | + vendor/bin/phpunit |
| 63 | + fi |
| 64 | +
|
| 65 | + - name: Code Coverage Report |
| 66 | + if: success() && matrix.php-version == '7.4' && matrix.db-type == 'sqlite' |
| 67 | + uses: codecov/codecov-action@v1 |
| 68 | + |
| 69 | + cs-stan: |
| 70 | + name: Coding Standard & Static Analysis |
| 71 | + runs-on: ubuntu-18.04 |
| 72 | + |
| 73 | + steps: |
| 74 | + - uses: actions/checkout@v1 |
| 75 | + with: |
| 76 | + fetch-depth: 1 |
| 77 | + |
| 78 | + - name: Setup PHP |
| 79 | + uses: shivammathur/setup-php@v2 |
| 80 | + with: |
| 81 | + php-version: '7.4' |
| 82 | + extension: mbstring, intl |
| 83 | + coverage: none |
| 84 | + tools: cs2pr, phpstan:^0.12 |
| 85 | + |
| 86 | + - name: Composer Install |
| 87 | + run: composer install |
| 88 | + |
| 89 | + - name: Run phpcs |
| 90 | + run: vendor/bin/phpcs --report=checkstyle --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/ tests/ | cs2pr |
| 91 | + |
| 92 | + - name: Run phpstan |
| 93 | + if: success() || failure() |
| 94 | + run: phpstan analyse |
0 commit comments