Skip to content

Commit 0d0be15

Browse files
turegjorupclaude
andcommitted
5402: Dockerize remaining PHP workflows and align on PHP 8.4
Replace shivammathur/setup-php with docker compose runs against the phpfpm service so all PHP CI runs match the local docker setup (itkdev/php8.4-fpm). phpunit and doctrine now reuse compose's mariadb instead of GitHub services. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent beeb375 commit 0d0be15

6 files changed

Lines changed: 53 additions & 185 deletions

File tree

.github/workflows/apispec.yaml

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,33 @@ on: pull_request
22

33
name: Api Spec
44

5+
env:
6+
COMPOSE_USER: runner
7+
58
jobs:
69
apispec:
710
runs-on: ubuntu-latest
811
name: API Specification validation
9-
strategy:
10-
fail-fast: false
11-
matrix:
12-
php: ["8.3"]
1312
steps:
1413
- name: Checkout
1514
uses: actions/checkout@v4
1615
with:
1716
fetch-depth: 2
1817

19-
- name: Setup PHP, with composer and extensions
20-
uses: shivammathur/setup-php@v2
21-
with:
22-
php-version: ${{ matrix.php}}
23-
extensions: apcu, ctype, iconv, imagick, json, redis, soap, xmlreader, zip
24-
coverage: none
25-
26-
- name: Get composer cache directory
27-
id: composer-cache
28-
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
29-
30-
- name: Cache composer dependencies
31-
uses: actions/cache@v4
32-
with:
33-
path: ${{ steps.composer-cache.outputs.dir }}
34-
key: ${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
35-
restore-keys: ${{ matrix.php }}-composer-
18+
- name: Setup network
19+
run: docker network create frontend
3620

3721
- name: Install Dependencies
38-
run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist
22+
run: docker compose run --rm phpfpm composer install
3923

4024
- name: Export specifications (yaml)
41-
run: bin/console api:openapi:export --yaml --output=public/api-spec-v2.yaml --no-interaction
25+
run: docker compose run --rm phpfpm bin/console api:openapi:export --yaml --output=public/api-spec-v2.yaml --no-interaction
4226

4327
- name: Check for changes in specifications (yaml)
4428
run: git diff --diff-filter=ACMRT --exit-code public/api-spec-v2.yaml
4529

4630
- name: Export specifications (json)
47-
run: bin/console api:openapi:export --output=public/api-spec-v2.json --no-interaction
31+
run: docker compose run --rm phpfpm bin/console api:openapi:export --output=public/api-spec-v2.json --no-interaction
4832

4933
- name: Check for changes in specifications (json)
5034
run: git diff --diff-filter=ACMRT --exit-code public/api-spec-v2.json

.github/workflows/composer_install.yaml

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,19 @@ on: pull_request
22

33
name: Composer install
44

5+
env:
6+
COMPOSE_USER: runner
7+
58
jobs:
69
test-composer-install:
710
runs-on: ubuntu-latest
8-
env:
9-
COMPOSER_ALLOW_SUPERUSER: 1
10-
strategy:
11-
fail-fast: false
12-
matrix:
13-
php: ["8.3"]
14-
name: Composer install in prod mode (PHP ${{ matrix.php}})
11+
name: Composer install in prod mode
1512
steps:
1613
- name: Checkout
1714
uses: actions/checkout@v4
1815

19-
- name: Setup PHP, with composer and extensions
20-
uses: shivammathur/setup-php@v2
21-
with:
22-
php-version: ${{ matrix.php}}
23-
extensions: apcu, ctype, iconv, imagick, json, redis, soap, xmlreader, zip
24-
coverage: none
25-
26-
- name: Get composer cache directory
27-
id: composer-cache
28-
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
29-
30-
- name: Cache composer dependencies
31-
uses: actions/cache@v4
32-
with:
33-
path: ${{ steps.composer-cache.outputs.dir }}
34-
key: ${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
35-
restore-keys: ${{ matrix.php }}-composer-
16+
- name: Setup network
17+
run: docker network create frontend
3618

37-
- name: "[prod] Composer install with exported .env variables"
38-
run: |
39-
set -a && source .env && set +a
40-
APP_ENV=prod composer install --no-dev -o
19+
- name: "[prod] Composer install"
20+
run: docker compose run --rm -e APP_ENV=prod phpfpm composer install --no-dev -o

.github/workflows/doctrine.yaml

Lines changed: 10 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,25 @@ on: pull_request
22

33
name: Doctrine
44

5+
env:
6+
COMPOSE_USER: runner
7+
58
jobs:
69
validate-doctrine-shema:
710
runs-on: ubuntu-latest
8-
env:
9-
DATABASE_URL: mysql://db:db@127.0.0.1:3306/db?serverVersion=mariadb-10.5.13
10-
strategy:
11-
fail-fast: false
12-
matrix:
13-
php: ["8.3"]
14-
name: Validate Schema (PHP ${{ matrix.php}})
15-
services:
16-
mariadb:
17-
image: mariadb:10.5.13
18-
env:
19-
MYSQL_USER: db
20-
MYSQL_PASSWORD: db
21-
MYSQL_DATABASE: db
22-
MYSQL_ROOT_PASSWORD: db
23-
ports:
24-
- 3306:3306
25-
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
11+
name: Validate Schema
2612
steps:
2713
- name: Checkout
2814
uses: actions/checkout@v4
2915

30-
- name: Setup PHP, with composer and extensions
31-
uses: shivammathur/setup-php@v2
32-
with:
33-
php-version: ${{ matrix.php}}
34-
extensions: apcu, ctype, iconv, imagick, json, redis, soap, xmlreader, zip
35-
coverage: none
36-
37-
- name: Get composer cache directory
38-
id: composer-cache
39-
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
40-
41-
- name: Cache composer dependencies
42-
uses: actions/cache@v4
43-
with:
44-
path: ${{ steps.composer-cache.outputs.dir }}
45-
key: ${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
46-
restore-keys: ${{ matrix.php }}-composer-
16+
- name: Setup network
17+
run: docker network create frontend
4718

48-
- name: "Composer install with exported .env variables"
49-
run: |
50-
set -a && source .env && set +a
51-
APP_ENV=prod composer install --no-dev -o
19+
- name: "[prod] Composer install"
20+
run: docker compose run --rm -e APP_ENV=prod phpfpm composer install --no-dev -o
5221

5322
- name: Run Doctrine Migrations
54-
run: APP_ENV=prod php bin/console doctrine:migrations:migrate --no-interaction
23+
run: docker compose run --rm -e APP_ENV=prod phpfpm bin/console doctrine:migrations:migrate --no-interaction
5524

5625
- name: Validate Doctrine schema
57-
run: APP_ENV=prod php bin/console doctrine:schema:validate
26+
run: docker compose run --rm -e APP_ENV=prod phpfpm bin/console doctrine:schema:validate

.github/workflows/phpunit.yaml

Lines changed: 11 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,58 +2,25 @@ on: pull_request
22

33
name: Test
44

5+
env:
6+
COMPOSE_USER: runner
7+
58
jobs:
69
phpunit:
710
runs-on: ubuntu-latest
8-
services:
9-
mariadb:
10-
image: mariadb:lts
11-
ports:
12-
- 3306
13-
env:
14-
MYSQL_USER: db
15-
MYSQL_PASSWORD: db
16-
MYSQL_DATABASE: db_test
17-
MYSQL_ROOT_PASSWORD: password
18-
# https://mariadb.org/mariadb-server-docker-official-images-healthcheck-without-mysqladmin/
19-
options: >-
20-
--health-cmd="healthcheck.sh --connect --innodb_initialized"
21-
--health-interval=5s
22-
--health-timeout=2s
23-
--health-retries=3
24-
strategy:
25-
fail-fast: false
26-
matrix:
27-
php: ["8.3"]
28-
name: PHP Unit tests (PHP ${{ matrix.php }})
11+
name: PHP Unit tests
2912
steps:
3013
- name: Checkout
3114
uses: actions/checkout@v4
3215

33-
- name: Setup PHP, with composer and extensions
34-
uses: shivammathur/setup-php@v2
35-
with:
36-
php-version: ${{ matrix.php}}
37-
extensions: apcu, ctype, iconv, imagick, json, redis, soap, xmlreader, zip
38-
coverage: none
39-
40-
- name: Get composer cache directory
41-
id: composer-cache
42-
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
43-
44-
- name: Cache composer dependencies
45-
uses: actions/cache@v4
46-
with:
47-
path: ${{ steps.composer-cache.outputs.dir }}
48-
key: ${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
49-
restore-keys: ${{ matrix.php }}-composer-
16+
- name: Setup network
17+
run: docker network create frontend
5018

5119
- name: Install Dependencies
52-
run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist
20+
run: docker compose run --rm phpfpm composer install
5321

5422
- name: PHP Unit - Test setup
55-
env:
56-
PORT: ${{ job.services.mariadb.ports[3306] }}
57-
run: |
58-
DATABASE_URL="mysql://db:db@127.0.0.1:$PORT/db_test" composer run test-setup
59-
DATABASE_URL="mysql://db:db@127.0.0.1:$PORT/db_test" composer run test
23+
run: docker compose run --rm phpfpm composer run test-setup
24+
25+
- name: PHP Unit - Run tests
26+
run: docker compose run --rm phpfpm composer run test

.github/workflows/psalm.yaml

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,22 @@ on: pull_request
22

33
name: Psalm
44

5+
env:
6+
COMPOSE_USER: runner
7+
58
jobs:
69
psalm:
710
runs-on: ubuntu-latest
8-
strategy:
9-
fail-fast: false
10-
matrix:
11-
php: ["8.3"]
12-
name: Psalm (PHP ${{ matrix.php }})
11+
name: Psalm
1312
steps:
1413
- name: Checkout
1514
uses: actions/checkout@v4
1615

17-
- name: Setup PHP, with composer and extensions
18-
uses: shivammathur/setup-php@v2
19-
with:
20-
php-version: ${{ matrix.php}}
21-
extensions: apcu, ctype, iconv, imagick, json, redis, soap, xmlreader, zip
22-
coverage: none
23-
24-
- name: Get composer cache directory
25-
id: composer-cache
26-
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
27-
28-
- name: Cache composer dependencies
29-
uses: actions/cache@v4
30-
with:
31-
path: ${{ steps.composer-cache.outputs.dir }}
32-
key: ${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
33-
restore-keys: ${{ matrix.php }}-composer-
16+
- name: Setup network
17+
run: docker network create frontend
3418

3519
- name: Install Dependencies
36-
run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist
20+
run: docker compose run --rm phpfpm composer install
3721

3822
- name: Psalm
39-
run: phpdbg -qrr ./vendor/bin/psalm
23+
run: docker compose run --rm phpfpm vendor/bin/psalm

.github/workflows/rector.yaml

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,22 @@ on: pull_request
22

33
name: Rector
44

5+
env:
6+
COMPOSE_USER: runner
7+
58
jobs:
69
rector:
710
runs-on: ubuntu-latest
8-
strategy:
9-
fail-fast: false
10-
matrix:
11-
php: ["8.3"]
12-
name: Rector (PHP ${{ matrix.php }})
11+
name: Rector
1312
steps:
1413
- name: Checkout
1514
uses: actions/checkout@v4
1615

17-
- name: Setup PHP, with composer and extensions
18-
uses: shivammathur/setup-php@v2
19-
with:
20-
php-version: ${{ matrix.php}}
21-
extensions: apcu, ctype, iconv, imagick, json, redis, soap, xmlreader, zip
22-
coverage: none
23-
24-
- name: Get composer cache directory
25-
id: composer-cache
26-
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
27-
28-
- name: Cache composer dependencies
29-
uses: actions/cache@v4
30-
with:
31-
path: ${{ steps.composer-cache.outputs.dir }}
32-
key: ${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
33-
restore-keys: ${{ matrix.php }}-composer-
16+
- name: Setup network
17+
run: docker network create frontend
3418

3519
- name: Install Dependencies
36-
run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist
20+
run: docker compose run --rm phpfpm composer install
3721

3822
- name: Rector
39-
run: phpdbg -qrr ./vendor/bin/rector --dry-run
23+
run: docker compose run --rm phpfpm vendor/bin/rector --dry-run

0 commit comments

Comments
 (0)