Skip to content

Commit e254a4a

Browse files
committed
Add tests for Docker images using Testcontainers
1 parent 48779f4 commit e254a4a

File tree

16 files changed

+1647
-201
lines changed

16 files changed

+1647
-201
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
name: Test Docker build
1+
name: Build image
22

33
on:
44
pull_request:
55
push:
66

77
jobs:
8-
test-build:
8+
build-image:
99
name: Test Docker build
1010
runs-on: ubuntu-latest
1111
steps:

.github/workflows/docker-publish.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish Docker image
1+
name: Publish image
22

33
on:
44
push:
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Run image tests
2+
3+
on:
4+
pull_request:
5+
push:
6+
7+
env:
8+
fail-fast: true
9+
GITHUB_TOKEN: ${{ github.token }}
10+
PHPUNIT_FLAGS: ""
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
phpunit:
17+
name: "Testcontainers"
18+
runs-on: ubuntu-latest
19+
continue-on-error: false
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Build Docker image
26+
id: push
27+
uses: docker/build-push-action@v6
28+
with:
29+
context: .
30+
file: ./Dockerfile
31+
push: false
32+
tags: dirigent-standalone
33+
34+
- name: Install PHP with extensions
35+
uses: shivammathur/setup-php@v2
36+
with:
37+
coverage: none
38+
extensions: intl, mbstring, zip
39+
php-version: 8.2
40+
tools: composer:v2
41+
42+
- name: Add PHPUnit matcher
43+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
44+
45+
- name: Set Composer cache directory
46+
id: composer-cache
47+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
48+
shell: bash
49+
50+
- name: Cache Composer output
51+
uses: actions/cache@v4
52+
with:
53+
path: ${{ steps.composer-cache.outputs.dir }}
54+
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
55+
restore-keys: ${{ runner.os }}-composer-
56+
57+
- name: Install Composer dependencies
58+
run: composer install --ansi --no-interaction --no-progress
59+
60+
- name: PHPUnit version
61+
run: bin/phpunit --version
62+
63+
- name: Run tests
64+
run: bin/phpunit --configuration phpunit.docker.xml ${{ env.PHPUNIT_FLAGS }}

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ WORKDIR /srv/app
55
COPY composer.json composer.lock ./
66

77
RUN composer install \
8+
--ignore-platform-reqs \
89
--no-ansi \
910
--no-autoloader \
11+
--no-dev \
1012
--no-interaction \
1113
--no-plugins \
1214
--no-progress \
@@ -95,6 +97,7 @@ COPY --chown=dirigent:dirigent templates templates/
9597

9698
RUN set -e; \
9799
chmod +x bin/console; \
100+
chmod +x bin/dirigent; \
98101
composer dump-autoload --classmap-authoritative --no-ansi --no-interaction
99102

100103
VOLUME /srv/data

bin/dirigent

100644100755
File mode changed.

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"symfony/mailer": "^7.0",
3636
"symfony/mime": "^7.0",
3737
"symfony/monolog-bundle": "^3.0",
38+
"symfony/options-resolver": "^6.4",
3839
"symfony/process": "^7.0",
3940
"symfony/property-access": "^7.0",
4041
"symfony/property-info": "^7.0",
@@ -63,7 +64,8 @@
6364
"symfony/maker-bundle": "^1.0",
6465
"symfony/phpunit-bridge": "^7.0",
6566
"symfony/stopwatch": "^7.0",
66-
"symfony/web-profiler-bundle": "^7.0"
67+
"symfony/web-profiler-bundle": "^7.0",
68+
"testcontainers/testcontainers": "^1.0"
6769
},
6870
"conflict": {
6971
"symfony/symfony": "*"

0 commit comments

Comments
 (0)