From c55d8775b970d970d898ff9fd6fa89d88448b2b7 Mon Sep 17 00:00:00 2001 From: Daniel Gohlke Date: Thu, 12 Nov 2026 02:10:06 +0100 Subject: [PATCH 1/5] [TASK] Remove stale GitLab CI entry from .gitattributes The GitLab CI configuration has already been removed, so its export-ignore entry is not needed any more. Co-Authored-By: Claude Opus 5.5 --- .gitattributes | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index 5f631f0..538b2b2 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,3 @@ /Build/ export-ignore /Tests/ export-ignore /.gitattributes export-ignore -/.gitlab-ci.yml export-ignore \ No newline at end of file From 17eda55051f13547319b2d6574e454b8545cd34f Mon Sep 17 00:00:00 2001 From: Daniel Gohlke Date: Thu, 12 Nov 2026 02:15:50 +0100 Subject: [PATCH 2/5] [TASK] Add missing export-ignore entries to .gitattributes Exclude all files that are only needed for development from the distribution archive, so they do not end up in the vendor directory of projects installing the extension. Co-Authored-By: Claude Opus 5.5 --- .gitattributes | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitattributes b/.gitattributes index 538b2b2..c428778 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,9 @@ +/.github/ export-ignore /Build/ export-ignore /Tests/ export-ignore /.gitattributes export-ignore +/.gitignore export-ignore +/codeception.dist.yml export-ignore +/crowdin.yml export-ignore +/rector.php export-ignore +/shell.nix export-ignore From bfab384fb13d4ace340f26d0c5daae87a2c90642 Mon Sep 17 00:00:00 2001 From: Daniel Gohlke Date: Thu, 12 Nov 2026 01:58:13 +0100 Subject: [PATCH 3/5] [TASK] Use same build directory for all cart extensions Move the vendor, bin and web directory to .Build/vendor, .Build/bin and .Build/public, as done by the TYPO3BestPractices/tea extension and most of the widely used TYPO3 extensions. All references in composer.json, CI configuration, test configuration, scripts and shell.nix are adjusted accordingly. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yaml | 4 ++-- .gitignore | 3 +-- Build/FunctionalTests.xml | 2 +- Build/UnitTests.xml | 2 +- codeception.dist.yml | 6 +++--- composer.json | 6 ++++-- shell.nix | 24 ++++++++++++------------ 7 files changed, 24 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7b3a952..31d1ea1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -49,7 +49,7 @@ jobs: run: composer install --prefer-dist --no-progress --no-suggest - name: Coding Guideline - run: vendor/bin/php-cs-fixer fix --config=Build/.php-cs-fixer.dist.php -v --dry-run --using-cache=no --path-mode=intersection ./ + run: .Build/bin/php-cs-fixer fix --config=Build/.php-cs-fixer.dist.php -v --dry-run --using-cache=no --path-mode=intersection ./ code-quality: runs-on: ubuntu-latest @@ -78,7 +78,7 @@ jobs: && composer install --no-progress --no-ansi --no-interaction - name: Code Quality (by PHPStan) - run: vendor/bin/phpstan analyse -c Build/phpstan.neon + run: .Build/bin/phpstan analyse -c Build/phpstan.neon test-unit-and-functional: runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index c33c81b..fabdc84 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -.build +.Build composer.lock .php-cs-fixer.cache @@ -11,7 +11,6 @@ Documentation/_make .idea var/ -vendor/ phpunit.coverage.xml phpunit.report.xml diff --git a/Build/FunctionalTests.xml b/Build/FunctionalTests.xml index 888811b..615428f 100644 --- a/Build/FunctionalTests.xml +++ b/Build/FunctionalTests.xml @@ -3,7 +3,7 @@ xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd" backupGlobals="true" beStrictAboutTestsThatDoNotTestAnything="false" - bootstrap="../vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php" + bootstrap="../.Build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php" cacheResult="false" colors="true" failOnDeprecation="true" diff --git a/Build/UnitTests.xml b/Build/UnitTests.xml index d69a6b6..5e3b72d 100644 --- a/Build/UnitTests.xml +++ b/Build/UnitTests.xml @@ -3,7 +3,7 @@ xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd" backupGlobals="true" beStrictAboutTestsThatDoNotTestAnything="false" - bootstrap="../vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsBootstrap.php" + bootstrap="../.Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsBootstrap.php" cacheResult="false" colors="true" failOnDeprecation="true" diff --git a/codeception.dist.yml b/codeception.dist.yml index 33354b7..4c7aa82 100644 --- a/codeception.dist.yml +++ b/codeception.dist.yml @@ -3,7 +3,7 @@ namespace: 'Extcode\CartBooks\Tests\Acceptance\Support' paths: tests: 'Tests/Acceptance' data: 'Tests/Acceptance/Data' - output: '.build/web/typo3temp/var/tests/acceptance-reports' + output: '.Build/public/typo3temp/var/tests/acceptance-reports' support: 'Tests/Acceptance/Support' settings: @@ -13,8 +13,8 @@ extensions: enabled: - 'Codeception\Extension\RunProcess': - - 'geckodriver > .build/web/typo3temp/var/tests/acceptance-logs/geckodriver.log 2>&1' - - 'TYPO3_PATH_APP="$INSTANCE_PATH" TYPO3_PATH_ROOT="$INSTANCE_PATH" php -S 127.0.0.1:8080 -t "$INSTANCE_PATH" > .build/web/typo3temp/var/tests/acceptance-logs/php.log 2>&1' + - 'geckodriver > .Build/public/typo3temp/var/tests/acceptance-logs/geckodriver.log 2>&1' + - 'TYPO3_PATH_APP="$INSTANCE_PATH" TYPO3_PATH_ROOT="$INSTANCE_PATH" php -S 127.0.0.1:8080 -t "$INSTANCE_PATH" > .Build/public/typo3temp/var/tests/acceptance-logs/php.log 2>&1' - 'Codeception\Extension\Recorder' - diff --git a/composer.json b/composer.json index e1920e1..e210ba8 100644 --- a/composer.json +++ b/composer.json @@ -36,12 +36,14 @@ "allow-plugins": { "typo3/cms-composer-installers": true, "typo3/class-alias-loader": true - } + }, + "vendor-dir": ".Build/vendor", + "bin-dir": ".Build/bin" }, "extra": { "typo3/cms": { "extension-key": "cart_books", - "web-dir": ".build/web" + "web-dir": ".Build/public" } }, "require": { diff --git a/shell.nix b/shell.nix index 2e57aca..70e7f07 100644 --- a/shell.nix +++ b/shell.nix @@ -35,7 +35,7 @@ let ]; text = '' - ./vendor/bin/php-cs-fixer fix --config=Build/.php-cs-fixer.dist.php -v --dry-run --diff + ./.Build/bin/php-cs-fixer fix --config=Build/.php-cs-fixer.dist.php -v --dry-run --diff ''; }; @@ -47,7 +47,7 @@ let ]; text = '' - ./vendor/bin/php-cs-fixer fix --config=Build/.php-cs-fixer.dist.php + ./.Build/bin/php-cs-fixer fix --config=Build/.php-cs-fixer.dist.php ''; }; @@ -71,7 +71,7 @@ let ]; text = '' - ./vendor/bin/typoscript-lint -c Build/typoscriptlint.yaml Configuration + ./.Build/bin/typoscript-lint -c Build/typoscriptlint.yaml Configuration ''; }; @@ -83,7 +83,7 @@ let ]; text = '' - ./vendor/bin/phpstan analyse -c Build/phpstan.neon --memory-limit 256M + ./.Build/bin/phpstan analyse -c Build/phpstan.neon --memory-limit 256M ''; }; @@ -95,7 +95,7 @@ let ]; text = '' project-install - vendor/bin/phpunit -c Build/UnitTests.xml + .Build/bin/phpunit -c Build/UnitTests.xml ''; }; @@ -107,7 +107,7 @@ let ]; text = '' project-install - vendor/bin/phpunit -c Build/FunctionalTests.xml + .Build/bin/phpunit -c Build/FunctionalTests.xml ''; }; @@ -124,14 +124,14 @@ let text = '' project-install - mkdir -p "$PROJECT_ROOT/.build/web/typo3temp/var/tests/acceptance" - mkdir -p "$PROJECT_ROOT/.build/web/typo3temp/var/tests/acceptance-logs" - mkdir -p "$PROJECT_ROOT/.build/web/typo3temp/var/tests/acceptance-reports" - mkdir -p "$PROJECT_ROOT/.build/web/typo3temp/var/tests/acceptance-sqlite-dbs" + mkdir -p "$PROJECT_ROOT/.Build/public/typo3temp/var/tests/acceptance" + mkdir -p "$PROJECT_ROOT/.Build/public/typo3temp/var/tests/acceptance-logs" + mkdir -p "$PROJECT_ROOT/.Build/public/typo3temp/var/tests/acceptance-reports" + mkdir -p "$PROJECT_ROOT/.Build/public/typo3temp/var/tests/acceptance-sqlite-dbs" - export INSTANCE_PATH="$PROJECT_ROOT/.build/web/typo3temp/var/tests/acceptance" + export INSTANCE_PATH="$PROJECT_ROOT/.Build/public/typo3temp/var/tests/acceptance" - ./vendor/bin/codecept run + ./.Build/bin/codecept run pgrep -f "php -S" | xargs -r kill pgrep -f "geckodriver" | xargs -r kill From bc679537b1365c972502d7b3e013c18d154a473c Mon Sep 17 00:00:00 2001 From: Daniel Gohlke Date: Thu, 12 Nov 2026 11:05:55 +0100 Subject: [PATCH 4/5] [TASK] Refactor tests to Build/Scripts directory The tests should be executable for local testing and GitHub Actions with nearly the same context. The composer scripts, the nix-shell commands and the CI workflow now call the same scripts in Build/Scripts, which also lift the PHP memory limit. The separate UnitTests.xml and FunctionalTests.xml are merged into Build/phpunit.xml.dist with one testsuite each, as expected by Build/Scripts/phpunit.sh. The unit tests in the CI workflow no longer need nix and run in a php-version matrix. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yaml | 33 ++++++----- Build/Scripts/cgl.sh | 20 +++++++ Build/Scripts/common.sh | 35 ++++++++++++ Build/Scripts/lint-php.sh | 11 ++++ Build/Scripts/phpstan.sh | 12 ++++ Build/Scripts/phpunit.sh | 57 +++++++++++++++++++ Build/UnitTests.xml | 30 ---------- .../{FunctionalTests.xml => phpunit.xml.dist} | 5 +- composer.json | 9 +++ shell.nix | 52 ++++++++--------- 10 files changed, 192 insertions(+), 72 deletions(-) create mode 100755 Build/Scripts/cgl.sh create mode 100644 Build/Scripts/common.sh create mode 100755 Build/Scripts/lint-php.sh create mode 100755 Build/Scripts/phpstan.sh create mode 100755 Build/Scripts/phpunit.sh delete mode 100644 Build/UnitTests.xml rename Build/{FunctionalTests.xml => phpunit.xml.dist} (88%) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 31d1ea1..4637f27 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -30,7 +30,7 @@ jobs: tools: composer:v2 - name: PHP lint - run: "find *.php Classes Configuration Tests -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l" + run: Build/Scripts/lint-php.sh coding-guideline: runs-on: ubuntu-latest @@ -49,7 +49,7 @@ jobs: run: composer install --prefer-dist --no-progress --no-suggest - name: Coding Guideline - run: .Build/bin/php-cs-fixer fix --config=Build/.php-cs-fixer.dist.php -v --dry-run --using-cache=no --path-mode=intersection ./ + run: Build/Scripts/cgl.sh code-quality: runs-on: ubuntu-latest @@ -78,31 +78,34 @@ jobs: && composer install --no-progress --no-ansi --no-interaction - name: Code Quality (by PHPStan) - run: .Build/bin/phpstan analyse -c Build/phpstan.neon + run: Build/Scripts/phpstan.sh test-unit-and-functional: runs-on: ubuntu-latest needs: - coding-guideline - code-quality + strategy: + matrix: + php-version: + - 8.2 + - 8.3 + - 8.4 + - 8.5 steps: - uses: actions/checkout@v5 - - uses: cachix/install-nix-action@v31 + - name: Install PHP + uses: shivammathur/setup-php@v2 with: - nix_path: nixpkgs=channel:nixos-unstable - - - name: Run Unit Tests PHP8.2 - run: nix-shell --arg phpVersion \"php82\" --pure --run project-test-unit - - - name: Run Unit Tests PHP8.3 - run: nix-shell --arg phpVersion \"php83\" --pure --run project-test-unit + php-version: "${{ matrix.php-version }}" + tools: composer:v2 - - name: Run Unit Tests PHP8.4 - run: nix-shell --arg phpVersion \"php84\" --pure --run project-test-unit + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-suggest - - name: Run Unit Tests PHP8.5 - run: nix-shell --arg phpVersion \"php85\" --pure --run project-test-unit + - name: Run unit tests + run: Build/Scripts/phpunit.sh unit test-acceptance: runs-on: ubuntu-latest diff --git a/Build/Scripts/cgl.sh b/Build/Scripts/cgl.sh new file mode 100755 index 0000000..460cd7e --- /dev/null +++ b/Build/Scripts/cgl.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# +# Checks the coding guidelines with php-cs-fixer. +# +# Usage: +# Build/Scripts/cgl.sh check only, fails on violations +# Build/Scripts/cgl.sh --fix fix the violations in place + +source "$(dirname "${BASH_SOURCE[0]}")/common.sh" + +requireBinary php-cs-fixer + +FIXER_ARGS=(--config=Build/.php-cs-fixer.dist.php --using-cache=no) +if [ "${1:-}" = "--fix" ]; then + shift +else + FIXER_ARGS+=(-v --dry-run --diff) +fi + +runPhp "${BIN_DIR}/php-cs-fixer" fix "${FIXER_ARGS[@]}" "$@" diff --git a/Build/Scripts/common.sh b/Build/Scripts/common.sh new file mode 100644 index 0000000..9220642 --- /dev/null +++ b/Build/Scripts/common.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# +# Shared setup for all scripts in Build/Scripts. +# +# This file is sourced, not executed. It changes to the project root, so every +# script behaves the same no matter from where it has been called, and it +# provides the defaults all scripts rely on. +# +# Environment variables used as overrides: +# PHP_BIN php binary to use, defaults to "php" +# PHP_MEMORY_LIMIT memory_limit for all php calls, defaults to "-1" + +set -euo pipefail + +PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +readonly PROJECT_ROOT +cd "${PROJECT_ROOT}" + +PHP_BIN="${PHP_BIN:-php}" +PHP_MEMORY_LIMIT="${PHP_MEMORY_LIMIT:--1}" +BIN_DIR="${PROJECT_ROOT}/.Build/bin" +readonly PHP_BIN PHP_MEMORY_LIMIT BIN_DIR + +# Runs php with the configured memory limit, independent of the php.ini in use. +runPhp() { + "${PHP_BIN}" -d memory_limit="${PHP_MEMORY_LIMIT}" "$@" +} + +# Fails with a readable message if composer install has not been run yet. +requireBinary() { + if [ ! -f "${BIN_DIR}/$1" ]; then + echo "Missing ${BIN_DIR}/$1, please run \"composer install\" first." >&2 + exit 1 + fi +} diff --git a/Build/Scripts/lint-php.sh b/Build/Scripts/lint-php.sh new file mode 100755 index 0000000..1b86352 --- /dev/null +++ b/Build/Scripts/lint-php.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +# +# Lints all php files of the extension for syntax errors. +# +# Usage: +# Build/Scripts/lint-php.sh + +source "$(dirname "${BASH_SOURCE[0]}")/common.sh" + +find ./*.php Classes Configuration Tests -name '*.php' -print0 \ + | xargs -0 -n 1 -P 4 "${PHP_BIN}" -l diff --git a/Build/Scripts/phpstan.sh b/Build/Scripts/phpstan.sh new file mode 100755 index 0000000..6f06604 --- /dev/null +++ b/Build/Scripts/phpstan.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +# +# Runs the static code analysis with phpstan. +# +# Usage: +# Build/Scripts/phpstan.sh [additional phpstan arguments] + +source "$(dirname "${BASH_SOURCE[0]}")/common.sh" + +requireBinary phpstan + +runPhp "${BIN_DIR}/phpstan" analyse -c Build/phpstan.neon "$@" diff --git a/Build/Scripts/phpunit.sh b/Build/Scripts/phpunit.sh new file mode 100755 index 0000000..2636b97 --- /dev/null +++ b/Build/Scripts/phpunit.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +# +# Runs the phpunit tests. +# +# Usage: +# Build/Scripts/phpunit.sh [testsuite] [additional phpunit arguments] +# +# Without a testsuite every suite defined in Build/phpunit.xml.dist is run, +# each one in its own phpunit process. They cannot share a process, the +# functional bootstrap leaks global state into the unit tests. The first +# argument is taken as the testsuite name unless it starts with a dash. +# +# Environment variables used as overrides: +# typo3DatabaseDriver database driver to test against, defaults to "pdo_sqlite" + +source "$(dirname "${BASH_SOURCE[0]}")/common.sh" + +requireBinary phpunit + +export typo3DatabaseDriver="${typo3DatabaseDriver:-pdo_sqlite}" + +runSuite() { + local suite="$1" + shift + + runPhp "${BIN_DIR}/phpunit" \ + -c Build/phpunit.xml.dist \ + --testsuite "${suite}" \ + --display-warnings \ + --display-deprecations \ + --display-errors \ + --display-notices \ + "$@" +} + +if [ $# -gt 0 ] && [ -n "$1" ] && [ "${1:0:1}" != "-" ]; then + TESTSUITE="$1" + shift + runSuite "${TESTSUITE}" "$@" + exit $? +fi + +mapfile -t SUITES < <(runPhp "${BIN_DIR}/phpunit" -c Build/phpunit.xml.dist --list-suites \ + | sed -n 's/^ - \(.*\) ([0-9]\{1,\} tests\{0,1\})$/\1/p') + +if [ ${#SUITES[@]} -eq 0 ]; then + echo "No testsuites found in Build/phpunit.xml.dist." >&2 + exit 1 +fi + +STATUS=0 +for suite in "${SUITES[@]}"; do + echo "Running testsuite \"${suite}\" ..." + runSuite "${suite}" "$@" || STATUS=$? +done + +exit "${STATUS}" diff --git a/Build/UnitTests.xml b/Build/UnitTests.xml deleted file mode 100644 index 5e3b72d..0000000 --- a/Build/UnitTests.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - ../Tests/Unit/ - - - - - ../Classes/ - - - diff --git a/Build/FunctionalTests.xml b/Build/phpunit.xml.dist similarity index 88% rename from Build/FunctionalTests.xml rename to Build/phpunit.xml.dist index 615428f..e77e172 100644 --- a/Build/FunctionalTests.xml +++ b/Build/phpunit.xml.dist @@ -18,9 +18,12 @@ > - + ../Tests/Functional/ + + ../Tests/Unit/ + diff --git a/composer.json b/composer.json index e210ba8..e707891 100644 --- a/composer.json +++ b/composer.json @@ -67,5 +67,14 @@ "typo3/cms-fluid-styled-content": "^13.4", "typo3/cms-install": "^13.4", "typo3/testing-framework": "^8.2" + }, + "scripts": { + "project:cgl": "Build/Scripts/cgl.sh", + "project:cgl:fix": "Build/Scripts/cgl.sh --fix", + "project:lint:php": "Build/Scripts/lint-php.sh", + "project:lint:typoscript": "typoscript-lint -c Build/typoscriptlint.yaml Configuration", + "project:phpstan": "Build/Scripts/phpstan.sh", + "project:test:unit": "Build/Scripts/phpunit.sh unit", + "project:test:functional": "Build/Scripts/phpunit.sh functional" } } diff --git a/shell.nix b/shell.nix index 70e7f07..71dae94 100644 --- a/shell.nix +++ b/shell.nix @@ -23,7 +23,8 @@ let composer ]; text = '' - composer update --prefer-dist --no-progress + rm -rf .Build/ composer.lock + composer update --prefer-dist --no-progress --working-dir="$PROJECT_ROOT" ''; }; @@ -35,7 +36,7 @@ let ]; text = '' - ./.Build/bin/php-cs-fixer fix --config=Build/.php-cs-fixer.dist.php -v --dry-run --diff + "$PROJECT_ROOT/Build/Scripts/cgl.sh" ''; }; @@ -47,67 +48,67 @@ let ]; text = '' - ./.Build/bin/php-cs-fixer fix --config=Build/.php-cs-fixer.dist.php + "$PROJECT_ROOT/Build/Scripts/cgl.sh" --fix ''; }; - projectLintPhp = pkgs.writeShellApplication { - name = "project-lint-php"; + projectLint = pkgs.writeShellApplication { + name = "project-lint"; runtimeInputs = [ php ]; text = '' - find ./*.php Classes Configuration Tests -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l + "$PROJECT_ROOT/Build/Scripts/lint-php.sh" ''; }; - projectLintTypoScript = pkgs.writeShellApplication { - name = "project-lint-typoscript"; + projectPhpstan = pkgs.writeShellApplication { + name = "project-phpstan"; runtimeInputs = [ php ]; text = '' - ./.Build/bin/typoscript-lint -c Build/typoscriptlint.yaml Configuration + "$PROJECT_ROOT/Build/Scripts/phpstan.sh" ''; }; - projectPhpstan = pkgs.writeShellApplication { - name = "project-phpstan"; - + projectTestUnit = pkgs.writeShellApplication { + name = "project-test-unit"; runtimeInputs = [ php + projectInstall ]; - text = '' - ./.Build/bin/phpstan analyse -c Build/phpstan.neon --memory-limit 256M + project-install + "$PROJECT_ROOT/Build/Scripts/phpunit.sh" unit ''; }; - projectTestUnit = pkgs.writeShellApplication { - name = "project-test-unit"; + projectTestFunctional = pkgs.writeShellApplication { + name = "project-test-functional"; runtimeInputs = [ php projectInstall ]; text = '' project-install - .Build/bin/phpunit -c Build/UnitTests.xml + "$PROJECT_ROOT/Build/Scripts/phpunit.sh" functional ''; }; - projectTestFunctional = pkgs.writeShellApplication { - name = "project-test-functional"; + projectTestWithCoverage = pkgs.writeShellApplication { + name = "project-test-with-coverage"; runtimeInputs = [ php projectInstall ]; text = '' project-install - .Build/bin/phpunit -c Build/FunctionalTests.xml + XDEBUG_MODE=coverage ./.Build/bin/phpunit -c Build/phpunit.xml.dist --coverage-html=coverage_result ''; }; @@ -138,22 +139,21 @@ let ''; }; -in pkgs.mkShell { - name = "TYPO3 Extension cart-books"; +in pkgs.mkShellNoCC { + name = "TYPO3 Extension extcode/cart-books"; buildInputs = [ php composer projectInstall - projectPhpstan projectCgl projectCglFix - projectLintPhp - projectLintTypoScript + projectLint + projectPhpstan projectTestUnit projectTestFunctional + projectTestWithCoverage projectTestAcceptance ]; - packages = [ pkgs.gnumake pkgs.busybox ]; shellHook = '' export PROJECT_ROOT="$(pwd)" From 51e387ad8713dc989eb2be0fc82158ee8ee69362 Mon Sep 17 00:00:00 2001 From: Daniel Gohlke Date: Thu, 12 Nov 2026 11:06:40 +0100 Subject: [PATCH 5/5] [TASK] Run acceptance tests via Build/Scripts The acceptance tests were only executable via nix-shell. They now use Build/Scripts/acceptance.sh like the other tests. The script is called by the new composer script project:test:acceptance, the nix-shell command project-test-acceptance and the CI workflow. The CI workflow no longer needs nix and runs the acceptance tests in a php-version matrix. On failure the acceptance reports are uploaded as artifact. The script stops the php webserver and geckodriver on exit, even if the tests fail. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yaml | 35 ++++++++++++++++++++--------- Build/Scripts/acceptance.sh | 45 +++++++++++++++++++++++++++++++++++++ composer.json | 6 ++++- shell.nix | 16 ++++--------- 4 files changed, 78 insertions(+), 24 deletions(-) create mode 100755 Build/Scripts/acceptance.sh diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4637f27..9951d6a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -111,22 +111,35 @@ jobs: runs-on: ubuntu-latest needs: - test-unit-and-functional + strategy: + fail-fast: false + matrix: + php-version: + - 8.2 + - 8.3 + - 8.4 + - 8.5 steps: - uses: actions/checkout@v5 - - uses: cachix/install-nix-action@v31 + - name: Install PHP + uses: shivammathur/setup-php@v2 with: - nix_path: nixpkgs=channel:nixos-unstable - - - name: Run Acceptance Tests PHP8.2 - run: nix-shell --arg phpVersion \"php82\" --pure --run project-test-acceptance + php-version: "${{ matrix.php-version }}" + tools: composer:v2 - - name: Run Acceptance Tests PHP8.3 - run: nix-shell --arg phpVersion \"php83\" --pure --run project-test-acceptance + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-suggest - - name: Run Acceptance Tests PHP8.4 - run: nix-shell --arg phpVersion \"php84\" --pure --run project-test-acceptance + - name: Show browser versions + run: firefox --version && geckodriver --version - - name: Run Acceptance Tests PHP8.5 - run: nix-shell --arg phpVersion \"php85\" --pure --run project-test-acceptance + - name: Run acceptance tests + run: Build/Scripts/acceptance.sh + - name: Upload acceptance reports + if: failure() + uses: actions/upload-artifact@v4 + with: + name: acceptance-reports-php${{ matrix.php-version }} + path: .Build/public/typo3temp/var/tests/acceptance-reports diff --git a/Build/Scripts/acceptance.sh b/Build/Scripts/acceptance.sh new file mode 100755 index 0000000..4274e37 --- /dev/null +++ b/Build/Scripts/acceptance.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# +# Runs the acceptance tests with codeception. +# +# Usage: +# Build/Scripts/acceptance.sh [test] [additional codecept run arguments] +# +# The tests run in the "acceptance" suite, so the first argument can be a +# single Cest, e.g. "AddSimpleProductWithoutStockHandlingToCartCest". +# +# Requirements: +# - firefox and geckodriver available in PATH +# - php with pdo_sqlite +# +# The codeception RunProcess extension starts geckodriver and the php built-in +# webserver. Both are stopped when this script exits, even on failure. + +source "$(dirname "${BASH_SOURCE[0]}")/common.sh" + +requireBinary codecept + +for tool in firefox geckodriver; do + if ! command -v "${tool}" > /dev/null 2>&1; then + echo "Missing \"${tool}\" in PATH, it is required for the acceptance tests." >&2 + exit 1 + fi +done + +TESTS_PATH="${PROJECT_ROOT}/.Build/public/typo3temp/var/tests" +mkdir -p \ + "${TESTS_PATH}/acceptance" \ + "${TESTS_PATH}/acceptance-logs" \ + "${TESTS_PATH}/acceptance-reports" \ + "${TESTS_PATH}/acceptance-sqlite-dbs" + +export INSTANCE_PATH="${TESTS_PATH}/acceptance" + +cleanup() { + pkill -f "php -S 127.0.0.1:8080" || true + pkill -f "geckodriver" || true +} +trap cleanup EXIT + +runPhp "${BIN_DIR}/codecept" build +runPhp "${BIN_DIR}/codecept" run acceptance "$@" diff --git a/composer.json b/composer.json index e707891..2dae5e0 100644 --- a/composer.json +++ b/composer.json @@ -75,6 +75,10 @@ "project:lint:typoscript": "typoscript-lint -c Build/typoscriptlint.yaml Configuration", "project:phpstan": "Build/Scripts/phpstan.sh", "project:test:unit": "Build/Scripts/phpunit.sh unit", - "project:test:functional": "Build/Scripts/phpunit.sh functional" + "project:test:functional": "Build/Scripts/phpunit.sh functional", + "project:test:acceptance": [ + "Composer\\Config::disableProcessTimeout", + "Build/Scripts/acceptance.sh" + ] } } diff --git a/shell.nix b/shell.nix index 71dae94..1f0b822 100644 --- a/shell.nix +++ b/shell.nix @@ -124,24 +124,16 @@ let ]; text = '' project-install - - mkdir -p "$PROJECT_ROOT/.Build/public/typo3temp/var/tests/acceptance" - mkdir -p "$PROJECT_ROOT/.Build/public/typo3temp/var/tests/acceptance-logs" - mkdir -p "$PROJECT_ROOT/.Build/public/typo3temp/var/tests/acceptance-reports" - mkdir -p "$PROJECT_ROOT/.Build/public/typo3temp/var/tests/acceptance-sqlite-dbs" - - export INSTANCE_PATH="$PROJECT_ROOT/.Build/public/typo3temp/var/tests/acceptance" - - ./.Build/bin/codecept run - - pgrep -f "php -S" | xargs -r kill - pgrep -f "geckodriver" | xargs -r kill + "$PROJECT_ROOT/Build/Scripts/acceptance.sh" "$@" ''; }; in pkgs.mkShellNoCC { name = "TYPO3 Extension extcode/cart-books"; buildInputs = [ + pkgs.firefox + pkgs.geckodriver + pkgs.procps php composer projectInstall