Skip to content

Commit ee41872

Browse files
committed
Improve GitHub workflow configurations
1 parent e764646 commit ee41872

File tree

5 files changed

+74
-113
lines changed

5 files changed

+74
-113
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
1-
name: Build image
1+
name: Build images
22

3-
on:
4-
pull_request:
5-
push:
3+
on: [pull_request, push]
64

75
jobs:
8-
build-image:
9-
name: Test Docker build
6+
build-standalone:
7+
name: Test standalone build
108
runs-on: ubuntu-latest
119
steps:
12-
-
13-
name: Set up Docker Buildx
10+
- name: Set up Docker Buildx
1411
uses: docker/setup-buildx-action@v3
1512
with:
1613
driver: docker-container
1714

18-
-
19-
name: Build Docker image
15+
- name: Build images
2016
uses: docker/build-push-action@v6
2117
with:
2218
platforms: linux/amd64,linux/arm64
Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,27 @@
1-
name: Publish image
1+
name: Publish images
22

33
on:
44
push:
5-
tags:
6-
- v*
5+
tags: [v*]
76
schedule:
8-
-
9-
cron: "30 4 * * *"
7+
- cron: "30 4 * * *"
108

119
jobs:
12-
publish-image:
13-
name: Publish Docker image
10+
publish-standalone:
11+
name: Publish standalone image
1412
runs-on: ubuntu-latest
1513
permissions:
1614
id-token: write
1715
contents: read
1816
packages: write
1917
attestations: write
2018
steps:
21-
-
22-
name: Set up Docker Buildx
19+
- name: Set up Docker Buildx
2320
uses: docker/setup-buildx-action@v3
2421
with:
2522
driver: docker-container
2623

27-
-
28-
name: Extract metadata for Docker
24+
- name: Extract metadata for Docker
2925
id: meta
3026
uses: docker/metadata-action@v5
3127
with:
@@ -35,16 +31,14 @@ jobs:
3531
type=semver,pattern={{version}}
3632
type=semver,pattern={{major}}.{{minor}}
3733
38-
-
39-
name: Login to GitHub Packages
34+
- name: Login to GitHub Packages
4035
uses: docker/login-action@v3
4136
with:
4237
registry: ghcr.io
4338
username: ${{ github.actor }}
4439
password: ${{ secrets.GITHUB_TOKEN }}
4540

46-
-
47-
name: Build and push Docker image
41+
- name: Build and push images
4842
id: push
4943
uses: docker/build-push-action@v6
5044
with:
@@ -53,8 +47,7 @@ jobs:
5347
labels: ${{ steps.meta.outputs.labels }}
5448
platforms: linux/amd64,linux/arm64
5549

56-
-
57-
name: Generate artifact attestation
50+
- name: Generate artifact attestation
5851
uses: actions/attest-build-provenance@v2
5952
with:
6053
subject-name: ghcr.io/${{ github.repository }}
Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@ name: Lint code & configuration
33
on:
44
pull_request:
55
push:
6-
7-
env:
8-
fail-fast: true
9-
10-
permissions:
11-
contents: read
6+
schedule:
7+
- cron: "30 4 * * *"
128

139
jobs:
1410
linters:
@@ -22,8 +18,6 @@ jobs:
2218
- name: Install PHP with extensions
2319
uses: shivammathur/setup-php@v2
2420
with:
25-
coverage: none
26-
extensions: intl
2721
php-version: 8.3
2822
tools: composer:v2
2923

@@ -48,7 +42,7 @@ jobs:
4842

4943
- name: Lint Twig templates
5044
if: always() && steps.install.outcome == 'success'
51-
run: bin/console lint:twig templates --env=prod
45+
run: bin/console lint:twig templates
5246

5347
#- name: Lint XLIFF translation files
5448
# if: always() && steps.install.outcome == 'success'
@@ -58,17 +52,17 @@ jobs:
5852
# if: always() && steps.install.outcome == 'success'
5953
# run: bin/console lint:translations
6054

61-
- name: Lint Parameters and Services
55+
- name: Lint service container # todo
6256
if: always() && steps.install.outcome == 'success'
63-
run: bin/console lint:container --no-debug
57+
run: bin/console lint:container
6458

