Skip to content

Commit 48028c0

Browse files
author
tchapi
committed
chore
1 parent 9343f05 commit 48028c0

1 file changed

Lines changed: 260 additions & 77 deletions

File tree

.github/workflows/ci.yml

Lines changed: 260 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -9,83 +9,266 @@ on:
99
- 'docker/**'
1010

1111
env:
12-
COMPOSER_ALLOW_SUPERUSER: '1'
13-
SYMFONY_DEPRECATIONS_HELPER: max[self]=0
14-
ADMIN_LOGIN: admin
15-
ADMIN_PASSWORD: test
16-
DATABASE_URL: mysql://davis:davis@mysql:3306/davis_test
12+
COMPOSER_ALLOW_SUPERUSER: '1'
13+
SYMFONY_DEPRECATIONS_HELPER: max[self]=0
14+
ADMIN_LOGIN: admin
15+
ADMIN_PASSWORD: test
1716

1817
jobs:
19-
analyze:
20-
name: Analyze
21-
runs-on: ubuntu-latest
22-
container:
23-
image: php:8.3-alpine
24-
options: >-
25-
--tmpfs /tmp:exec
26-
--tmpfs /var/tmp:exec
27-
steps:
28-
- name: Checkout
29-
uses: actions/checkout@v4
30-
- name: Install GD / ZIP PHP extension
31-
run: |
32-
apk add $PHPIZE_DEPS libpng-dev libzip-dev
33-
docker-php-ext-configure gd
34-
docker-php-ext-configure zip
35-
docker-php-ext-install gd zip
36-
- name: Install Composer
37-
run: wget -qO - https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --quiet
38-
- name: Validate Composer
39-
run: composer validate
40-
- name: Update to highest dependencies with Composer
41-
run: composer update --no-interaction --no-progress --ansi
42-
- name: Analyze
43-
run: PHP_CS_FIXER_IGNORE_ENV=True vendor/bin/php-cs-fixer fix --ansi
18+
analyze:
19+
name: Analyze
20+
runs-on: ubuntu-latest
21+
container:
22+
image: php:8.3-alpine
23+
options: >-
24+
--tmpfs /tmp:exec
25+
--tmpfs /var/tmp:exec
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
30+
- name: Install GD / ZIP PHP extension
31+
run: |
32+
apk add $PHPIZE_DEPS libpng-dev libzip-dev
33+
docker-php-ext-configure gd
34+
docker-php-ext-configure zip
35+
docker-php-ext-install gd zip
36+
37+
- name: Install Composer
38+
run: wget -qO - https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --quiet
39+
40+
- name: Validate Composer
41+
run: composer validate
42+
43+
- name: Update to highest dependencies with Composer
44+
run: composer update --no-interaction --no-progress --ansi
45+
46+
- name: Analyze
47+
run: PHP_CS_FIXER_IGNORE_ENV=True vendor/bin/php-cs-fixer fix --ansi
4448

