4544: POC for using FrankenPHP behind Traefik #99
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Doctrine | |
| env: | |
| COMPOSE_USER: root | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| - develop | |
| jobs: | |
| validate-doctrine-schema: | |
| name: Validate Doctrine Schema | |
| runs-on: ubuntu-latest | |
| env: | |
| APP_ENV: prod | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Create docker network | |
| run: | | |
| docker network create frontend | |
| - name: Run Composer Install | |
| run: | | |
| docker compose run --rm frankenphp composer install | |
| - name: Run Doctrine Migrations | |
| run: | | |
| docker compose run --rm frankenphp bin/console doctrine:migrations:migrate --no-interaction | |
| - name: Setup messenger "failed" doctrine transport to ensure db schema is updated | |
| run: | | |
| docker compose run --rm frankenphp bin/console messenger:setup-transports failed | |
| - name: Validate Doctrine schema | |
| run: | | |
| docker compose run --rm frankenphp bin/console doctrine:schema:validate | |
| load-fixtures: | |
| name: Load Doctrine fixtures | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Create docker network | |
| run: | | |
| docker network create frontend | |
| - name: Run Composer Install | |
| run: | | |
| docker compose run --rm frankenphp composer install --no-interaction | |
| - name: Run Doctrine Migrations | |
| run: | | |
| docker compose run --rm frankenphp bin/console doctrine:migrations:migrate --no-interaction | |
| - name: Load fixtures | |
| run: | | |
| docker compose run --rm frankenphp composer fixtures | |
| # The jobs above migrate an empty database. A deployment migrates a database | |
| # that already holds rows, so a migration that cannot cope with existing | |
| # data passes those jobs unnoticed. This job builds the database as it looks | |
| # before the pull request, fixtures included, and then applies the pull | |
| # request's migrations on top of it. | |
| migrate-populated-database: | |
| name: Run migrations on a populated database | |
| runs-on: ubuntu-latest | |
| # This workflow also runs on pushes to main and develop, where there is | |
| # no pull request to read a base branch from: the checkout steps below | |
| # would get an empty revision and fail. A push has no base to compare | |
| # against, so skip the job rather than guess one. | |
| if: github.event_name == 'pull_request' | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Create docker network | |
| run: | | |
| docker network create frontend | |
| - name: Check out the base branch | |
| run: | | |
| git checkout ${{ github.event.pull_request.base.sha }} | |
| - name: Resolve the PHP service name | |
| run: | | |
| # This job straddles two revisions of docker-compose.yml: one | |
| # of them may still call the PHP service phpfpm while the | |
| # other calls it frankenphp. | |
| if docker compose config --services | grep -qx frankenphp; then | |
| echo "PHP_SERVICE=frankenphp" >> "$GITHUB_ENV" | |
| else | |
| echo "PHP_SERVICE=phpfpm" >> "$GITHUB_ENV" | |
| fi | |
| - name: Run Composer Install | |
| run: | | |
| docker compose run --rm "$PHP_SERVICE" composer install --no-interaction | |
| - name: Run Doctrine Migrations | |
| run: | | |
| docker compose run --rm "$PHP_SERVICE" bin/console doctrine:migrations:migrate --no-interaction | |
| - name: Load fixtures | |
| run: | | |
| docker compose run --rm "$PHP_SERVICE" composer fixtures | |
| - name: Check out the pull request | |
| run: | | |
| git checkout ${{ github.event.pull_request.head.sha }} | |
| - name: Resolve the PHP service name | |
| run: | | |
| # This job straddles two revisions of docker-compose.yml: one | |
| # of them may still call the PHP service phpfpm while the | |
| # other calls it frankenphp. | |
| if docker compose config --services | grep -qx frankenphp; then | |
| echo "PHP_SERVICE=frankenphp" >> "$GITHUB_ENV" | |
| else | |
| echo "PHP_SERVICE=phpfpm" >> "$GITHUB_ENV" | |
| fi | |
| - name: Run Composer Install | |
| run: | | |
| docker compose run --rm "$PHP_SERVICE" composer install --no-interaction | |
| - name: Run Doctrine Migrations on the populated database | |
| run: | | |
| docker compose run --rm "$PHP_SERVICE" bin/console doctrine:migrations:migrate --no-interaction |