65-
- name: Lint Composer config
59+
- name: Lint Composer configuration
6660
if: always() && steps.install.outcome == 'success'
6761
run: composer validate
6862
# todo enable strict mode, currently license is invalid
6963
# run: composer validate --strict
7064

71-
- name: Check if any dependencies are compromised
65+
- name: Check if any Composer dependencies are compromised
7266
if: always() && steps.install.outcome == 'success'
7367
run: composer audit
7468

@@ -86,8 +80,6 @@ jobs:
8680
- name: Install PHP with extensions
8781
uses: shivammathur/setup-php@v2
8882
with:
89-
coverage: none
90-
extensions: intl
9183
php-version: 8.3
9284
tools: composer:v2
9385

@@ -107,7 +99,7 @@ jobs:
10799
run: composer install --ansi --no-interaction --no-progress
108100

109101
- name: PHP-CS-Fixer
110-
run: ./vendor/bin/php-cs-fixer fix --diff --dry-run
102+
run: vendor/bin/php-cs-fixer fix --diff --dry-run
111103

112104
phpstan:
113105
name: PHPStan
@@ -120,8 +112,6 @@ jobs:
120112
- name: Install PHP with extensions
121113
uses: shivammathur/setup-php@v2
122114
with:
123-
coverage: none
124-
extensions: intl
125115
php-version: 8.3
126116
tools: composer:v2
127117

@@ -142,4 +132,4 @@ jobs:
142132

143133
- name: Run PHPStan
144134
if: always() && steps.install.outcome == 'success'
145-
run: ./vendor/bin/phpstan analyze
135+
run: vendor/bin/phpstan analyze
Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
name: Run image tests
22

3-
on:
4-
pull_request:
5-
push:
3+
on: [pull_request, push]
64

75
env:
8-
fail-fast: true
96
GITHUB_TOKEN: ${{ github.token }}
107
PHPUNIT_FLAGS: ""
118

12-
permissions:
13-
contents: read
14-
159
jobs:
16-
phpunit:
17-
name: Testcontainers
10+
testcontainers:
11+
name: Testcontainers (Standalone)
1812
runs-on: ubuntu-latest
1913
continue-on-error: false
2014

@@ -34,8 +28,6 @@ jobs:
3428
- name: Install PHP with extensions
3529
uses: shivammathur/setup-php@v2
3630
with:
37-
coverage: none
38-
extensions: intl, mbstring, zip
3931
php-version: 8.3
4032
tools: composer:v2
4133

.github/workflows/tests.yaml

Lines changed: 46 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,39 @@
11
name: Run tests
22

3-
on:
4-
pull_request:
5-
push:
3+
on: [pull_request, push]
64

75
env:
8-
fail-fast: true
96
GITHUB_TOKEN: ${{ github.token }}
107
PHPUNIT_FLAGS: ""
118

12-
permissions:
13-
contents: read
14-
159
jobs:
16-
phpunit:
17-
name: "PHPUnit (PHP ${{ matrix.php-version }})"
10+
database:
11+
name: Validate database components
1812
runs-on: ubuntu-latest
19-
continue-on-error: false
2013

2114
services:
2215
database:
2316
image: postgres:16-alpine
2417
ports:
2518
- "5432:5432"
2619
env:
27-
POSTGRES_DB: dirigent_test
20+
POSTGRES_DB: dirigent
2821
POSTGRES_PASSWORD: "!ChangeMe!"
2922
POSTGRES_USER: dirigent
3023

31-
strategy:
32-
matrix:
33-
php-version: ["8.3", "8.4"]
34-
3524
steps:
3625
- name: Checkout code
3726
uses: actions/checkout@v4
3827

3928
- name: Install PHP with extensions
4029
uses: shivammathur/setup-php@v2
4130
with:
42-
coverage: none
43-
extensions: intl, mbstring, zip
44-
php-version: ${{ matrix.php-version }}
31+
php-version: 8.3
4532
tools: composer:v2
4633

47-
- name: Add PHPUnit matcher
48-
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
49-
5034
- name: Set Composer cache directory
5135
id: composer-cache
5236
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
53-
shell: bash
5437

