Skip to content

Commit 3ea262a

Browse files
committed
Improve GitHub workflow configurations
Improvements to GitHub workflow configurations: - Fixes code style issues - Improves naming of files, workflows and jobs - Adds scheduled workflow for dependency validation - Allows the check for outdated Symfony recipes to fail
1 parent e764646 commit 3ea262a

File tree

6 files changed

+150
-157
lines changed

6 files changed

+150
-157
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
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: Standalone images
8+
109
runs-on: ubuntu-latest
10+
1111
steps:
12-
-
13-
name: Set up Docker Buildx
12+
- name: Set up Docker Buildx
1413
uses: docker/setup-buildx-action@v3
1514
with:
1615
driver: docker-container
1716

18-
-
19-
name: Build Docker image
17+
- name: Build images
2018
uses: docker/build-push-action@v6
2119
with:
2220
platforms: linux/amd64,linux/arm64
Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,24 @@
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: Standalone images
12+
1413
runs-on: ubuntu-latest
15-
permissions:
16-
id-token: write
17-
contents: read
18-
packages: write
19-
attestations: write
14+
2015
steps:
21-
-
22-
name: Set up Docker Buildx
16+
- name: Set up Docker Buildx
2317
uses: docker/setup-buildx-action@v3
2418
with:
2519
driver: docker-container
2620

27-
-
28-
name: Extract metadata for Docker
21+
- name: Extract metadata for Docker
2922
id: meta
3023
uses: docker/metadata-action@v5
3124
with:
@@ -35,16 +28,14 @@ jobs:
3528
type=semver,pattern={{version}}
3629
type=semver,pattern={{major}}.{{minor}}
3730
38-
-
39-
name: Login to GitHub Packages
31+
- name: Login to GitHub Packages
4032
uses: docker/login-action@v3
4133
with:
4234
registry: ghcr.io
4335
username: ${{ github.actor }}
4436
password: ${{ secrets.GITHUB_TOKEN }}
4537

46-
-
47-
name: Build and push Docker image
38+
- name: Build and publish images
4839
id: push
4940
uses: docker/build-push-action@v6
5041
with:
@@ -53,8 +44,7 @@ jobs:
5344
labels: ${{ steps.meta.outputs.labels }}
5445
platforms: linux/amd64,linux/arm64
5546

56-
-
57-
name: Generate artifact attestation
47+
- name: Generate artifact attestation
5848
uses: actions/attest-build-provenance@v2
5949
with:
6050
subject-name: ghcr.io/${{ github.repository }}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Lint dependencies
2+
3+
on:
4+
pull_request:
5+
push:
6+
schedule:
7+
- cron: "30 4 * * *"
8+
9+
jobs:
10+
composer:
11+
name: Composer
12+
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Install PHP with extensions
20+
uses: shivammathur/setup-php@v2
21+
with:
22+
php-version: 8.3
23+
tools: composer:v2
24+
25+
- name: Set Composer cache directory
26+
id: composer-cache
27+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
28+
29+
- name: Cache Composer output
30+
uses: actions/cache@v4
31+
with:
32+
path: ${{ steps.composer-cache.outputs.dir }}
33+
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
34+
restore-keys: ${{ runner.os }}-composer-
35+
36+
- name: Install Composer dependencies
37+
id: composer-install
38+
run: composer install --ansi --no-interaction --no-progress
39+
40+
- name: Check if any Composer dependencies are compromised
41+
if: always() && steps.composer-install.outcome == 'success'
42+
run: composer audit --ansi
43+
44+
# This check always shows a success state, even when there are
45+
# outdated recipes (due to `continue-on-error`). Please check
46+
# the result when updating Composer dependencies.
47+
# todo fail when composer.lock changed and there is an outdated recipe
48+
- name: Check if any Symfony Flex recipes are outdated
49+
if: always() && steps.composer-install.outcome == 'success'
50+
continue-on-error: true
51+
run: composer recipes --outdated --ansi
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
name: Lint code & configuration
22

3-
on:
4-
pull_request:
5-
push:
6-
7-
env:
8-
fail-fast: true
9-
10-
permissions:
11-
contents: read
3+
on: [pull_request, push]
124

135
jobs:
146
linters:
157
name: Linters
8+
169
runs-on: ubuntu-latest
1710

1811
steps:
@@ -22,8 +15,6 @@ jobs:
2215
- name: Install PHP with extensions
2316
uses: shivammathur/setup-php@v2
2417
with:
25-
coverage: none
26-
extensions: intl
2718
php-version: 8.3
2819
tools: composer:v2
2920

@@ -38,56 +29,48 @@ jobs:
3829
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
3930
restore-keys: ${{ runner.os }}-composer-
4031

41-
- name: Install dependencies
42-
id: install
32+
- name: Install Composer dependencies
33+
id: composer-install
4334
run: composer install --ansi --no-interaction --no-progress
4435

36+
- name: Lint Composer configuration
37+
if: always() && steps.composer-install.outcome == 'success'
38+
run: composer validate --ansi
39+
# todo enable strict mode, currently license is invalid
40+
# run: composer validate --strict
41+
4542
- name: Lint YAML files
46-
if: always() && steps.install.outcome == 'success'
47-
run: bin/console lint:yaml .github config translations --parse-tags
43+
if: always() && steps.composer-install.outcome == 'success'
44+
run: bin/console lint:yaml .github config translations --parse-tags --ansi
4845

