Skip to content

[6.x] Improve laravel-ci #1127

[6.x] Improve laravel-ci

[6.x] Improve laravel-ci #1127

Workflow file for this run

name: 'ci / Laravel'
on:
workflow_dispatch:
push:
branches:
- main
- 6.x
pull_request:
concurrency:
group: laravel-ci-${{ github.ref }}
cancel-in-progress: true
jobs:
pint:
name: 'Code Quality / Pint'
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
extensions: json, dom, curl, libxml, mbstring
tools: composer:v2, laravel/pint
coverage: none
- name: Run Pint
run: pint --parallel --test --verbose
rector:
name: 'Code Quality / Rector'
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMPOSER_AUTH_JSON: |
{
"http-basic": {
"repo.packagist.com": {
"username": "${{ secrets.packagist_username }}",
"password": "${{ secrets.packagist_token }}"
}
}
}
- name: Set version
run: composer config version "6.x-dev"
- name: Install dependencies
uses: ramsey/composer-install@v3
- name: Rector Cache
uses: actions/cache@v4
with:
path: /tmp/rector
key: ${{ runner.os }}-rector-${{ github.run_id }}
restore-keys: ${{ runner.os }}-rector-
- run: mkdir -p /tmp/rector
- name: Run Rector
run: vendor/bin/rector process --dry-run --ansi
phpstan:
name: 'Code Quality / Phpstan'
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v5
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
tools: composer:v2
coverage: none
- name: Set version
run: composer config version "6.x-dev"
- name: Install composer dependencies
uses: ramsey/composer-install@v3
- name: PHPStan Cache
uses: actions/cache@v4
with:
path: /tmp/phpstan
key: ${{ runner.os }}-phpstan-${{ github.run_id }}
restore-keys: ${{ runner.os }}-phpstan-
- name: Run PHPStan
run: ./vendor/bin/phpstan --error-format=github
unit-tests:
needs: [pint, phpstan, rector]
name: 'Tests / Unit'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run tests
uses: ./.github/actions/run-tests
with:
test-command: ./vendor/bin/pest --ci --compact --testsuite=Unit
github-token: ${{ secrets.GITHUB_TOKEN }}
packagist-username: ${{ secrets.packagist_username }}
packagist-token: ${{ secrets.packagist_token }}
arch-tests:
needs: [pint, phpstan, rector]
name: 'Tests / Arch'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run tests
uses: ./.github/actions/run-tests
with:
test-command: ./vendor/bin/pest --ci --testsuite=Arch
github-token: ${{ secrets.GITHUB_TOKEN }}
packagist-username: ${{ secrets.packagist_username }}
packagist-token: ${{ secrets.packagist_token }}
feature-tests:
needs: [pint, phpstan, rector]
name: 'Tests / Feature on ${{ matrix.db }}'
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: true
matrix:
db: [mysql, pgsql]
services:
pgsql:
image: ${{ (matrix.db == 'pgsql') && 'postgres:latest' || '' }}
env:
POSTGRES_USER: root
POSTGRES_PASSWORD: mysecretpassword
POSTGRES_DB: craft_test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
mysql:
image: ${{ (matrix.db == 'mysql') && 'mysql:8.0' || '' }}
env:
MYSQL_ROOT_PASSWORD: mysecretpassword
MYSQL_DATABASE: craft_test
MYSQL_AUTHENTICATION_PLUGIN: mysql_native_password
options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 5
ports:
- 3306:3306
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Copy tests .env
run: |
cp ./tests/.env.example.${{ matrix.db }} ./tests/.env
sed -i 's/DB_PASSWORD=/DB_PASSWORD=mysecretpassword/' tests/.env
- name: Run tests
uses: ./.github/actions/run-tests
with:
test-command: ./vendor/bin/pest --ci --compact --testsuite=Feature
github-token: ${{ secrets.GITHUB_TOKEN }}
packagist-username: ${{ secrets.packagist_username }}
packagist-token: ${{ secrets.packagist_token }}
yii2-adapter-tests:
needs: [pint, phpstan, rector]
name: 'Tests / Yii2 Adapter'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run tests
uses: ./.github/actions/run-tests
with:
test-command: vendor/bin/pest --ci --compact --configuration ./yii2-adapter/phpunit.xml.dist --test-directory ./yii2-adapter/tests-laravel
github-token: ${{ secrets.GITHUB_TOKEN }}
packagist-username: ${{ secrets.packagist_username }}
packagist-token: ${{ secrets.packagist_token }}
working-directory: yii2-adapter