Skip to content

Commit 89eba26

Browse files
committed
feature: handle PDO driver extensions
Projects `composer.json` can require specific PDO drivers such as `ext-pdo_mysql`. These are passed to the CI container as `pdo_mysql` and are then passed as `php<version>-pdo_mysql` package to `apt install`. These packages do not exist and thus there will be an error if the appropriate extension(s) was/were not already installed/enabled. This patch handles the most common drivers `mysql`, `pgsql` and `sqlite` and ensure that these are installed/enabled along with the `pdo` extension. Signed-off-by: Maximilian Bösing <[email protected]>
1 parent 9fdebed commit 89eba26

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

scripts/extensions.sh

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,18 @@ declare -a EXTENSIONS=(${@:2})
9393
ENABLED_EXTENSIONS=$(php -m | tr '[:upper:]' '[:lower:]' | egrep -v '^[\[]' | grep -v 'zend opcache')
9494
EXTENSIONS_TO_INSTALL=()
9595

96+
add_extension_to_install() {
97+
local extension=$1
98+
99+
# Prevent duplicates
100+
if [[ ! " ${EXTENSIONS_TO_INSTALL[@]} " =~ " ${extension} " ]]; then
101+
EXTENSIONS_TO_INSTALL+=("${extension}")
102+
fi
103+
}
104+
96105
# Loop through known statically compiled/installed extensions, and enable them.
97106
# NOTE: when developing on MacOS, remove the quotes while implementing your changes and re-add the quotes afterwards.
98107
for EXTENSION in "${EXTENSIONS[@]}"; do
99-
100108
# Check if extension is already enabled
101109
REGULAR_EXPRESSION=\\b${EXTENSION}\\b
102110
if [[ "${ENABLED_EXTENSIONS}" =~ $REGULAR_EXPRESSION ]]; then
@@ -112,7 +120,32 @@ for EXTENSION in "${EXTENSIONS[@]}"; do
112120
continue;
113121
fi
114122

115-
EXTENSIONS_TO_INSTALL+=("$EXTENSION")
123+
if [[ "${EXTENSION}" =~ ^pdo_ ]]; then
124+
case "${EXTENSION}" in
125+
"pdo_mysql")
126+
add_extension_to_install "mysql"
127+
;;
128+
"pdo_sqlite")
129+
add_extension_to_install "sqlite3"
130+
;;
131+
"pdo_pgsql")
132+
add_extension_to_install "pgsql"
133+
;;
134+
*)
135+
echo "Unsupported PDO driver extension \"${EXTENSION}\" cannot is not (yet) supported."
136+
echo -n "In case the extension is not available already, please consider using .pre-install.sh to install"
137+
echo " the appropriate extension."
138+
echo -n "If you think its worth to have the PDO driver extension installed automatically, please create"
139+
echo " a feature request on github: https://github.com/laminas/laminas-continuous-integration-action/issues"
140+
continue;
141+
;;
142+
esac
143+
144+
add_extension_to_install "pdo"
145+
continue;
146+
fi
147+
148+
add_extension_to_install "${EXTENSION}"
116149
done
117150

118151
# If by now the extensions list is not empty, install missing extensions.

0 commit comments

Comments
 (0)