Skip to content

Commit c989da5

Browse files
committed
Add scripts for matrix testing
1 parent 10ecea3 commit c989da5

File tree

4 files changed

+173
-0
lines changed

4 files changed

+173
-0
lines changed

.evergreen/config/php.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extension=mongodb.so

.evergreen/install-dependencies.sh

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#!/bin/sh
2+
set -o xtrace # Write all commands first to stderr
3+
set -o errexit # Exit the script with error if any of the commands fail
4+
5+
install_extension ()
6+
{
7+
# Workaround to get PECL running on PHP 7.0
8+
export PHP_PEAR_PHP_BIN=${PHP_PATH}/bin/php
9+
export PHP_PEAR_INSTALL_DIR=${PHP_PATH}/lib/php
10+
11+
rm -f ${PHP_PATH}/lib/php.ini
12+
13+
if [ "x${DRIVER_BRANCH}" != "x" ] || [ "x${DRIVER_REPO}" != "x" ]; then
14+
CLONE_REPO=${DRIVER_REPO:-https://github.com/mongodb/mongo-php-driver}
15+
CHECKOUT_BRANCH=${DRIVER_BRANCH:-master}
16+
17+
echo "Compiling driver branch ${CHECKOUT_BRANCH} from repository ${CLONE_REPO}"
18+
19+
mkdir -p /tmp/compile
20+
rm -rf /tmp/compile/mongo-php-driver
21+
git clone ${CLONE_REPO} /tmp/compile/mongo-php-driver
22+
cd /tmp/compile/mongo-php-driver
23+
24+
git checkout ${CHECKOUT_BRANCH}
25+
git submodule update --init
26+
phpize
27+
./configure --enable-mongodb-developer-flags
28+
make all -j20 > /dev/null
29+
make install
30+
31+
cd ${PROJECT_DIRECTORY}
32+
elif [ "x${DRIVER_VERSION}" != "x" ]; then
33+
echo "Installing driver version ${DRIVER_VERSION} from PECL"
34+
pecl install -f mongodb-${DRIVER_VERSION}
35+
else
36+
echo "Installing latest driver version from PECL"
37+
pecl install -f mongodb
38+
fi
39+
40+
sudo cp ${PROJECT_DIRECTORY}/.evergreen/config/php.ini ${PHP_PATH}/lib/php.ini
41+
}
42+
43+
# Functions to fetch MongoDB binaries
44+
. ${DRIVERS_TOOLS}/.evergreen/download-mongodb.sh
45+
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
46+
47+
get_distro
48+
49+
case "$DISTRO" in
50+
cygwin*)
51+
echo "Install Windows dependencies"
52+
;;
53+
54+
darwin*)
55+
echo "Install macOS dependencies"
56+
;;
57+
58+
linux-rhel*)
59+
echo "Install RHEL dependencies"
60+
;;
61+
62+
linux-ubuntu*)
63+
echo "Install Ubuntu dependencies"
64+
sudo apt-get install -y awscli || true
65+
;;
66+
67+
sunos*)
68+
echo "Install Solaris dependencies"
69+
sudo /opt/csw/bin/pkgutil -y -i sasl_dev || true
70+
;;
71+
72+
*)
73+
echo "All other platforms..."
74+
;;
75+
esac
76+
77+
case "$DEPENDENCIES" in
78+
lowest*)
79+
COMPOSER_FLAGS="${COMPOSER_FLAGS} --prefer-lowest"
80+
;;
81+
82+
*)
83+
;;
84+
esac
85+
86+
PHP_PATH=/opt/php/${PHP_VERSION}-64bit
87+
OLD_PATH=$PATH
88+
PATH=$PHP_PATH/bin:$OLD_PATH
89+
90+
install_extension
91+
92+
php --ri mongodb
93+
94+
# Install composer
95+
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
96+
php composer-setup.php
97+
php -r "unlink('composer-setup.php');"
98+
99+
php composer.phar update $COMPOSER_FLAGS

.evergreen/run-tests.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/sh
2+
set -o xtrace # Write all commands first to stderr
3+
set -o errexit # Exit the script with error if any of the commands fail
4+
5+
# Supported/used environment variables:
6+
# AUTH Set to enable authentication. Defaults to "noauth"
7+
# SSL Set to enable SSL. Defaults to "nossl"
8+
# MONGODB_URI Set the suggested connection MONGODB_URI (including credentials and topology info)
9+
# MARCH Machine Architecture. Defaults to lowercase uname -m
10+
11+
12+
AUTH=${AUTH:-noauth}
13+
SSL=${SSL:-nossl}
14+
MONGODB_URI=${MONGODB_URI:-}
15+
TESTS=${TESTS:-}
16+
PHP_VERSION=${PHP_VERSION:-7.2.21}
17+
18+
# The PLATFORM environment variable is used by the matrix testing project.
19+
# For the time being, we can use that to install the correct extension version
20+
if [ "x${PLATFORM}" != "x" ]; then
21+
DIR=$(dirname $0)
22+
DRIVER_VERSION=1.5.5 . $DIR/install-dependencies.sh
23+
fi
24+
25+
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
26+
[ -z "$MARCH" ] && MARCH=$(uname -m | tr '[:upper:]' '[:lower:]')
27+
28+
echo "Running $AUTH tests over $SSL, connecting to $MONGODB_URI"
29+
30+
OLD_PATH=$PATH
31+
PATH=/opt/php/${PHP_VERSION}-64bit/bin:$OLD_PATH
32+
33+
# Disable failing PHPUnit due to deprecations
34+
export SYMFONY_DEPRECATIONS_HELPER=999999
35+
36+
# Run the tests, and store the results in a Evergreen compatible JSON results file
37+
case "$TESTS" in
38+
*)
39+
php vendor/bin/phpunit --configuration phpunit.evergreen.xml
40+
;;
41+
esac

phpunit.evergreen.xml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<phpunit
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.3/phpunit.xsd"
6+
backupGlobals="false"
7+
backupStaticAttributes="false"
8+
colors="true"
9+
convertErrorsToExceptions="true"
10+
convertNoticesToExceptions="true"
11+
convertWarningsToExceptions="true"
12+
stopOnFailure="false"
13+
syntaxCheck="false"
14+
bootstrap="tests/bootstrap.php"
15+
>
16+
17+
<php>
18+
<ini name="error_reporting" value="-1"/>
19+
<env name="MONGODB_URI" value="mongodb://127.0.0.1:27017/?serverSelectionTimeoutMS=100"/>
20+
<env name="MONGODB_DATABASE" value="phplib_test"/>
21+
</php>
22+
23+
<testsuites>
24+
<testsuite name="Default Test Suite">
25+
<directory>./tests/</directory>
26+
</testsuite>
27+
</testsuites>
28+
29+
<logging>
30+
<log type="junit" target="test-results.xml" />
31+
</logging>
32+
</phpunit>

0 commit comments

Comments
 (0)