Skip to content

Commit

Permalink
fixup! Fix docker images build to handle old linux distributions
Browse files Browse the repository at this point in the history
  • Loading branch information
alquerci committed Nov 18, 2023
1 parent 3eef9e5 commit 4383879
Show file tree
Hide file tree
Showing 2 changed files with 242 additions and 53 deletions.
13 changes: 2 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,9 @@ Tests

test/bin/test

### For PHP 7.3 and for lowest dependencies versions?

test/bin/test php73 lowest

### For PHP 7.3 and for highest dependencies versions?

test/bin/test php73 highest

### For executing a dedicated test file?

test/bin/test php73 highest test/unit/cache/sfAPCCacheTest.php
### Want to do specific test ? Ask help with the option.

test/bin/test --help

### When you finish your work day, do not forget to clean up your desk

Expand Down
282 changes: 240 additions & 42 deletions test/bin/test
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,119 @@
#

__DIR__=`dirname "$0"`
rootdir="${__DIR__}/../.."
ROOT_DIR="${__DIR__}/../.."

. "${rootdir}"/.env.dist
. "${rootdir}"/.env || :
main ()
{
importEnvironmentVariablesFromDirectory "${ROOT_DIR}"

# Configuration
#
dependencyPreferences='highest'
configureWithArguments ${1+"$@"}

# Commands
#
dcexec="${DOCKER_COMPOSE} exec -u `id -u`:`id -g`"
installSubmodule='git submodule update --checkout --recursive --force'
composerUpdate='composer update --prefer-dist --no-suggest --optimize-autoloader'
symfonyTestSuite='data/bin/symfony symfony:test --trace'
startDockerComposeServices

# Parse arguments
#
phpVersions="${1-}"
dependencyPreferences="${2-${dependencyPreferences}}"
phpTestRuntime="${3-${symfonyTestSuite}}"
populatePHPVersions

runTests
}

script ()
printHelp ()
{
echo
echo
echo $0 ${1} ${2}
echo
cat <<EOF
$0 - symfony1 tests tool.
Usage:
test/bin/test [--php-versions <PHP_VERSION>...]
[--dependency-preference <DEPENDENCY_PREFERENCE>...]
[--php-test-runtime <PHP_TEST_RUNTIME>]
Options:
--help Show this screen.
--php-versions Select specific php versions. [default: ${PHP_VERSIONS}]
Examples:
php53
'php53 php54'
--dependency-preference Select spectific dependency preference. [default: ${DEPENDENCY_PREFERENCES}]
Allows values:
- highest
- lowest
--php-test-runtime The endpoint command to run test. [default: ${PHP_TEST_RUNTIME}]
Files:
There are a few configuration files to control certain aspects of operation.
<rootdir>/.env.dist
This is the default configuration file read on startup.
<rootdir>/.env
This is the custom configuration file read on startup.
To be used to extends <rootdir>/.env.dist with custom configuration.
Examples:
* How to execute all tests on all supported PHP versions and dependencies?
$ test/bin/test
* How to execute all tests on specific PHP version ?
$ test/bin/test --php-versions 'php56 php74 php82'
* How to execute all tests on lowest and highest dependency preference ?
install_${dependencyPreference} ${phpVersion}
$ test/bin/test --dependency-preferences 'lowest highest'
${dcexec} ${1} php data/bin/check_configuration.php
${dcexec} ${1} php ${phpTestRuntime}
* When you finish your work day, do not forget to clean up your desk
$ docker-compose down
EOF
}

scriptAll ()
importEnvironmentVariablesFromDirectory ()
{
for dependencyPreference in ${dependencyPreferences}
do
for phpVersion in ${phpVersions}
do
script ${phpVersion} ${dependencyPreference}
done
done
a_directory=${1}

. "${a_directory}"/.env.dist

if test -r "${a_directory}"/.env; then
. "${a_directory}"/.env
else :; fi
}

startDockerComposeServices ()
{
echo "+ ${DOCKER_COMPOSE} build"
${DOCKER_COMPOSE} up -d --build --remove-orphans > /dev/null
}

configureWithArguments ()
{
# Commands
#
DOCKER_COMPOSE_EXEC="${DOCKER_COMPOSE} exec -u `id -u`:`id -g`"
INSTALL_GIT_SUB_MODULE='git submodule update --checkout --recursive --force'
COMPOSER_UPDATE='composer update --prefer-dist --no-suggest --optimize-autoloader'

# Default Options
#
DEPENDENCY_PREFERENCES='highest'
PHP_VERSIONS='all'
PHP_TEST_RUNTIME='data/bin/symfony symfony:test --trace'
hasHelpOption=false

parseOperands ${1+"$@"}

if ${hasHelpOption}; then
printHelp

exit 0
else :; fi
}

