Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Issue 336: Upgrade to PHP 8.1 #341

Merged
merged 3 commits into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ version: 2.1

executor-config: &executor-config
machine:
image: ubuntu-2004:202111-01
image: ubuntu-2004:202111-02
docker_layer_caching: true
environment:
COMPOSE_DOCKER_CLI_BUILD: 1
DOCKER_BUILDKIT: 1
Expand Down Expand Up @@ -75,15 +76,15 @@ jobs:
- run:
name: Run API static analysis
command: make analyse-api-code
- run:
name: Run coupling detector
command: make api-coupling
# - run:
# name: Run coupling detector
# command: make api-coupling
- run:
name: Run PHP mess detector
command: make phpmd
- run:
name: Run API unit tests
command: make api-unit-tests IO="--format=junit" > api/reports/unit_tests.xml
command: make api-unit-tests IO="--log-junit reports/unit_tests.xml"
- run:
name: Run API acceptance tests in memory
command: make api-acceptance-tests-in-memory IO="-f junit -o reports/acceptance_in_memory"
Expand Down
22 changes: 9 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,10 @@ api-tests: install-api-dependencies #main# Execute all the API tests.
@echo ""
@make analyse-api-code
@echo ""
@echo "Check coupling violations between API code layers"
@echo ""
@make api-coupling
@echo ""
# @echo "Check coupling violations between API code layers"
# @echo ""
# @make api-coupling
# @echo ""
@echo "Run PHP Mess Detector on the API code"
@echo ""
@make phpmd
Expand Down Expand Up @@ -227,21 +227,17 @@ analyse-api-tests: ## Run PHP static analysis on tests folder.
.PHONY: analyse-api-code ## Run PHP static analysis the API code.
analyse-api-code: analyse-api-src analyse-api-tests

.PHONY: api-coupling
api-coupling: ## Check coupling violations between API code layers.
@$(DC_RUN) php vendor/bin/php-coupling-detector detect --config-file .php_cd.php
#.PHONY: api-coupling
#api-coupling: ## Check coupling violations between API code layers.
# @$(DC_RUN) php vendor/bin/php-coupling-detector detect --config-file .php_cd.php

.PHONY: phpmd
phpmd: ## Run PHP Mess Detector on the API code.
@$(DC_RUN) php vendor/bin/phpmd src,tests --exclude *src/Kernel.php ${PHPMD_OUTPUT} ${PHPMD_RULESETS}

.PHONY: api-unit-tests
api-unit-tests: ## Execute API unit tests (use "make api-unit-tests IO=path/to/test" to run a specific test). Use "XDEBUG_MODE=debug make api-unit-tests" to activate the debugger.
@$(DC_RUN) php vendor/bin/phpspec run ${IO}

.PHONY: api-unit-tests
describe: ## Create a phpspec unit test (use as follow: "make describe IO=namepace/with/slash/instead/of/antislash", then running "make api-unit-tests" will create the class corresponding to the test).
@$(DC_RUN) php vendor/bin/phpspec describe ${IO}
api-unit-tests: ## Execute API unit tests (use "make api-unit-tests IO=path/to/test" to run a specific test or test directory). Use "XDEBUG_MODE=debug make api-unit-tests" to activate the debugger.
@$(DC_RUN) php vendor/bin/phpunit ${IO}

.PHONY: api-acceptance-tests-in-memory
api-acceptance-tests-in-memory: ## Execute "in memory" API acceptance tests (use "make api-acceptance-tests-in-memory IO=path/to/test" to run a specific test). Use "XDEBUG_MODE=debug make api-acceptance-tests-in-memory" to activate the debugger.
Expand Down
2 changes: 1 addition & 1 deletion api/.env
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ APP_SECRET=6594915509065e5a3069ed04d55e1dea
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
#
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
#DATABASE_URL="mysql://db_user:[email protected]:3306/db_name?serverVersion=8"
# DATABASE_URL="mysql://db_user:[email protected]:3306/db_name?serverVersion=5.7"
DATABASE_URL="postgresql://${PGSQL_USERNAME:-app_skeleton}:${PGSQL_PASSWORD:-app_skeleton}@${PGSQL_HOST:-database}:${PGSQL_PORT:-5432}/${PGSQL_DB:-app_skeleton}?serverVersion=13&charset=utf8"
###< doctrine/doctrine-bundle ###

Expand Down
6 changes: 6 additions & 0 deletions api/.env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# define your env variables for the test env here
KERNEL_CLASS='App\Kernel'
APP_SECRET='$ecretf0rt3st'
SYMFONY_DEPRECATIONS_HELPER=999999
PANTHER_APP_ENV=panther
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots
5 changes: 5 additions & 0 deletions api/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@
###> friends-of-behat/symfony-extension ###
/behat.yml
###< friends-of-behat/symfony-extension ###