5538
- name: Cache Composer output
5639
uses: actions/cache@v4
@@ -59,59 +42,58 @@ jobs:
5942
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
6043
restore-keys: ${{ runner.os }}-composer-
6144

62-
- name: Install Composer dependencies
45+
- name: Install dependencies
46+
id: install
6347
run: composer install --ansi --no-interaction --no-progress
6448

65-
- name: Install Node.js
66-
uses: actions/setup-node@v4
67-
68-
- name: Install Node dependencies
69-
run: npm ci
70-
71-
- name: Build assets
72-
run: npm run build
73-
74-
- name: Create database schema
75-
run: bin/console --env=test doctrine:schema:create
49+
- name: Validate mapping
50+
run: bin/console doctrine:schema:validate --skip-sync --no-interaction -vvv
7651

77-
- name: Load database fixtures
78-
run: bin/console --env=test doctrine:fixtures:load --no-interaction
52+
- name: Execute migrations
53+
run: bin/console doctrine:migrations:migrate --no-interaction -v
7954

80-
- name: PHPUnit version
81-
run: bin/phpunit --version
55+
- name: Validate schema
56+
run: bin/console doctrine:schema:validate --skip-mapping --skip-property-types --no-interaction -vvv
8257

83-
- name: Run tests
84-
run: bin/phpunit ${{ env.PHPUNIT_FLAGS }}
58+
- name: Load fixtures
59+
run: bin/console doctrine:fixtures:load --no-interaction -vvv
8560

86-
database:
87-
name: Validate database components
61+
phpunit:
62+
name: "PHPUnit (PHP ${{ matrix.php-version }})"
8863
runs-on: ubuntu-latest
64+
continue-on-error: false
8965

9066
services:
9167
database:
9268
image: postgres:16-alpine
9369
ports:
9470
- "5432:5432"
9571
env:
96-
POSTGRES_DB: dirigent
72+
POSTGRES_DB: dirigent_test
9773
POSTGRES_PASSWORD: "!ChangeMe!"
9874
POSTGRES_USER: dirigent
9975

76+
strategy:
77+
matrix:
78+
php-version: ["8.3", "8.4"]
79+
10080
steps:
10181
- name: Checkout code
10282
uses: actions/checkout@v4
10383

10484
- name: Install PHP with extensions
10585
uses: shivammathur/setup-php@v2
10686
with:
107-
coverage: none
108-
extensions: intl
109-
php-version: 8.3
87+
php-version: ${{ matrix.php-version }}
11088
tools: composer:v2
11189

90+
- name: Add PHPUnit matcher
91+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
92+
11293
- name: Set Composer cache directory
11394
id: composer-cache
11495
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
96+
shell: bash
11597

11698
- name: Cache Composer output
11799
uses: actions/cache@v4
@@ -120,18 +102,26 @@ jobs:
120102
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
121103
restore-keys: ${{ runner.os }}-composer-
122104

123-
- name: Install dependencies
124-
id: install
105+
- name: Install Composer dependencies
125106
run: composer install --ansi --no-interaction --no-progress
126107

127-
- name: Validate mapping
128-
run: bin/console doctrine:schema:validate --skip-sync --no-interaction -vvv
108+
- name: Install Node.js
109+
uses: actions/setup-node@v4
129110

130-
- name: Execute migrations
131-
run: bin/console doctrine:migrations:migrate --no-interaction -v
111+
- name: Install Node dependencies
112+
run: npm ci
132113

133-
- name: Validate schema
134-
run: bin/console doctrine:schema:validate --skip-mapping --skip-property-types --no-interaction -vvv
114+
- name: Build assets
115+
run: npm run build
135116

136-
- name: Load fixtures
137-
run: bin/console doctrine:fixtures:load --no-interaction -vvv
117+
- name: Create database schema
118+
run: bin/console doctrine:schema:create --env=test
119+
120+
- name: Load database fixtures
121+
run: bin/console doctrine:fixtures:load --env=test --no-interaction
122+
123+
- name: PHPUnit version
124+
run: bin/phpunit --version
125+
126+
- name: Run tests
127+
run: bin/phpunit ${{ env.PHPUNIT_FLAGS }}

0 commit comments

Comments
 (0)