|
| 1 | +name: Tests |
| 2 | + |
| 3 | +on: [pull_request] |
| 4 | + |
| 5 | +env: |
| 6 | + DEFAULT_COMPOSER_FLAGS: "--prefer-dist --no-interaction --no-progress --optimize-autoloader" |
| 7 | + |
| 8 | +jobs: |
| 9 | + PHPStan: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + strategy: |
| 12 | + fail-fast: false |
| 13 | + |
| 14 | + steps: |
| 15 | + - name: Checkout |
| 16 | + uses: actions/checkout@v2 |
| 17 | + - name: Install PHP |
| 18 | + uses: shivammathur/setup-php@v2 |
| 19 | + with: |
| 20 | + php-version: '7.4' |
| 21 | + extensions: mbstring, intl |
| 22 | + coverage: none |
| 23 | + env: |
| 24 | + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 25 | + update: true |
| 26 | + - name: Get composer cache directory |
| 27 | + id: composer-cache |
| 28 | + run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 29 | + - name: Cache composer dependencies |
| 30 | + uses: actions/cache@v1 |
| 31 | + with: |
| 32 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 33 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} |
| 34 | + restore-keys: ${{ runner.os }}-composer- |
| 35 | + - name: Install dependencies |
| 36 | + run: composer update $DEFAULT_COMPOSER_FLAGS |
| 37 | + - name: PHPStan tests |
| 38 | + run: vendor/bin/phpstan analyze -l 8 -a vendor/yiisoft/yii2/Yii.php --no-progress src |
| 39 | + |
| 40 | + PHPUnit: |
| 41 | + name: PHP ${{ matrix.php }} |
| 42 | + runs-on: ubuntu-latest |
| 43 | + strategy: |
| 44 | + fail-fast: false |
| 45 | + matrix: |
| 46 | + php: ['7.2', '7.3', '7.4'] |
| 47 | + services: |
| 48 | + mysql: |
| 49 | + image: mysql:5.7.29 |
| 50 | + env: |
| 51 | + MYSQL_ALLOW_EMPTY_PASSWORD: false |
| 52 | + MYSQL_ROOT_PASSWORD: password |
| 53 | + MYSQL_DATABASE: migration |
| 54 | + MYSQL_USER: migration |
| 55 | + MYSQL_PASSWORD: password |
| 56 | + ports: |
| 57 | + - 3306/tcp |
| 58 | + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 |
| 59 | + postgres: |
| 60 | + image: postgres:9.6.17 |
| 61 | + env: |
| 62 | + POSTGRES_USER: migration |
| 63 | + POSTGRES_PASSWORD: password |
| 64 | + POSTGRES_DB: migration |
| 65 | + ports: |
| 66 | + - 5432/tcp |
| 67 | + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3 |
| 68 | + |
| 69 | + steps: |
| 70 | + - name: Checkout |
| 71 | + uses: actions/checkout@v2 |
| 72 | + - name: Install PHP |
| 73 | + uses: shivammathur/setup-php@v2 |
| 74 | + with: |
| 75 | + php-version: ${{ matrix.php }} |
| 76 | + extensions: mbstring, intl, mysql, pgsql, sqlite |
| 77 | + coverage: none |
| 78 | + env: |
| 79 | + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 80 | + update: true |
| 81 | + - name: Start MySQL service |
| 82 | + run: sudo /etc/init.d/mysql start |
| 83 | + - name: Get composer cache directory |
| 84 | + id: composer-cache |
| 85 | + run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 86 | + - name: Cache composer dependencies |
| 87 | + uses: actions/cache@v1 |
| 88 | + with: |
| 89 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 90 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} |
| 91 | + restore-keys: ${{ runner.os }}-composer- |
| 92 | + - name: Install dependencies |
| 93 | + run: composer update $DEFAULT_COMPOSER_FLAGS |
| 94 | + - name: Prepare DB connections for tests |
| 95 | + run: printf "<?php\n\n\$config['mysql']['dsn']='mysql:host=127.0.0.1;port=${{ job.services.mysql.ports['3306'] }};dbname=migration';\n\$config['pgsql']['dsn']='pgsql:host=127.0.0.1;port=${{ job.services.postgres.ports['5432'] }};dbname=postgres';\n" >> tests/config.local.php; |
| 96 | + - name: PHPUnit tests |
| 97 | + run: vendor/bin/phpunit --verbose |
0 commit comments