Skip to content

Commit cb71a9d

Browse files
author
Cristoforo Cervino
committed
update environment
1 parent 60bb1db commit cb71a9d

23 files changed

+469
-277
lines changed

.github/workflows/ci.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ "main", "develop" ]
6+
pull_request:
7+
branches: [ "main", "develop" ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
include:
15+
- php-version: '8.2'
16+
symfony-version: '6.4.*'
17+
- php-version: '8.2'
18+
symfony-version: '7.0.*'
19+
20+
name: PHP ${{ matrix.php-version }} · SF ${{ matrix.symfony-version }}
21+
22+
services:
23+
mysql:
24+
image: mysql:8.0
25+
env:
26+
MYSQL_ROOT_PASSWORD: root
27+
MYSQL_DATABASE: test
28+
ports:
29+
- 3306:3306
30+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
31+
32+
steps:
33+
- uses: actions/checkout@v4
34+
35+
- name: Setup PHP
36+
uses: shivammathur/setup-php@v2
37+
with:
38+
php-version: ${{ matrix.php-version }}
39+
extensions: mbstring, xml, ctype, iconv, intl, json
40+
coverage: ${{ matrix.symfony-version == '7.0.*' && 'pcov' || 'none' }}
41+
42+
- name: Constrain Symfony version
43+
run: |
44+
sed -ri 's/"symfony\/([^"]+)": "[^"]+"/"symfony\/\1": "${{ matrix.symfony-version }}"/g' composer.json
45+
46+
- name: Install Composer dependencies
47+
uses: ramsey/composer-install@v3
48+
with:
49+
composer-options: "--prefer-dist --no-progress --no-interaction --optimize-autoloader"
50+
51+
- name: Run PHP-CS-Fixer
52+
if: matrix.symfony-version == '7.0.*'
53+
run: vendor/bin/php-cs-fixer fix --dry-run --stop-on-violation --using-cache=no
54+
55+
- name: Run PHPStan
56+
if: matrix.symfony-version == '7.0.*'
57+
run: vendor/bin/phpstan analyse src tests --configuration=phpstan.neon --memory-limit=1G
58+
59+
- name: Run PHPUnit tests
60+
env:
61+
DATABASE_URL: mysql://root:root@127.0.0.1:3306/test?serverVersion=8.0
62+
run: vendor/bin/phpunit ${{ matrix.symfony-version == '7.0.*' && '--coverage-clover coverage.xml' || '' }}
63+
64+
- name: Upload coverage to Codecov
65+
if: matrix.symfony-version == '7.0.*'
66+
uses: codecov/codecov-action@v4
67+
with:
68+
files: ./coverage.xml
69+
fail_ci_if_error: false

.github/workflows/workflow.yml

Lines changed: 0 additions & 62 deletions
This file was deleted.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ composer.lock
1212
!bin/symfony_requirements
1313
/vendor/
1414
/phpunit.xml
15+
docker-compose.override.yml
16+
coverage.xml

Makefile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.PHONY: setup php cs-fixer phpstan tests ci-local
2+
3+
setup:
4+
rm -f composer.lock
5+
docker-compose up --build -d php
6+
docker-compose exec php composer install
7+
8+
php:
9+
docker-compose exec php sh
10+
11+
cs-fixer:
12+
docker-compose exec php vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --allow-risky=yes
13+
14+
phpstan:
15+
docker-compose exec php vendor/bin/phpstan analyse src tests --configuration=phpstan.neon --memory-limit=1G
16+
17+
tests:
18+
rm -rf var/cache/test
19+
mkdir -p var/cache/test
20+
docker-compose exec php vendor/bin/phpunit
21+
22+
ci-local:
23+
act -j build

docker-compose.override.yml.dist

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
services:
2+
php:
3+
environment:
4+
XDEBUG_MODE: develop,debug
5+
XDEBUG_CLIENT_HOST: host.docker.internal
6+
XDEBUG_CLIENT_PORT: 9090
7+
PHP_IDE_CONFIG: serverName=andanteproject-timestampable-bundle
8+
XDEBUG_START_WITH_REQUEST: yes

docker-compose.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
services:
2+
php:
3+
build:
4+
context: .
5+
dockerfile: docker/Dockerfile.php82
6+
volumes:
7+
- .:/var/www/html
8+
environment:
9+
XDEBUG_MODE: ${XDEBUG_MODE:-develop,debug}
10+
XDEBUG_CLIENT_HOST: ${XDEBUG_CLIENT_HOST:-host.docker.internal}
11+
XDEBUG_CLIENT_PORT: ${XDEBUG_CLIENT_PORT:-9090}
12+
PHP_IDE_CONFIG: ${PHP_IDE_CONFIG:-serverName=andanteproject-timestampable-bundle}
13+
XDEBUG_START_WITH_REQUEST: ${XDEBUG_START_WITH_REQUEST:-yes}

docker/Dockerfile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
FROM php:8.2-fpm-alpine
2+
3+
# Install dependencies
4+
RUN apk add --no-cache \
5+
git \
6+
unzip \
7+
libzip-dev \
8+
icu-dev \
9+
libpq-dev \
10+
oniguruma-dev \
11+
libxml2-dev \
12+
autoconf \
13+
gcc \
14+
g++ \
15+
make \
16+
linux-headers \
17+
&& docker-php-ext-install \
18+
pdo_mysql \
19+
zip \
20+
intl \
21+
pdo_pgsql \
22+
mbstring \
23+
soap \
24+
xml \
25+
&& docker-php-ext-enable \
26+
pdo_mysql \
27+
zip \
28+
intl \
29+
pdo_pgsql \
30+
mbstring \
31+
soap \
32+
xml
33+
34+
# Install Xdebug
35+
RUN pecl install xdebug \
36+
&& docker-php-ext-enable xdebug
37+
38+
# Install Composer
39+
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
40+
41+
COPY docker/php/conf.d/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
42+
43+
WORKDIR /var/www/html
44+
45+
CMD ["php-fpm"]

docker/Dockerfile.php82

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
FROM php:8.2-fpm-alpine
2+
3+
# Install dependencies
4+
RUN apk add --no-cache \
5+
git \
6+
unzip \
7+
libzip-dev \
8+
icu-dev \
9+
libpq-dev \
10+
oniguruma-dev \
11+
libxml2-dev \
12+
autoconf \
13+
gcc \
14+
g++ \
15+
make \
16+
linux-headers \
17+
&& docker-php-ext-install \
18+
pdo_mysql \
19+
zip \
20+
intl \
21+
pdo_pgsql \
22+
mbstring \
23+
soap \
24+
xml \
25+
&& docker-php-ext-enable \
26+
pdo_mysql \
27+
zip \
28+
intl \
29+
pdo_pgsql \
30+
mbstring \
31+
soap \
32+
xml
33+
34+
# Install Xdebug
35+
RUN pecl install xdebug \
36+
&& docker-php-ext-enable xdebug
37+
38+
# Install Composer
39+
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
40+
41+
COPY docker/php/conf.d/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
42+
43+
WORKDIR /var/www/html
44+
45+
CMD ["php-fpm"]

docker/php/conf.d/xdebug.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
zend_extension=xdebug.so
2+
xdebug.mode=${XDEBUG_MODE}
3+
xdebug.client_host=${XDEBUG_CLIENT_HOST}
4+
xdebug.client_port=${XDEBUG_CLIENT_PORT}
5+
xdebug.start_with_request=${XDEBUG_START_WITH_REQUEST}

phpstan.neon

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ parameters:
22
level: 8
33
checkMissingIterableValueType: false
44
checkGenericClassInNonGenericObjectType: false
5+
excludePaths:
6+
- src/DependencyInjection/Configuration.php

0 commit comments

Comments
 (0)