populatePHPVersions ()
{
if test x'all' = x"${PHP_VERSIONS}"; then
PHP_VERSIONS=`fetchAllPHPVersions`
else :; fi
}

fetchAllPHPVersions ()
Expand All @@ -63,18 +132,50 @@ fetchAllPHPVersions ()
| sort
}

runTests ()
{
for dependencyPreference in ${DEPENDENCY_PREFERENCES}
do
for phpVersion in ${PHP_VERSIONS}
do
runTestsForOnePhpVersionAndOneDependencyPreference ${phpVersion} ${dependencyPreference}
done
done
}

runTestsForOnePhpVersionAndOneDependencyPreference ()
{
a_phpVersion=${1}
a_dependencyPreference=${2}

echo
echo
echo $0 ${a_phpVersion} ${a_dependencyPreference}
echo

install_${a_dependencyPreference} ${a_phpVersion}

${DOCKER_COMPOSE_EXEC} ${a_phpVersion} php data/bin/check_configuration.php
${DOCKER_COMPOSE_EXEC} ${a_phpVersion} php ${PHP_TEST_RUNTIME}
}

install_highest ()
{
${installSubmodule} --remote
${dcexec} ${1} ${composerUpdate}
b_service=${1}

${INSTALL_GIT_SUB_MODULE} --remote

${DOCKER_COMPOSE_EXEC} ${b_service} ${COMPOSER_UPDATE}
}

install_lowest ()
{
c_service=${1}

reset_submodules
${INSTALL_GIT_SUB_MODULE}

${installSubmodule}
${dcexec} ${1} ${composerUpdate} --prefer-lowest
${DOCKER_COMPOSE_EXEC} ${c_service} ${COMPOSER_UPDATE} --prefer-lowest
}

reset_submodules ()
Expand All @@ -84,11 +185,108 @@ reset_submodules ()
git submodule init
}

echo "+ ${DOCKER_COMPOSE} build"
${DOCKER_COMPOSE} up -d --build --remove-orphans
parseOperands ()
{
parseOperands_init

for parseOperands_currentOperand
do
if parseOperands_previousOptionNeedsValue; then
parseOperands_assignValueToVariableToSet

continue
else :; fi

parseOperands_extractValueFromCurrentOperand

case ${parseOperands_endOfOptions}${parseOperands_currentOperand} in #(
--)
parseOperands_endOfOptions='yes'
;; #(
--help)
hasHelpOption=${optionValue}
;; #(
--php-versions)
variableToSet=PHP_VERSIONS
;; #(
--php-versions=*)
PHP_VERSIONS=${optionValue}
;; #(
--dependency-preferences)
variableToSet=DEPENDENCY_PREFERENCES
;; #(
--dependency-preferences=*)
DEPENDENCY_PREFERENCES=${optionValue}
;; #(
--php-test-runtime)
variableToSet=PHP_TEST_RUNTIME
;; #(
--php-test-runtime=*)
PHP_TEST_RUNTIME=${optionValue}
;; #(
# --flag-option)
# hasFlagOption=${optionValue}
# ;; #(
# --value-option)
# variableToSet=valueOption
# ;; #(
# --value-option=*)
# valueOption=${optionValue}
# ;; #(
-*)
:
;; #(
*)
parseOperands_argumentPosition=`expr 1 \+ ${parseOperands_argumentPosition}`

case ${parseOperands_argumentPosition} in #(
# 1)
# firstArgument=${parseOperands_currentOperand}
# ;; #(
*)
:
;;
esac
;;
esac
done
}

parseOperands_init ()
{
variableToSet=
optionValue=

parseOperands_endOfOptions=
parseOperands_argumentPosition=0
parseOperands_operandEnabledValue=':'
}

parseOperands_assignValueToVariableToSet ()
{
eval ${variableToSet}=\"${parseOperands_currentOperand}\"

variableToSet=
}

parseOperands_previousOptionNeedsValue ()
{
test x != x"${variableToSet}"
}

test x"" != x"${phpVersions}" || {
phpVersions=`fetchAllPHPVersions`
parseOperands_extractValueFromCurrentOperand ()
{
case ${parseOperands_currentOperand} in #(
?*=?*)
optionValue=`expr X"${parseOperands_currentOperand}" : X'[^=]*=\(.*\)'`
;; #(
?*=)
optionValue=
;; #(
*)
optionValue=${parseOperands_operandEnabledValue}
;;
esac
}

scriptAll
main ${1+"$@"}

0 comments on commit 4383879

Please sign in to comment.