From 7257f2a8551b7291010a1cea797a374528f145f0 Mon Sep 17 00:00:00 2001 From: Christian Kuhn <lolli@schwarzbu.ch> Date: Tue, 26 Jan 2021 12:46:29 +0100 Subject: [PATCH] [TASK] runTests.sh: Add phpstan and docBlockCheck Allows: * Build/Scripts/runTests.sh -s docBlockCheck * Build/Scripts/runTests.sh -s phpstan These two have been added to bamboo with #89023, but not to runTests.sh. phpstan is tuned a bit to create it's cache in .cache rather than ephermal /tmp to survive between host reboots. Additionally the number of max CPU's is restricted in phpstan to be a better neighbor on local dev machines and on CI. Resolves: #93367 Related: #89023 Releases: master, 10.4 Change-Id: I5672370b51205266ee46888837f151de8e809edf Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/67534 Reviewed-by: Simon Gilli <typo3@gilbertsoft.org> Reviewed-by: Jochen <rothjochen@gmail.com> Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Simon Gilli <typo3@gilbertsoft.org> Tested-by: TYPO3com <noreply@typo3.com> Tested-by: Jochen <rothjochen@gmail.com> Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> --- Build/Scripts/runTests.sh | 18 +++++++++-- Build/testing-docker/local/docker-compose.yml | 31 ++++++++++++++++++- phpstan.neon | 7 +++++ 3 files changed, 53 insertions(+), 3 deletions(-) diff --git a/Build/Scripts/runTests.sh b/Build/Scripts/runTests.sh index bfe06786a0d6..d5752ee91699 100755 --- a/Build/Scripts/runTests.sh +++ b/Build/Scripts/runTests.sh @@ -57,7 +57,7 @@ No arguments: Run all unit tests with PHP 7.4 Options: -s <...> Specifies which test suite to run - - acceptance: backend acceptance tests + - acceptance: main backend acceptance tests - acceptancePagetree: backend acceptance tests for page tree - acceptanceInstallTool: acceptance tests for stand alone install tool - buildCss: execute scss to css builder @@ -79,6 +79,7 @@ Options: - composerInstallMax: "composer update", with no platform.php config. - composerInstallMin: "composer update --prefer-lowest", with platform.php set to PHP version x.x.0. - composerValidate: "composer validate" + - docBlockCheck: Scan php doc blocks for validity - fixCsvFixtures: fix broken functional test csv fixtures - functional: functional tests - install: installation acceptance tests, only with -d mariadb|postgres|sqlite @@ -86,6 +87,7 @@ Options: - lintScss: SCSS linting - lintTypescript: TS linting - lintHtml: HTML linting + - phpstan: phpstan tests - unit (default): PHP unit tests - unitDeprecated: deprecated PHP unit tests - unitJavascript: JavaScript unit tests @@ -507,6 +509,12 @@ case ${TEST_SUITE} in SUITE_EXIT_CODE=$? docker-compose down ;; + docBlockCheck) + setUpDockerComposeDotEnv + docker-compose run doc_block_check + SUITE_EXIT_CODE=$? + docker-compose down + ;; fixCsvFixtures) setUpDockerComposeDotEnv docker-compose run fix_csv_fixtures @@ -583,7 +591,7 @@ case ${TEST_SUITE} in ;; lint) setUpDockerComposeDotEnv - docker-compose run lint + docker-compose run lint_php SUITE_EXIT_CODE=$? docker-compose down ;; @@ -605,6 +613,12 @@ case ${TEST_SUITE} in SUITE_EXIT_CODE=$? docker-compose down ;; + phpstan) + setUpDockerComposeDotEnv + docker-compose run phpstan + SUITE_EXIT_CODE=$? + docker-compose down + ;; unit) setUpDockerComposeDotEnv docker-compose run unit diff --git a/Build/testing-docker/local/docker-compose.yml b/Build/testing-docker/local/docker-compose.yml index 483a435804c9..bc1fabd1852a 100644 --- a/Build/testing-docker/local/docker-compose.yml +++ b/Build/testing-docker/local/docker-compose.yml @@ -640,6 +640,20 @@ services: composer validate; " + doc_block_check: + image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest + user: ${HOST_UID} + volumes: + - ${CORE_ROOT}:${CORE_ROOT} + working_dir: ${CORE_ROOT} + command: > + /bin/sh -c " + if [ ${SCRIPT_VERBOSE} -eq 1 ]; then + set -x + fi + Build/Scripts/docBlockChecker.php; + " + functional_split: image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest user: ${HOST_UID} @@ -913,7 +927,7 @@ services: fi " - lint: + lint_php: image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest user: ${HOST_UID} volumes: @@ -984,6 +998,21 @@ services: node_modules/grunt/bin/grunt eslint; " + phpstan: + image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest + user: ${HOST_UID} + volumes: + - ${CORE_ROOT}:${CORE_ROOT} + working_dir: ${CORE_ROOT} + command: > + /bin/sh -c " + if [ ${SCRIPT_VERBOSE} -eq 1 ]; then + set -x + fi + mkdir -p .cache + bin/phpstan analyse --no-progress --no-interaction --memory-limit 4G + " + unit: image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest user: ${HOST_UID} diff --git a/phpstan.neon b/phpstan.neon index 261a9d94d35c..5cd6a9307c8d 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -5,6 +5,13 @@ includes: # - vendor/phpstan/phpstan/conf/bleedingEdge.neon parameters: + # Use local .cache dir instead of /tmp + tmpDir: .cache/phpstan + + parallel: + # Don't be overly greedy on machines with more CPU's to be a good neighbor especially on CI + maximumNumberOfProcesses: 5 + level: 2 # level 2 parameters which are set to opposite values in the original level 2 configuration. Parameters need to be -- GitLab