name: CI on: push: branches: [ main, master ] pull_request: branches: [ main, master ] jobs: test: runs-on: ubuntu-latest strategy: matrix: php: [ '8.2', '8.3' ] services: mysql: image: mysql:8 env: MYSQL_ROOT_PASSWORD: root MYSQL_DATABASE: pairity ports: - 3306:3306 options: >- --health-cmd "mysqladmin ping -h 127.0.0.1 -proot" --health-interval 10s --health-timeout 5s --health-retries 20 mongo: image: mongo:6 ports: - 27017:27017 options: >- --health-cmd "mongosh --eval 'db.runCommand({ ping: 1 })' || exit 1" --health-interval 10s --health-timeout 5s --health-retries 30 postgres: image: postgres:15 env: POSTGRES_PASSWORD: postgres POSTGRES_DB: pairity POSTGRES_USER: postgres ports: - 5432:5432 options: >- --health-cmd "pg_isready -U postgres" --health-interval 10s --health-timeout 5s --health-retries 20 steps: - name: Checkout uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} # Pin ext-mongodb to a 1.21+ line compatible with mongodb/mongodb ^1.20 (which resolves to 1.21+) extensions: pdo, pdo_mysql, pdo_sqlite, pdo_pgsql, mongodb-1.21.0 coverage: none - name: Install dependencies run: | composer install --no-interaction --prefer-dist - name: Prepare MySQL run: | sudo apt-get update # wait for mysql to be healthy for i in {1..30}; do if mysqladmin ping -h 127.0.0.1 -proot --silent; then break fi sleep 2 done mysql -h 127.0.0.1 -uroot -proot -e 'CREATE DATABASE IF NOT EXISTS pairity;' - name: Prepare Postgres run: | for i in {1..30}; do if pg_isready -h 127.0.0.1 -p 5432 -U postgres; then break fi sleep 2 done - name: Run tests env: MYSQL_HOST: 127.0.0.1 MYSQL_PORT: 3306 MYSQL_DB: pairity MYSQL_USER: root MYSQL_PASS: root MONGO_HOST: 127.0.0.1 MONGO_PORT: 27017 POSTGRES_HOST: 127.0.0.1 POSTGRES_PORT: 5432 POSTGRES_DB: pairity POSTGRES_USER: postgres POSTGRES_PASS: postgres run: | vendor/bin/phpunit --colors=always - name: Static analysis (PHPStan) run: | if [ -f phpstan.neon.dist ]; then vendor/bin/phpstan analyse --no-progress || true; fi - name: Style check (PHPCS) run: | if [ -f phpcs.xml.dist ]; then vendor/bin/phpcs || true; fi