From 179cc0df8fea55bb940dbd7cd93f59f143e52565 Mon Sep 17 00:00:00 2001 From: Daniel Gohlke Date: Fri, 21 Feb 2025 17:32:27 +0100 Subject: [PATCH 1/4] [TASK] Add CI test for PHP 8.4 Resolves: #103 --- .github/workflows/ci.yaml | 12 +++++++ .gitlab-ci.yml | 70 +++++++++++++++++++++------------------ README.md | 2 +- composer.json | 2 +- 4 files changed, 52 insertions(+), 34 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2b847f67..3b01ddc9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,6 +18,7 @@ jobs: - 8.1 - 8.2 - 8.3 + - 8.4 steps: - name: Checkout uses: actions/checkout@v4 @@ -75,6 +76,8 @@ jobs: typo3-version: '^12.4' - php-version: '8.3' typo3-version: '^12.4' + - php-version: '8.4' + typo3-version: '^12.4' steps: - uses: actions/checkout@v4 @@ -115,6 +118,9 @@ jobs: - name: Run Unit Tests PHP8.3 run: nix-shell --arg phpVersion \"php83\" --pure --run project-test-unit + - name: Run Unit Tests PHP8.4 + run: nix-shell --arg phpVersion \"php84\" --pure --run project-test-unit + - name: Run Functional Tests PHP8.1 run: nix-shell --arg phpVersion \"php81\" --pure --run project-test-functional @@ -124,6 +130,9 @@ jobs: - name: Run Functional Tests PHP8.3 run: nix-shell --arg phpVersion \"php83\" --pure --run project-test-functional + - name: Run Functional Tests PHP8.4 + run: nix-shell --arg phpVersion \"php84\" --pure --run project-test-functional + - name: Run Acceptance Tests PHP8.1 run: nix-shell --arg phpVersion \"php81\" --pure --run project-test-acceptance @@ -132,3 +141,6 @@ jobs: - name: Run Acceptance Tests PHP8.3 run: nix-shell --arg phpVersion \"php83\" --pure --run project-test-acceptance + + - name: Run Acceptance Tests PHP8.4 + run: nix-shell --arg phpVersion \"php84\" --pure --run project-test-acceptance diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e44f61fc..d5f52a33 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -23,32 +23,13 @@ stages: - documentation lint:cgl: - image: $CI_REGISTRY/containers/phpunit-with-php-8.1:main + image: $CI_REGISTRY/containers/phpunit-with-php-8.2:main stage: lint before_script: - - sed -i -e "s#ssh://git@code.extco.de:22722#https://gitlab-ci-token:$CI_JOB_TOKEN@code.extco.de#g" composer.json - - composer config platform.php 8.1 - - composer remove typo3/cms-core --no-update + - composer remove typo3/cms-* --no-update - composer install --no-progress --no-ansi --no-interaction script: - vendor/bin/php-cs-fixer fix --config=Build/.php-cs-fixer.dist.php -v --dry-run --using-cache=no --path-mode=intersection ./ - -lint:typoscriptcgl: - image: php:8.1-alpine - stage: lint - before_script: - - apk add --no-cache bash curl git mercurial openssh openssl parallel subversion tini zlib-dev libzip-dev zip icu-dev g++ - - docker-php-ext-install mysqli && docker-php-ext-install zip && docker-php-ext-configure intl && docker-php-ext-install intl && docker-php-ext-enable intl - - wget https://composer.github.io/installer.sig -O - -q | tr -d '\n' > installer.sig - - php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" - - php -r "if (hash_file('SHA384', 'composer-setup.php') === trim(file_get_contents('installer.sig'))) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" - - php composer-setup.php --no-ansi --install-dir=/usr/bin --filename=composer - - php -r "unlink('composer-setup.php'); unlink('installer.sig');" - - sed -i -e "s#ssh://git@code.extco.de:22722#https://gitlab-ci-token:$CI_JOB_TOKEN@code.extco.de#g" composer.json - - composer config platform.php 8.1 - - composer remove typo3/cms-core --no-update - - composer install --no-progress --no-ansi --no-interaction - script: - vendor/bin/typoscript-lint -c Build/typoscriptlint.yaml Configuration lint:yaml: @@ -59,23 +40,31 @@ lint:yaml: script: - yamllint -c Build/yamllint.yaml Configuration/ Resources/ -lint:php81: +.lint_php: &lint_php stage: lint - image: php:8.1-alpine + image: $CONTAINER_IMAGE script: - - find . -name \*.php -exec php -l "{}" \; + - find *.php Classes Configuration Tests -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l + +lint:php81: + <<: *lint_php + variables: + CONTAINER_IMAGE: php:8.1-alpine lint:php82: - stage: lint - image: php:8.2-alpine - script: - - find . -name \*.php -exec php -l "{}" \; + <<: *lint_php + variables: + CONTAINER_IMAGE: php:8.2-alpine lint:php83: - stage: lint - image: php:8.3-alpine - script: - - find . -name \*.php -exec php -l "{}" \; + <<: *lint_php + variables: + CONTAINER_IMAGE: php:8.3-alpine + +lint:php84: + <<: *lint_php + variables: + CONTAINER_IMAGE: php:8.4-alpine phpstan:analyse: image: $CI_REGISTRY/containers/phpunit-with-php-8.1:main @@ -124,6 +113,13 @@ test:php83:typo3_12: CONTAINER_IMAGE: $CI_REGISTRY/containers/phpunit-with-php-8.3:main TYPO3_VERSION: ^12.4 +# Build in PHP 8.3 and TYPO3 12.4 +test:php84:typo3_12: + <<: *test_php + variables: + CONTAINER_IMAGE: $CI_REGISTRY/containers/phpunit-with-php-8.4:main + TYPO3_VERSION: ^12.4 + .test_codeception: &test_codeception stage: test image: $CONTAINER_IMAGE @@ -176,6 +172,16 @@ test:codception:php83:typo3_12: TYPO3_VERSION: ^12.4 GECKODRIVER_VERSION: v0.34.0 +# Build in PHP 8.4 and TYPO3 12.4 +test:codception:php84:typo3_12: + <<: *test_codeception + needs: + - test:codception:php83:typo3_12 + variables: + CONTAINER_IMAGE: $CI_REGISTRY/containers/codeception-with-php-8.4:main + TYPO3_VERSION: ^12.4 + GECKODRIVER_VERSION: v0.34.0 + documentation: stage: documentation image: diff --git a/README.md b/README.md index a90e4ccc..e71bf0c9 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Sometimes minor versions also result in minor adjustments to own templates or co | Cart Events | TYPO3 | PHP | Support/Development | |-------------|------------|-----------|--------------------------------------| -| 5.x.x | 12.4 | 8.1+ | Features, Bugfixes, Security Updates | +| 5.x.x | 12.4 | 8.1 - 8.4 | Features, Bugfixes, Security Updates | | 4.x.x | 10.4, 11.5 | 7.2+ | Bugfixes, Security Updates | | 3.x.x | 10.4 | 7.2 - 7.4 | Security Updates | | 2.x.x | 9.5 | 7.2 - 7.4 | | diff --git a/composer.json b/composer.json index 6db69d21..615e894a 100644 --- a/composer.json +++ b/composer.json @@ -46,7 +46,7 @@ } }, "require": { - "php": "^8.1", + "php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0", "ext-json": "*", "ext-pdo": "*", "extcode/cart": "^10.0", From 4038f143f65f1fa32145b9b9342bf78c3bd7768b Mon Sep 17 00:00:00 2001 From: Daniel Gohlke Date: Fri, 21 Feb 2025 21:12:16 +0100 Subject: [PATCH 2/4] [BUGFIX] Make method arguments explicitly nullable Relates: #103 --- Classes/Controller/EventController.php | 4 ++-- Classes/Domain/Finisher/Form/AddToCartFinisher.php | 2 +- Classes/Domain/Repository/CategoryRepository.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Classes/Controller/EventController.php b/Classes/Controller/EventController.php index 920b2fa3..5d12db25 100644 --- a/Classes/Controller/EventController.php +++ b/Classes/Controller/EventController.php @@ -97,7 +97,7 @@ public function teaserAction(): ResponseInterface * @TYPO3\CMS\Extbase\Annotation\IgnoreValidation("event") */ #[IgnoreValidation(['value' => 'event'])] - public function showAction(Event $event = null): ResponseInterface + public function showAction(?Event $event = null): ResponseInterface { if (!$event) { $event = $this->getEvent(); @@ -117,7 +117,7 @@ public function showAction(Event $event = null): ResponseInterface #[IgnoreValidation(['value' => 'eventDate'])] #[IgnoreValidation(['value' => 'priceCategory'])] - public function formAction(EventDate $eventDate = null, PriceCategory $priceCategory = null): ResponseInterface + public function formAction(?EventDate $eventDate = null, ?PriceCategory $priceCategory = null): ResponseInterface { if (!$eventDate) { $arguments = $this->request->getArguments(); diff --git a/Classes/Domain/Finisher/Form/AddToCartFinisher.php b/Classes/Domain/Finisher/Form/AddToCartFinisher.php index d0247251..4625f98f 100644 --- a/Classes/Domain/Finisher/Form/AddToCartFinisher.php +++ b/Classes/Domain/Finisher/Form/AddToCartFinisher.php @@ -71,7 +71,7 @@ public function getProductFromForm( protected function getProductFromEventDate( int $quantity, array $taxClasses, - array $feVariants = null + array $feVariants = [] ): Product { $event = $this->eventDate->getEvent(); $title = implode(' - ', [$event->getTitle(), $this->eventDate->getTitle()]); diff --git a/Classes/Domain/Repository/CategoryRepository.php b/Classes/Domain/Repository/CategoryRepository.php index ac7dbd77..c175be5f 100644 --- a/Classes/Domain/Repository/CategoryRepository.php +++ b/Classes/Domain/Repository/CategoryRepository.php @@ -16,13 +16,13 @@ class CategoryRepository extends Repository { - public function findAllAsRecursiveTreeArray(Category $selectedCategory = null): array + public function findAllAsRecursiveTreeArray(?Category $selectedCategory = null): array { $categoriesArray = $this->findAllAsArray($selectedCategory); return $this->buildSubcategories($categoriesArray, null); } - public function findAllAsArray(Category $selectedCategory = null): array + public function findAllAsArray(?Category $selectedCategory = null): array { $localCategories = $this->findAll(); $categories = []; From cfbba719b66a0c200c4b84fcb38d79e0aac054e9 Mon Sep 17 00:00:00 2001 From: Daniel Gohlke Date: Fri, 21 Feb 2025 20:06:09 +0100 Subject: [PATCH 3/4] [CLEANUP] Remove unused variables from GitLab CI --- .gitlab-ci.yml | 51 ++++++++++++-------------------------------------- 1 file changed, 12 insertions(+), 39 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d5f52a33..29082ec5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,14 +5,7 @@ cache: - .php_cs.cache variables: - COMPOSER_CACHE_DIR: ".composer" - TYPO3_PATH_WEB: "$CI_PROJECT_DIR/.build/public" - MYSQL_DATABASE: "typo3" - MYSQL_ROOT_PASSWORD: "joh316" - typo3DatabaseName: "typo3" - typo3DatabaseHost: "mysql" - typo3DatabaseUsername: "root" - typo3DatabasePassword: "joh316" + TYPO3_VERSION: ^12.4 before_script: - apk add git --update @@ -92,33 +85,25 @@ phpstan:analyse: - vendor/bin/phpunit -c Build/UnitTests.xml - typo3DatabaseDriver=pdo_sqlite vendor/bin/phpunit -c Build/FunctionalTests.xml -# Build in PHP 8.1 and TYPO3 12.4 -test:php81:typo3_12: +test:php81: <<: *test_php variables: CONTAINER_IMAGE: $CI_REGISTRY/containers/phpunit-with-php-8.1:main - TYPO3_VERSION: ^12.4 -# Build in PHP 8.2 and TYPO3 12.4 -test:php82:typo3_12: +test:php82: <<: *test_php variables: CONTAINER_IMAGE: $CI_REGISTRY/containers/phpunit-with-php-8.2:main - TYPO3_VERSION: ^12.4 -# Build in PHP 8.3 and TYPO3 12.4 -test:php83:typo3_12: +test:php83: <<: *test_php variables: CONTAINER_IMAGE: $CI_REGISTRY/containers/phpunit-with-php-8.3:main - TYPO3_VERSION: ^12.4 -# Build in PHP 8.3 and TYPO3 12.4 -test:php84:typo3_12: +test:php84: <<: *test_php variables: CONTAINER_IMAGE: $CI_REGISTRY/containers/phpunit-with-php-8.4:main - TYPO3_VERSION: ^12.4 .test_codeception: &test_codeception stage: test @@ -144,43 +129,31 @@ test:php84:typo3_12: expire_in: 1 day when: always -# Build in PHP 8.1 and TYPO3 12.4 -test:codception:php81:typo3_12: +codeception:php81: <<: *test_codeception variables: CONTAINER_IMAGE: $CI_REGISTRY/containers/codeception-with-php-8.1:main - TYPO3_VERSION: ^12.4 - GECKODRIVER_VERSION: v0.34.0 -# Build in PHP 8.2 and TYPO3 12.4 -test:codception:php82:typo3_12: +codeception:php82: <<: *test_codeception needs: - - test:codception:php81:typo3_12 + - codeception:php81 variables: CONTAINER_IMAGE: $CI_REGISTRY/containers/codeception-with-php-8.2:main - TYPO3_VERSION: ^12.4 - GECKODRIVER_VERSION: v0.34.0 -# Build in PHP 8.3 and TYPO3 12.4 -test:codception:php83:typo3_12: +codeception:php83: <<: *test_codeception needs: - - test:codception:php82:typo3_12 + - codeception:php82 variables: CONTAINER_IMAGE: $CI_REGISTRY/containers/codeception-with-php-8.3:main - TYPO3_VERSION: ^12.4 - GECKODRIVER_VERSION: v0.34.0 -# Build in PHP 8.4 and TYPO3 12.4 -test:codception:php84:typo3_12: +codeception:php84: <<: *test_codeception needs: - - test:codception:php83:typo3_12 + - codeception:php83 variables: CONTAINER_IMAGE: $CI_REGISTRY/containers/codeception-with-php-8.4:main - TYPO3_VERSION: ^12.4 - GECKODRIVER_VERSION: v0.34.0 documentation: stage: documentation From 7bce8e8bb865f3e3dc600f887282daf97a610c3f Mon Sep 17 00:00:00 2001 From: Daniel Gohlke Date: Fri, 21 Feb 2025 20:39:17 +0100 Subject: [PATCH 4/4] [CLEANUP] Group php and acceptance test in GitHub Action similar to GitLab CI --- .github/workflows/ci.yaml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3b01ddc9..cfec80b7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -97,7 +97,7 @@ jobs: - name: Code Quality (by PHPStan) run: vendor/bin/phpstan analyse -c Build/phpstan.neon - tests-acceptance: + test-php: runs-on: ubuntu-latest needs: - coding-guideline @@ -133,6 +133,17 @@ jobs: - name: Run Functional Tests PHP8.4 run: nix-shell --arg phpVersion \"php84\" --pure --run project-test-functional + test-acceptance: + runs-on: ubuntu-latest + needs: + - test-php + steps: + - uses: actions/checkout@v3 + + - uses: cachix/install-nix-action@v17 + with: + nix_path: nixpkgs=channel:nixos-unstable + - name: Run Acceptance Tests PHP8.1 run: nix-shell --arg phpVersion \"php81\" --pure --run project-test-acceptance