Skip to content

Commit cbe4898

Browse files
committed
Set PHP patch version automatically
1 parent 199cd73 commit cbe4898

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

.evergreen/install-dependencies.sh

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,36 @@
11
#!/bin/sh
22
set -o errexit # Exit the script with error if any of the commands fail
33

4+
set_php_version ()
5+
{
6+
PHP_VERSION=$1
7+
8+
if [ ! -d "/opt/php" ]; then
9+
echo "PHP is not available"
10+
exit 1
11+
fi
12+
13+
if [ -d "/opt/php/${PHP_VERSION}-64bit/bin" ]; then
14+
export PHP_PATH="/opt/php/${PHP_VERSION}-64bit/bin"
15+
else
16+
# Try to find the newest version matching our constant
17+
export PHP_PATH=`find /opt/php/ -maxdepth 1 -type d -name "${PHP_VERSION}.*-64bit" -print | sort -V -r | head -1`
18+
fi
19+
20+
if [ ! -d "$PHP_PATH" ]; then
21+
echo "Could not find PHP binaries for version ${PHP_VERSION}. Listing available versions..."
22+
ls -1 /opt/php
23+
exit 1
24+
fi
25+
26+
export PATH=$PHP_PATH/bin:$PATH
27+
}
28+
429
install_extension ()
530
{
631
# Workaround to get PECL running on PHP 7.0
732
export PHP_PEAR_PHP_BIN=${PHP_PATH}/bin/php
8-
export PHP_PEAR_INSTALL_DIR=${PHP_PATH}/lib/php
33+
export PHP_PEAR_INSTALL_DIR=${PHP_PATH}/bin/php
934

1035
rm -f ${PHP_PATH}/lib/php.ini
1136

@@ -100,10 +125,7 @@ case "$DEPENDENCIES" in
100125
;;
101126
esac
102127

103-
PHP_PATH=/opt/php/${PHP_VERSION}-64bit
104-
OLD_PATH=$PATH
105-
PATH=$PHP_PATH/bin:$OLD_PATH
106-
128+
set_php_version $PHP_VERSION
107129
install_extension
108130
install_composer
109131

.evergreen/run-tests.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ OS=$(uname -s | tr '[:upper:]' '[:lower:]')
3737

3838
echo "Running tests with $AUTH and $SSL, connecting to: $MONGODB_URI"
3939

40-
OLD_PATH=$PATH
41-
PATH=/opt/php/${PHP_VERSION}-64bit/bin:$OLD_PATH
42-
4340
# Disable failing PHPUnit due to deprecations
4441
export SYMFONY_DEPRECATIONS_HELPER=999999
4542

0 commit comments

Comments
 (0)