49-
- name: Lint Twig templates
50-
if: always() && steps.install.outcome == 'success'
51-
run: bin/console lint:twig templates --env=prod
46+
- name: Lint Symfony service container
47+
if: always() && steps.composer-install.outcome == 'success'
48+
run: bin/console lint:container --ansi
5249

53-
#- name: Lint XLIFF translation files
54-
# if: always() && steps.install.outcome == 'success'
55-
# run: bin/console lint:xliff translations
50+
- name: Lint Twig templates
51+
if: always() && steps.composer-install.outcome == 'success'
52+
run: bin/console lint:twig templates --ansi
5653

5754
#- name: Lint translation contents
58-
# if: always() && steps.install.outcome == 'success'
59-
# run: bin/console lint:translations
55+
# if: always() && steps.composer-install.outcome == 'success'
56+
# run: bin/console lint:translations --ansi
6057

61-
- name: Lint Parameters and Services
62-
if: always() && steps.install.outcome == 'success'
63-
run: bin/console lint:container --no-debug
64-
65-
- name: Lint Composer config
66-
if: always() && steps.install.outcome == 'success'
67-
run: composer validate
68-
# todo enable strict mode, currently license is invalid
69-
# run: composer validate --strict
70-
71-
- name: Check if any dependencies are compromised
72-
if: always() && steps.install.outcome == 'success'
73-
run: composer audit
74-
75-
- name: Check if any Symfony recipes are outdated
76-
if: always() && steps.install.outcome == 'success'
77-
run: composer recipes --outdated --no-interaction
58+
#- name: Lint XLIFF translation files
59+
# if: always() && steps.composer-install.outcome == 'success'
60+
# run: bin/console lint:xliff translations --ansi
7861

7962
php-cs-fixer:
8063
name: PHP-CS-Fixer
64+
8165
runs-on: ubuntu-latest
66+
8267
steps:
8368
- name: Checkout code
8469
uses: actions/checkout@v4
8570

8671
- name: Install PHP with extensions
8772
uses: shivammathur/setup-php@v2
8873
with:
89-
coverage: none
90-
extensions: intl
9174
php-version: 8.3
9275
tools: composer:v2
9376

@@ -102,15 +85,15 @@ jobs:
10285
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
10386
restore-keys: ${{ runner.os }}-composer-
10487

105-
- name: Install dependencies
106-
id: install
88+
- name: Install Composer dependencies
10789
run: composer install --ansi --no-interaction --no-progress
10890

109-
- name: PHP-CS-Fixer
110-
run: ./vendor/bin/php-cs-fixer fix --diff --dry-run
91+
- name: Run PHP-CS-Fixer
92+
run: vendor/bin/php-cs-fixer fix --diff --dry-run --ansi --show-progress none
11193

11294
phpstan:
11395
name: PHPStan
96+
11497
runs-on: ubuntu-latest
11598

11699
steps:
@@ -120,8 +103,6 @@ jobs:
120103
- name: Install PHP with extensions
121104
uses: shivammathur/setup-php@v2
122105
with:
123-
coverage: none
124-
extensions: intl
125106
php-version: 8.3
126107
tools: composer:v2
127108

@@ -136,10 +117,8 @@ jobs:
136117
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
137118
restore-keys: ${{ runner.os }}-composer-
138119

139-
- name: Install dependencies
140-
id: install
120+
- name: Install Composer dependencies
141121
run: composer install --ansi --no-interaction --no-progress
142122

143123
- name: Run PHPStan
144-
if: always() && steps.install.outcome == 'success'
145-
run: ./vendor/bin/phpstan analyze
124+
run: vendor/bin/phpstan analyze --ansi --no-progress
Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
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 }}
10-
PHPUNIT_FLAGS: ""
11-
12-
permissions:
13-
contents: read
147

158
jobs:
16-
phpunit:
17-
name: Testcontainers
9+
testcontainers:
10+
name: Testcontainers (Standalone)
11+
1812
runs-on: ubuntu-latest
19-
continue-on-error: false
2013

2114
steps:
2215
- name: Checkout code
@@ -34,8 +27,6 @@ jobs:
3427
- name: Install PHP with extensions
3528
uses: shivammathur/setup-php@v2
3629
with:
37-
coverage: none
38-
extensions: intl, mbstring, zip
3930
php-version: 8.3
4031
tools: composer:v2
4132

@@ -45,7 +36,6 @@ jobs:
4536
- name: Set Composer cache directory
4637
id: composer-cache
4738
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
48-
shell: bash
4939

5040
- name: Cache Composer output
5141
uses: actions/cache@v4
@@ -60,5 +50,5 @@ jobs:
6050
- name: PHPUnit version
6151
run: bin/phpunit --version
6252

63-
- name: Run tests
64-
run: bin/phpunit --configuration phpunit.docker.xml ${{ env.PHPUNIT_FLAGS }}
53+
- name: Run PHPUnit
54+
run: bin/phpunit --configuration phpunit.docker.xml --no-progress

0 commit comments

Comments
 (0)