45-
phpunit:
46-
name: PHPUnit (PHP ${{ matrix.php }})
47-
runs-on: ubuntu-latest
48-
container:
49-
image: php:${{ matrix.php }}-alpine
50-
options: >-
51-
--tmpfs /tmp:exec
52-
--tmpfs /var/tmp:exec
53-
services:
54-
mysql:
55-
image: mariadb:10.11
56-
env:
57-
# Corresponds to what is in .env.test
58-
MYSQL_DATABASE: davis_test
59-
MYSQL_USER: davis
60-
MYSQL_PASSWORD: davis
61-
MYSQL_ROOT_PASSWORD: root
62-
options: >-
63-
--health-cmd "mysqladmin ping"
64-
--health-interval 10s
65-
--health-timeout 5s
66-
--health-retries 5
67-
ports:
68-
- 3306:3306
69-
strategy:
70-
matrix:
71-
php:
72-
- '8.2'
73-
- '8.3'
74-
- '8.4'
75-
fail-fast: false
76-
steps:
77-
- name: Checkout
78-
uses: actions/checkout@v4
79-
- name: Install MySQL / GD / ZIP PHP extensions
80-
run: |
81-
apk add $PHPIZE_DEPS icu-libs icu-dev libpng-dev libzip-dev
82-
docker-php-ext-configure intl
83-
docker-php-ext-configure gd
84-
docker-php-ext-configure zip
85-
docker-php-ext-install pdo pdo_mysql intl gd zip
86-
- name: Install Composer
87-
run: wget -qO - https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --quiet
88-
- name: Install dependencies with Composer
89-
run: composer install --no-progress --no-interaction --ansi
90-
- name: Run tests with PHPUnit
91-
run: vendor/bin/phpunit --process-isolation --colors=always
49+
phpunit:
50+
name: PHPUnit (PHP ${{ matrix.php }})
51+
runs-on: ubuntu-latest
52+
container:
53+
image: php:${{ matrix.php }}-alpine
54+
options: >-
55+
--tmpfs /tmp:exec
56+
--tmpfs /var/tmp:exec
57+
services:
58+
mysql:
59+
image: mariadb:10.11
60+
env:
61+
# Corresponds to what is in .env.test
62+
MYSQL_DATABASE: davis_test
63+
MYSQL_USER: davis
64+
MYSQL_PASSWORD: davis
65+
MYSQL_ROOT_PASSWORD: root
66+
options: >-
67+
--health-cmd "mysqladmin ping"
68+
--health-interval 10s
69+
--health-timeout 5s
70+
--health-retries 5
71+
ports:
72+
- 3306:3306
73+
74+
strategy:
75+
matrix:
76+
php:
77+
- '8.2'
78+
- '8.3'
79+
- '8.4'
80+
fail-fast: false
81+
82+
steps:
83+
- name: Checkout
84+
uses: actions/checkout@v4
85+
86+
- name: Install MySQL / GD / ZIP PHP extensions
87+
run: |
88+
apk add $PHPIZE_DEPS icu-libs icu-dev libpng-dev libzip-dev
89+
docker-php-ext-configure intl
90+
docker-php-ext-configure gd
91+
docker-php-ext-configure zip
92+
docker-php-ext-install pdo pdo_mysql intl gd zip
93+
94+
- name: Install Composer
95+
run: wget -qO - https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --quiet
96+
97+
- name: Install dependencies with Composer
98+
run: composer install --no-progress --no-interaction --ansi
99+
100+
- name: Run tests with PHPUnit
101+
env:
102+
DATABASE_URL: mysql://davis:davis@mysql:3306/davis_test
103+
run: vendor/bin/phpunit --process-isolation --colors=always
104+
105+
migrations:
106+
name: Migrations (${{ matrix.database }})
107+
runs-on: ubuntu-latest
108+
container:
109+
image: php:8.3-alpine
110+
options: >-
111+
--tmpfs /tmp:exec
112+
--tmpfs /var/tmp:exec
113+
114+
services:
115+
mysql:
116+
image: mariadb:10.11
117+
env:
118+
MYSQL_DATABASE: davis_test
119+
MYSQL_USER: davis
120+
MYSQL_PASSWORD: davis
121+
MYSQL_ROOT_PASSWORD: root
122+
options: >-
123+
--health-cmd "mysqladmin ping"
124+
--health-interval 10s
125+
--health-timeout 5s
126+
--health-retries 5
127+
128+
postgres:
129+
image: postgres:15-alpine
130+
env:
131+
POSTGRES_DB: davis_test
132+
POSTGRES_USER: davis
133+
POSTGRES_PASSWORD: davis
134+
options: >-
135+
--health-cmd pg_isready
136+
--health-interval 10s
137+
--health-timeout 5s
138+
--health-retries 5
139+
140+
strategy:
141+
matrix:
142+
database:
143+
- mysql
144+
- postgresql
145+
- sqlite
146+
fail-fast: false
147+
148+
steps:
149+
- name: Checkout
150+
uses: actions/checkout@v4
151+
152+
- name: Install database extensions
153+
run: |
154+
apk add $PHPIZE_DEPS icu-libs icu-dev libpng-dev libzip-dev postgresql-dev sqlite-dev
155+
docker-php-ext-configure intl
156+
docker-php-ext-configure gd
157+
docker-php-ext-configure zip
158+
docker-php-ext-install pdo pdo_mysql pdo_pgsql pdo_sqlite intl gd zip
159+
160+
- name: Install Composer
161+
run: wget -qO - https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --quiet
162+
163+
- name: Install dependencies with Composer
164+
run: composer install --no-progress --no-interaction --ansi
165+
166+
- name: Run migrations (MySQL)
167+
if: matrix.database == 'mysql'
168+
env:
169+
DATABASE_URL: mysql://davis:davis@mysql:3306/davis_test
170+
run: |
171+
php bin/console doctrine:database:create --if-not-exists --env=test
172+
php bin/console doctrine:migrations:migrate --no-interaction --env=test
173+
php bin/console doctrine:schema:validate --env=test
174+
175+
- name: Run migrations (PostgreSQL)
176+
if: matrix.database == 'postgresql'
177+
env:
178+
DATABASE_URL: postgresql://davis:davis@postgres:5432/davis_test?serverVersion=15&charset=utf8
179+
run: |
180+
php bin/console doctrine:database:create --if-not-exists --env=test
181+
php bin/console doctrine:migrations:migrate --no-interaction --env=test
182+
php bin/console doctrine:schema:validate --env=test
183+
184+
- name: Run migrations (SQLite)
185+
if: matrix.database == 'sqlite'
186+
env:
187+
DATABASE_URL: sqlite:///%kernel.project_dir%/var/data_test.db
188+
run: |
189+
php bin/console doctrine:database:create --if-not-exists --env=test
190+
php bin/console doctrine:migrations:migrate --no-interaction --env=test
191+
php bin/console doctrine:schema:validate --env=test
192+
193+
smoke-test:
194+
name: Application Smoke Test
195+
runs-on: ubuntu-latest
196+
container:
197+
image: php:8.3-alpine
198+
options: >-
199+
--tmpfs /tmp:exec
200+
--tmpfs /var/tmp:exec
201+
202+
services:
203+
mysql:
204+
image: mariadb:10.11
205+
env:
206+
MYSQL_DATABASE: davis_test
207+
MYSQL_USER: davis
208+
MYSQL_PASSWORD: davis
209+
MYSQL_ROOT_PASSWORD: root
210+
options: >-
211+
--health-cmd "mysqladmin ping"
212+
--health-interval 10s
213+
--health-timeout 5s
214+
--health-retries 5
215+
216+
steps:
217+
- name: Checkout
218+
uses: actions/checkout@v4
219+
220+
- name: Install extensions and curl
221+
run: |
222+
apk add $PHPIZE_DEPS icu-libs icu-dev libpng-dev libzip-dev curl
223+
docker-php-ext-configure intl
224+
docker-php-ext-configure gd
225+
docker-php-ext-configure zip
226+
docker-php-ext-install pdo pdo_mysql intl gd zip
227+
228+
- name: Install Composer
229+
run: wget -qO - https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --quiet
230+
231+
- name: Install dependencies with Composer
232+
run: composer install --no-progress --no-interaction --ansi --optimize-autoloader
233+
234+
- name: Prepare application
235+
env:
236+
DATABASE_URL: mysql://davis:davis@mysql:3306/davis_test
237+
APP_ENV: test
238+
run: |
239+
php bin/console doctrine:database:create --if-not-exists --env=test
240+
php bin/console doctrine:migrations:migrate --no-interaction --env=test
241+
php bin/console cache:clear --env=test
242+
243+
- name: Start Symfony server in background
244+
env:
245+
DATABASE_URL: mysql://davis:davis@mysql:3306/davis_test
246+
APP_ENV: test
247+
run: |
248+
php -S 127.0.0.1:8000 -t public/ &
249+
echo $! > server.pid
250+
sleep 3
251+
252+
- name: Test application responds
253+
run: |
254+
# Test that the app responds with a successful HTTP status
255+
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8000/)
256+
echo "HTTP Response code: $RESPONSE"
257+
if [ "$RESPONSE" -ge 200 ] && [ "$RESPONSE" -lt 400 ]; then
258+
echo "✅ Application is responding correctly"
259+
else
260+
echo "❌ Application returned unexpected status code: $RESPONSE"
261+
exit 1
262+
fi
263+
264+
- name: Test dashboard
265+
continue-on-error: true
266+
run: |
267+
curl -f http://127.0.0.1:8000/dashboard || echo "No health endpoint available"
268+
269+
- name: Stop server
270+
if: always()
271+
run: |
272+
if [ -f server.pid ]; then
273+
kill $(cat server.pid) || true
274+
fi

0 commit comments

Comments
 (0)