CI/CD Pipeline
Logidav uses a Jenkins-based CI/CD pipeline defined in Jenkinsfile. The pipeline supports three modes -- full, fast, and skip -- depending on the branch and target.
Branch Policy
| Branch | CI Mode | What Runs |
|---|---|---|
main or PR to main | full | Tests, PHPStan, format check, Docker build |
develop or PR to develop | fast | Tests, basic PHPStan |
| other branches | skip | Optional, no automatic pipeline |
Pipeline Stages
The full pipeline runs through these stages sequentially:
In fast mode, the pipeline skips the format check and Docker build stages, running only through PHPStan.
Stage Details
Branch Policy -- Determines whether to run full, fast, or skip based on the branch name and PR target.
Prepare Config -- CI merges .github/parameters.yml into app/config/parameters.yml to provide test-safe configuration values (test database credentials, mock API keys, etc.).
Composer Install -- Installs PHP dependencies. Uses Composer 1 for the main install step due to legacy compatibility requirements.
Schema Dump -- Runs doctrine:schema:update --dump-sql to detect pending schema changes. Review any SQL output carefully -- unexpected schema changes can indicate missing migrations.
PHPUnit Tests -- Runs the full test suite with SYMFONY_DEPRECATIONS_HELPER=weak_vendors. All tests must pass.
PHPStan -- Static analysis at the configured level. Runs with a 2G memory limit (--memory-limit=2G). Both full and fast modes include this check.
Format Check (full mode only) -- Verifies code style compliance using php-cs-fixer --dry-run. Fails if any file does not match PSR-2/PSR-12 standards.
Docker Build (full mode only) -- Builds and pushes Docker images to GHCR (GitHub Container Registry) for deployment.
Email Notification -- Sends build results to committers. Failure emails include the culprit list to identify who introduced the breaking change.
Interpreting Build Results
Test Failures
Check the PHPUnit output in the Jenkins console log. Common causes:
- Missing mock setup -- a test calls a method that was not mocked
- Database state -- test assumes data that does not exist in the CI database
- Environment differences -- code depends on
parameters.ymlvalues not present in CI config
PHPStan Failures
Fix type errors reported by PHPStan. The analysis runs with a 2G memory limit, so out-of-memory errors are rare but possible for very large changesets.
# Run locally to reproduce
vendor/bin/phpstan analyse --memory-limit=2G
Format Failures
The format check uses php-cs-fixer. Fix locally and commit:
# Check what needs fixing
vendor/bin/php-cs-fixer fix --dry-run --diff
# Apply fixes
vendor/bin/php-cs-fixer fix
# Commit the style fixes
git add -p && git commit -m "style: apply php-cs-fixer formatting"
Schema Dump Warnings
If the schema dump stage produces unexpected SQL, it means your entities are out of sync with the database schema. Review the output:
- Expected changes: new columns/tables from your PR -- verify the SQL is correct
- Unexpected changes: changes you did not make -- investigate before merging
Do not ignore schema dump warnings. Unexpected SQL output often indicates a missing or incorrect migration that could cause problems in production.
Docker Images
The pipeline builds two Docker images, pushed to GHCR on main branch changes:
| Image | Dockerfile | Purpose |
|---|---|---|
| PHP CLI | Dockerfile.ci | PHP 7.3 CLI with required extensions for running tests |
| Jenkins Agent | Dockerfile.jenkins-agent | Jenkins agent with Composer 1 + 2 installed |
These images are used by the CI pipeline itself. Changes to Dockerfiles on the main branch trigger a rebuild and push.
Config Preparation
CI configuration lives in .github/parameters.yml and is merged into the application config during the Prepare Config stage. This file contains:
- Test database connection details
- Mock API credentials (non-functional, for test isolation)
- CI-specific feature flags
Never put real production credentials in .github/parameters.yml. This file is committed to the repository and visible to all developers.
Running CI Checks Locally
Before pushing, replicate the CI checks locally:
# 1. Tests
SYMFONY_DEPRECATIONS_HELPER=weak_vendors vendor/bin/simple-phpunit -c phpunit.xml.dist
# 2. PHPStan
vendor/bin/phpstan analyse --memory-limit=2G
# 3. Code style (full mode only)
vendor/bin/php-cs-fixer fix --dry-run --diff
# 4. Schema check
php bin/console doctrine:schema:update --dump-sql -e=dev
If all four pass locally, your PR should pass CI.
See Also
- Testing Guide for writing tests that pass in CI
- Architecture: Runtime & Deployment for pipeline architecture decisions