|
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 | + ${dcexec} ${1} php data/bin/check_configuration.php |
| 50 | + ${dcexec} ${1} php ${phpTestRuntime} |
38 | 51 | } |
39 | 52 |
|
40 | 53 | scriptAll () |
41 | 54 | { |
42 | | - for dependencyPreference in ${dependencyPreferences} |
43 | | - do |
44 | | - install_${dependencyPreference} |
45 | | - |
46 | | - for phpVersion in ${phpVersions} |
| 55 | + for dependencyPreference in ${dependencyPreferences} |
47 | 56 | do |
48 | | - script ${phpVersion} ${dependencyPreference} |
| 57 | + install_${dependencyPreference} |
| 58 | + |
| 59 | + for phpVersion in ${phpVersions} |
| 60 | + do |
| 61 | + script ${phpVersion} ${dependencyPreference} |
| 62 | + done |
49 | 63 | done |
50 | | - done |
51 | 64 | } |
52 | 65 |
|
53 | 66 | fetchAllPHPVersions () |
54 | 67 | { |
55 | | - docker-compose 2>/dev/null ps --services --filter status=running \ |
56 | | - | grep php \ |
57 | | - | sort \ |
58 | | - | grep -v ${skipPHPVersions} |
| 68 | + docker-compose 2>/dev/null ps --services --filter status=running \ |
| 69 | + | grep php \ |
| 70 | + | sort |
59 | 71 | } |
60 | 72 |
|
61 | 73 | install_highest () |
62 | 74 | { |
63 | | - ${installSubmodule} --remote |
64 | | - ${dcexec} composer ${composerUpdate} |
| 75 | + ${installSubmodule} --remote |
| 76 | + ${dcexec} composer ${composerUpdate} |
65 | 77 | } |
66 | 78 |
|
67 | 79 | install_lowest () |
68 | 80 | { |
69 | | - reset_submodules |
| 81 | + reset_submodules |
70 | 82 |
|
71 | | - ${installSubmodule} |
72 | | - ${dcexec} composer ${composerUpdate} --prefer-lowest |
| 83 | + ${installSubmodule} |
| 84 | + ${dcexec} composer ${composerUpdate} --prefer-lowest |
73 | 85 | } |
74 | 86 |
|
75 | 87 | reset_submodules () |
76 | 88 | { |
77 | | - git submodule deinit --force --quiet -- . |
| 89 | + git submodule deinit --force --quiet -- . |
78 | 90 |
|
79 | | - git submodule init |
| 91 | + git submodule init |
80 | 92 | } |
81 | 93 |
|
82 | | -echo '+ docker-compose build' |
83 | | -docker-compose up -d --build --remove-orphans > /dev/null |
| 94 | +tearDownRegisterFunction() |
| 95 | +{ |
| 96 | + test x"" != x"${tearDown_functions-}" || { |
| 97 | + trap 'tearDown' 2 # CTRL-C |
| 98 | + trap 'tearDown' QUIT TERM EXIT INT KILL SEGV |
| 99 | + } |
| 100 | + |
| 101 | + case ${tearDown_functions-} in #( |
| 102 | + ?*) tearDown_functions="${tearDown_functions} $1" ;; #( |
| 103 | + *) tearDown_functions=$1 ;; |
| 104 | + esac |
| 105 | +} |
84 | 106 |
|
85 | | -test x"" != x"${phpVersions}" || { |
86 | | - phpVersions=`fetchAllPHPVersions` |
| 107 | +tearDown() |
| 108 | +{ |
| 109 | + test x"" != x"${tearDown_functions-}" || { |
| 110 | + return 0 |
| 111 | + } |
| 112 | + |
| 113 | + for tearDown_function in ${tearDown_functions} |
| 114 | + do |
| 115 | + ${tearDown_function} |
| 116 | + done |
87 | 117 | } |
88 | 118 |
|
89 | | -scriptAll |
| 119 | +main ${1+"$@"} |
0 commit comments