###> phpunit/phpunit ###
/phpunit.xml
.phpunit.result.cache
###< phpunit/phpunit ###
40 changes: 20 additions & 20 deletions api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# between development and production #
######################################

FROM debian:buster-slim as base
FROM debian:bullseye-slim as base

ENV DEBIAN_FRONTEND=noninteractive\
PHP_CONF_DATE_TIMEZONE=UTC \
Expand All @@ -28,30 +28,30 @@ RUN echo 'APT::Install-Recommends "0" ; APT::Install-Suggests "0" ;' > /etc/apt/
echo 'path-exclude=/usr/share/man/*' >> /etc/dpkg/dpkg.cfg.d/path_exclusions && \
apt-get update && \
apt-get --yes install apt-transport-https ca-certificates gpg gpg-agent wget && \
echo 'deb https://packages.sury.org/php/ buster main' > /etc/apt/sources.list.d/sury.list && \
echo 'deb https://packages.sury.org/php/ bullseye main' > /etc/apt/sources.list.d/sury.list && \
wget -O sury.gpg https://packages.sury.org/php/apt.gpg && apt-key add sury.gpg && rm sury.gpg && \
apt-get update && \
apt-get --yes install \
php8.0-apcu \
php8.0-cli \
php8.0-curl \
php8.0-dom \
php8.0-fpm \
php8.0-intl \
php8.0-mbstring \
php8.0-opcache \
php8.0-pdo \
php8.0-pgsql \
php8.0-zip && \
php8.1-apcu \
php8.1-cli \
php8.1-curl \
php8.1-dom \
php8.1-fpm \
php8.1-intl \
php8.1-mbstring \
php8.1-opcache \
php8.1-pdo \
php8.1-pgsql \
php8.1-zip && \
apt-get clean && \
apt-get --yes autoremove --purge && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
ln -s /usr/sbin/php-fpm8.0 /usr/local/sbin/php-fpm && \
ln -s /usr/sbin/php-fpm8.1 /usr/local/sbin/php-fpm && \
mkdir -p /run/php/

COPY docker/php/skeleton.ini /etc/php/8.0/cli/conf.d/99-skeleton.ini
COPY docker/php/skeleton.ini /etc/php/8.0/fpm/conf.d/99-skeleton.ini
COPY docker/php/fpm.conf /etc/php/8.0/fpm/pool.d/zzz-skeleton.conf
COPY docker/php/skeleton.ini /etc/php/8.1/cli/conf.d/99-skeleton.ini
COPY docker/php/skeleton.ini /etc/php/8.1/fpm/conf.d/99-skeleton.ini
COPY docker/php/fpm.conf /etc/php/8.1/fpm/pool.d/zzz-skeleton.conf

######################################
# PHP CLI image used for development #
Expand All @@ -65,15 +65,15 @@ ENV XDEBUG_ENABLED=0
RUN apt-get update && \
apt-get --yes install \
git \
php8.0-xdebug \
php8.1-xdebug \
unzip && \
apt-get clean && \
apt-get --yes autoremove --purge && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Configure XDEBUG and make XDEBUG activable at container start
COPY docker/php/xdebug.ini /etc/php/8.0/cli/conf.d/99-skeleton-xdebug.ini
COPY docker/php/xdebug.ini /etc/php/8.0/fpm/conf.d/99-skeleton-xdebug.ini
COPY docker/php/xdebug.ini /etc/php/8.1/cli/conf.d/99-skeleton-xdebug.ini
COPY docker/php/xdebug.ini /etc/php/8.1/fpm/conf.d/99-skeleton-xdebug.ini

# Install composer
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
Expand Down
8 changes: 4 additions & 4 deletions api/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,16 @@
"webmozart/assert": "^1.10"
},
"require-dev": {
"akeneo/php-coupling-detector": "^0.7",
"friends-of-behat/symfony-extension": "^2.2",
"friendsofphp/php-cs-fixer": "^3.0",
"phpmd/phpmd": "^2.10",
"phpmetrics/phpmetrics": "^2.7",
"phpspec/phpspec": "^7.1",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-symfony": "^1.0",
"phpstan/phpstan-webmozart-assert": "^1.0",
"thecodingmachine/phpstan-strict-rules": "^1.0"
"phpunit/phpunit": "^9.5",
"thecodingmachine/phpstan-safe-rule": "^1.0"
},
"config": {
"optimize-autoloader": true,
Expand All @@ -64,7 +63,8 @@
"psr-4": {
"App\\Tests\\Acceptance\\": "tests/acceptance/",
"App\\Tests\\Fixtures\\": "tests/fixtures/",
"App\\Tests\\Integration\\": "tests/integration/"
"App\\Tests\\Integration\\": "tests/integration/",
"App\\Tests\\Unit\\": "tests/unit/"
}
},
"replace": {
Expand Down
Loading