CodeIgniter4/.github/workflows/test-phpunit.yml
2022-01-10 02:02:55 +00:00

156 lines
4.9 KiB
YAML

name: PHPUnit
on:
push:
branches:
- develop
paths:
- composer.json
- spark
- phpunit.xml.dist
- '**.php'
- .github/workflows/test-phpunit.yml
pull_request:
branches:
- develop
- '4.*'
paths:
- composer.json
- spark
- phpunit.xml.dist
- '**.php'
- .github/workflows/test-phpunit.yml
jobs:
tests:
name: PHP ${{ matrix.php-versions }} - ${{ matrix.db-platforms }}
runs-on: ubuntu-20.04
if: "!contains(github.event.head_commit.message, '[ci skip]')"
strategy:
fail-fast: false
matrix:
php-versions: ['7.4', '8.0', '8.1']
db-platforms: ['MySQLi', 'Postgre', 'SQLite3', 'SQLSRV']
mysql-versions: ['5.7']
include:
- php-versions: '7.4'
db-platforms: MySQLi
mysql-versions: '8.0'
services:
mysql:
image: mysql:${{ matrix.mysql-versions }}
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: test
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
postgres:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test
ports:
- 5432:5432
options: --health-cmd=pg_isready --health-interval=10s --health-timeout=5s --health-retries=3
mssql:
image: mcr.microsoft.com/mssql/server:2019-CU10-ubuntu-20.04
env:
SA_PASSWORD: 1Secure*Password1
ACCEPT_EULA: Y
MSSQL_PID: Developer
ports:
- 1433:1433
options: --health-cmd="/opt/mssql-tools/bin/sqlcmd -S 127.0.0.1 -U sa -P 1Secure*Password1 -Q 'SELECT @@VERSION'" --health-interval=10s --health-timeout=5s --health-retries=3
redis:
image: redis
ports:
- 6379:6379
options: --health-cmd "redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
memcached:
image: memcached:1.6-alpine
ports:
- 11211:11211
steps:
- name: Create database for MSSQL Server
if: matrix.db-platforms == 'SQLSRV'
run: sqlcmd -S 127.0.0.1 -U sa -P 1Secure*Password1 -Q "CREATE DATABASE test"
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: composer, pecl
extensions: imagick, sqlsrv, gd, sqlite3, redis, memcached, pgsql
coverage: xdebug
env:
update: true
- name: Install latest ImageMagick
run: |
sudo apt-get update
sudo apt-get install --reinstall libgs9-common fonts-noto-mono libgs9:amd64 libijs-0.35:amd64 fonts-urw-base35 ghostscript poppler-data libjbig2dec0:amd64 gsfonts libopenjp2-7:amd64 fonts-droid-fallback ttf-dejavu-core
sudo apt-get install -y imagemagick
sudo apt-get install --fix-broken
- name: Get composer cache directory
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: |
composer update --ansi --no-interaction
composer remove --ansi --dev --unused -W -- rector/rector phpstan/phpstan friendsofphp/php-cs-fixer nexusphp/cs-config codeigniter/coding-standard
env:
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}
- name: Profile slow tests in PHP 8.0
if: matrix.php-versions == '8.0'
run: echo "TACHYCARDIA_MONITOR_GA=enabled" >> $GITHUB_ENV
- name: Test with PHPUnit
run: script -e -c "vendor/bin/phpunit --color=always --exclude-group=auto-review"
env:
DB: ${{ matrix.db-platforms }}
TERM: xterm-256color
- name: Run Coveralls
if: github.repository_owner == 'codeigniter4' && matrix.php-versions == '8.0'
run: |
composer global require --ansi php-coveralls/php-coveralls:^2.4
php-coveralls --coverage_clover=build/logs/clover.xml -v
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_PARALLEL: true
COVERALLS_FLAG_NAME: PHP ${{ matrix.php-versions }} - ${{ matrix.db-platforms }}
coveralls-finish:
if: github.repository_owner == 'codeigniter4'
needs: [tests]
runs-on: ubuntu-20.04
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true