|
9 | 9 | # Example: "lowest highest"
|
10 | 10 | #
|
11 | 11 |
|
12 |
| -# Configuration |
13 |
| -# |
14 |
| -dependencyPreferences='highest' |
15 |
| -skipPHPVersions='php8' |
| 12 | +main () |
| 13 | +{ |
| 14 | + # Configuration |
| 15 | + # |
| 16 | + dependencyPreferences='highest' |
16 | 17 |
|
17 |
| -# Commands |
18 |
| -# |
19 |
| -dcexec="docker-compose exec -u `id -u`:`id -g`" |
20 |
| -installSubmodule='git submodule update --checkout --recursive --force' |
21 |
| -composerUpdate='composer update --prefer-dist --no-suggest --optimize-autoloader' |
22 |
| -symfonyTestSuite='data/bin/symfony symfony:test --trace' |
| 18 | + # Commands |
| 19 | + # |
| 20 | + dcexec="docker-compose exec -u `id -u`:`id -g`" |
| 21 | + installSubmodule='git submodule update --checkout --recursive --force' |
| 22 | + composerUpdate='composer update --prefer-dist --no-suggest --optimize-autoloader' |
| 23 | + symfonyTestSuite='data/bin/symfony symfony:test --trace' |
23 | 24 |
|
24 |
| -# Parse arguments |
25 |
| -# |
26 |
| -phpVersions="${1-}" |
27 |
| -dependencyPreferences="${2-${dependencyPreferences}}" |
28 |
| -phpTestRuntime="${3-${symfonyTestSuite}}" |
| 25 | + # Parse arguments |
| 26 | + # |
| 27 | + phpVersions="${1-}" |
| 28 | + dependencyPreferences="${2-${dependencyPreferences}}" |
| 29 | + phpTestRuntime="${3-${symfonyTestSuite}}" |
| 30 | + |
| 31 | + echo '+ docker-compose build' |
| 32 | + docker-compose up -d --build --remove-orphans > /dev/null |
| 33 | + |
| 34 | + test x"" != x"${phpVersions}" || { |
| 35 | + phpVersions=`fetchAllPHPVersions` |
| 36 | + } |
| 37 | + |
| 38 | + tearDownRegisterFunction reset_submodules |
| 39 | + |
| 40 | + scriptAll |
| 41 | +} |
29 | 42 |
|
30 | 43 | script ()
|
31 | 44 | {
|
32 |
| - echo |
33 |
| - echo |
34 |
| - echo $0 ${1} ${2} |
35 |
| - echo |
36 |
| - ${dcexec} ${1} php data/bin/check_configuration.php |
37 |
| - ${dcexec} ${1} php ${phpTestRuntime} |
| 45 | + echo |
| 46 | + echo |
| 47 | + echo $0 ${1} ${2} |
| 48 | + echo |
| 49 | + clearCacheOfMemcached |
| 50 | + ${dcexec} ${1} php data/bin/check_configuration.php |
| 51 | + ${dcexec} ${1} php ${phpTestRuntime} |
38 | 52 | }
|
39 | 53 |
|
40 | 54 | scriptAll ()
|
41 | 55 | {
|
42 |
| - for dependencyPreference in ${dependencyPreferences} |
43 |
| - do |
44 |
| - install_${dependencyPreference} |
45 |
| - |
46 |
| - for phpVersion in ${phpVersions} |
| 56 | + for dependencyPreference in ${dependencyPreferences} |
47 | 57 | do
|
48 |
| - script ${phpVersion} ${dependencyPreference} |
| 58 | + install_${dependencyPreference} |
| 59 | + |
| 60 | + for phpVersion in ${phpVersions} |
| 61 | + do |
| 62 | + script ${phpVersion} ${dependencyPreference} |
| 63 | + done |
49 | 64 | done
|
50 |
| - done |
51 | 65 | }
|
52 | 66 |
|
53 | 67 | fetchAllPHPVersions ()
|
54 | 68 | {
|
55 |
| - docker-compose 2>/dev/null ps --services --filter status=running \ |
56 |
| - | grep php \ |
57 |
| - | sort \ |
58 |
| - | grep -v ${skipPHPVersions} |
| 69 | + docker-compose 2>/dev/null ps --services --filter status=running \ |
| 70 | + | grep php \ |
| 71 | + | sort |
59 | 72 | }
|
60 | 73 |
|
61 | 74 | install_highest ()
|
62 | 75 | {
|
63 |
| - ${installSubmodule} --remote |
64 |
| - ${dcexec} composer ${composerUpdate} |
| 76 | + ${installSubmodule} --remote |
| 77 | + ${dcexec} composer ${composerUpdate} |
65 | 78 | }
|
66 | 79 |
|
67 | 80 | install_lowest ()
|
68 | 81 | {
|
69 |
| - reset_submodules |
| 82 | + reset_submodules |
70 | 83 |
|
71 |
| - ${installSubmodule} |
72 |
| - ${dcexec} composer ${composerUpdate} --prefer-lowest |
| 84 | + ${installSubmodule} |
| 85 | + ${dcexec} composer ${composerUpdate} --prefer-lowest |
73 | 86 | }
|
74 | 87 |
|
75 | 88 | reset_submodules ()
|
76 | 89 | {
|
77 |
| - git submodule deinit --force --quiet -- . |
| 90 | + git submodule deinit --force --quiet -- . |
78 | 91 |
|
79 |
| - git submodule init |
| 92 | + git submodule init |
80 | 93 | }
|
81 | 94 |
|
82 |
| -echo '+ docker-compose build' |
83 |
| -docker-compose up -d --build --remove-orphans > /dev/null |
| 95 | +clearCacheOfMemcached () |
| 96 | +{ |
| 97 | + echo 'Clearing cache of memcached' |
| 98 | + ${dcexec} memcached sh -c 'echo 'flush_all' | nc localhost 11211' |
| 99 | +} |
| 100 | + |
| 101 | +tearDownRegisterFunction() |
| 102 | +{ |
| 103 | + test x"" != x"${tearDown_functions-}" || { |
| 104 | + trap 'tearDown' 2 # CTRL-C |
| 105 | + trap 'tearDown' QUIT TERM EXIT INT KILL SEGV |
| 106 | + } |
| 107 | + |
| 108 | + case ${tearDown_functions-} in #( |
| 109 | + ?*) tearDown_functions="${tearDown_functions} $1" ;; #( |
| 110 | + *) tearDown_functions=$1 ;; |
| 111 | + esac |
| 112 | +} |
| 113 | + |
| 114 | +tearDown() |
| 115 | +{ |
| 116 | + test x"" != x"${tearDown_functions-}" || { |
| 117 | + return 0 |
| 118 | + } |
84 | 119 |
|
85 |
| -test x"" != x"${phpVersions}" || { |
86 |
| - phpVersions=`fetchAllPHPVersions` |
| 120 | + for tearDown_function in ${tearDown_functions} |
| 121 | + do |
| 122 | + ${tearDown_function} |
| 123 | + done |
87 | 124 | }
|
88 | 125 |
|
89 |
| -scriptAll |
| 126 | +main ${1+"$@"} |
0 commit comments