|
| 1 | +name: Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ master, develop ] |
| 6 | + pull_request: |
| 7 | + branches: [ master, develop ] |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +jobs: |
| 13 | + tests: |
| 14 | + name: PHP ${{ matrix.php }} Test |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + strategy: |
| 18 | + matrix: |
| 19 | + php: ['7.3', '7.4', '8.0', '8.1'] |
| 20 | + |
| 21 | + services: |
| 22 | + mariadb: |
| 23 | + image: mariadb:10.3 |
| 24 | + ports: |
| 25 | + - 3306:3306 |
| 26 | + env: |
| 27 | + MYSQL_ROOT_PASSWORD: root |
| 28 | + options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3 |
| 29 | + |
| 30 | + steps: |
| 31 | + - name: Checkout |
| 32 | + uses: actions/checkout@v3 |
| 33 | + |
| 34 | + - name: Test migrations |
| 35 | + run: | |
| 36 | + git fetch origin 0.44.1 && git checkout FETCH_HEAD -- structure.sql |
| 37 | + mysql -h127.0.0.1 -P3306 -uroot -proot -e "create database telegrambot_migrations; use telegrambot_migrations; source structure.sql;" |
| 38 | + git checkout HEAD -- structure.sql |
| 39 | + mysql -h127.0.0.1 -P3306 -uroot -proot -e "create database telegrambot; use telegrambot; source structure.sql;" |
| 40 | + for SCHEMA_UPDATE_FILE in $(ls utils/db-schema-update); do mysql -h127.0.0.1 -P3306 -uroot -proot -e "use telegrambot_migrations; source utils/db-schema-update/${SCHEMA_UPDATE_FILE};"; done; |
| 41 | +
|
| 42 | + - name: Install PHP |
| 43 | + uses: shivammathur/setup-php@v2 |
| 44 | + with: |
| 45 | + php-version: ${{ matrix.php }} |
| 46 | + extensions: pdo_mysql |
| 47 | + |
| 48 | + - name: Cache Composer packages |
| 49 | + id: composer-cache |
| 50 | + uses: actions/cache@v3 |
| 51 | + with: |
| 52 | + path: vendor |
| 53 | + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} |
| 54 | + restore-keys: | |
| 55 | + ${{ runner.os }}-php- |
| 56 | +
|
| 57 | + - name: Validate composer.json and composer.lock |
| 58 | + run: composer validate --strict |
| 59 | + |
| 60 | + - name: Install dependencies |
| 61 | + run: composer install --prefer-dist --no-progress |
| 62 | + |
| 63 | + - name: Check PHP code |
| 64 | + run: composer check-code |
| 65 | + |
| 66 | + - name: Run test suite |
| 67 | + if: ${{ matrix.php != '7.3'}} |
| 68 | + run: composer test-cov |
| 69 | + |
| 70 | + - name: Run test suite (with coverage) |
| 71 | + if: ${{ matrix.php == '7.3'}} |
| 72 | + run: | |
| 73 | + composer test-cov |
| 74 | + composer test-cov-upload |
0 commit comments