Template — Backend CI
| Statut | Actif — v1.0 — 2026-06-27 |
| Usage | Copier dans .github/workflows/backend-ci.yml |
| Voir aussi | Playbook CI · Standards |
Usage
Copier dans .github/workflows/backend-ci.yml du projet Laravel.
PHPStan est optionnel : le step est automatiquement sauté si phpstan.neon n'existe pas dans le projet.
Template
name: Backend CI
# Standard DMV — Laravel projects
# Triggers on every PR and push to main.
# Steps: install → pint → phpstan (if present) → tests (with PostgreSQL)
on:
pull_request:
push:
branches:
- main
permissions:
contents: read
jobs:
backend:
name: Quality & Tests
runs-on: ubuntu-latest
timeout-minutes: 15
services:
postgres:
image: postgres:16
env:
POSTGRES_DB: dmv_test
POSTGRES_USER: dmv
POSTGRES_PASSWORD: secret
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
extensions: pdo_pgsql
coverage: none
- name: Install dependencies
run: composer install --no-interaction --prefer-dist --optimize-autoloader
- name: Pint (code style)
run: vendor/bin/pint --test
- name: PHPStan (if configured)
run: |
if [ -f phpstan.neon ] || [ -f phpstan.neon.dist ]; then
vendor/bin/phpstan analyse --no-progress
else
echo "PHPStan not configured — skipping"
fi
- name: Generate test APP_KEY
run: echo "APP_KEY=base64:$(php -r 'echo base64_encode(random_bytes(32));')" >> $GITHUB_ENV
- name: Run migrations
env:
APP_ENV: testing
DB_CONNECTION: pgsql
DB_HOST: 127.0.0.1
DB_PORT: 5432
DB_DATABASE: dmv_test
DB_USERNAME: dmv
DB_PASSWORD: secret
DB_SSLMODE: disable
run: php artisan migrate --force
- name: Run tests
env:
APP_ENV: testing
DB_CONNECTION: pgsql
DB_HOST: 127.0.0.1
DB_PORT: 5432
DB_DATABASE: dmv_test
DB_USERNAME: dmv
DB_PASSWORD: secret
DB_SSLMODE: disable
run: php artisan test
Status check GitHub
Activer dans Branch Protection → Required status checks :
backend / Quality & Tests