Commit ff134cc9 authored by Stefan Bürk's avatar Stefan Bürk Committed by Christian Kuhn
Browse files

[TASK] CI detection in runTests.sh for phpstan

phpstan parallel execution is limited to a maximum
of 5 processes to be a nice neighbor when executed
during core CI runs. This however leads to longer
execution times when executed on local developer
machines with many available CPU's.

This patch introduces two separated phpstan config
file entrypoints, one for local and one for CI. They
are automatically selected in runTests.sh based on
existence of a CI env variable.

Resolves: #97571
Releases: main, 11.5
Change-Id: I14bf13412de7a2471703e7982dad4030ae6ba735
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/74536

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Tested-by: Nikita Hovratov's avatarNikita Hovratov <nikita.h@live.de>
Tested-by: Oliver Klee's avatarOliver Klee <typo3-coding@oliverklee.de>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: Oliver Klee's avatarOliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent d6965d85
......@@ -37,6 +37,8 @@ setUpDockerComposeDotEnv() {
echo "CHUNKS=${CHUNKS}"
echo "THISCHUNK=${THISCHUNK}"
echo "DOCKER_SELENIUM_IMAGE=${DOCKER_SELENIUM_IMAGE}"
echo "IS_CORE_CI=${IS_CORE_CI}"
echo "PHPSTAN_CONFIG_FILE=${PHPSTAN_CONFIG_FILE}"
} > .env
}
......@@ -331,6 +333,14 @@ POSTGRES_VERSION="10"
CHUNKS=0
THISCHUNK=0
DOCKER_SELENIUM_IMAGE="selenium/standalone-chrome:4.0.0-20211102"
IS_CORE_CI=0
PHPSTAN_CONFIG_FILE="phpstan.local.neon"
# ENV var "CI" is set by gitlab-ci. We use it here to distinct 'local' and 'CI' environment.
if [ "$CI" == "true" ]; then
IS_CORE_CI=1
PHPSTAN_CONFIG_FILE="phpstan.ci.neon"
fi
# Detect arm64 and use a seleniarm image.
# In a perfect world selenium would have a arm64 integrated, but that is not on the horizon.
......@@ -851,13 +861,15 @@ if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
fi
echo "" >&2
echo "###########################################################################" >&2
echo "Result of ${TEST_SUITE}" >&2
if [[ ${IS_CORE_CI} -eq 1 ]]; then
echo "Environment: CI" >&2
else
echo "Environment: local" >&2
fi
echo "PHP: ${PHP_VERSION}" >&2
if [[ ${TEST_SUITE} =~ ^(functional|acceptance|acceptanceInstall)$ ]]; then
echo "Result of ${TEST_SUITE}" >&2
echo "PHP: ${PHP_VERSION}" >&2
echo "${DBMS_OUTPUT}" >&2
else
echo "Result of ${TEST_SUITE}" >&2
echo "PHP: ${PHP_VERSION}" >&2
fi
if [[ ${SUITE_EXIT_CODE} -eq 0 ]]; then
......
includes:
- phpstan.neon
parameters:
parallel:
# Don't be overly greedy on machines with more CPU's to be a good neighbor especially on CI
maximumNumberOfProcesses: 5
# @todo Process timeout raised as a intermediate solution. This should be further investigated if we can mitigate
# the occurring subprocess timeout issue through other configurations and minimize the execution time again.
processTimeout: 900.0
includes:
- phpstan.neon
......@@ -9,13 +9,6 @@ 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
# @todo Process timeout raised as a intermediate solution. This should be further investigated if we can mitigate
# the occurring subprocess timeout issue through other configurations and minimize the execution time again.
processTimeout: 900.0
level: 5
bootstrapFiles:
......
......@@ -1206,7 +1206,7 @@ services:
set -x
fi
mkdir -p .cache
bin/phpstan analyse -c Build/phpstan/phpstan.neon --no-progress --no-interaction --memory-limit 4G ${TEST_FILE}
bin/phpstan analyse -c Build/phpstan/${PHPSTAN_CONFIG_FILE} --no-progress --no-interaction --memory-limit 4G ${TEST_FILE}
"
phpstan_generate_baseline:
......@@ -1221,7 +1221,7 @@ services:
set -x
fi
mkdir -p .cache
bin/phpstan analyse -c Build/phpstan/phpstan.neon --no-progress --no-interaction --memory-limit 4G --generate-baseline=Build/phpstan/phpstan-baseline.neon
bin/phpstan analyse -c Build/phpstan/${PHPSTAN_CONFIG_FILE} --no-progress --no-interaction --memory-limit 4G --generate-baseline=Build/phpstan/phpstan-baseline.neon
"
unit:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment