Skip to content

PHPLIB-617 Continuous Matrix Testing for 4.0 era drivers #810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Feb 19, 2021
1 change: 1 addition & 0 deletions .evergreen/config/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extension=mongodb.so
99 changes: 99 additions & 0 deletions .evergreen/install-dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/bin/sh
set -o xtrace # Write all commands first to stderr
set -o errexit # Exit the script with error if any of the commands fail

install_extension ()
{
# Workaround to get PECL running on PHP 7.0
export PHP_PEAR_PHP_BIN=${PHP_PATH}/bin/php
export PHP_PEAR_INSTALL_DIR=${PHP_PATH}/lib/php

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

if [ "x${DRIVER_BRANCH}" != "x" ] || [ "x${DRIVER_REPO}" != "x" ]; then
CLONE_REPO=${DRIVER_REPO:-https://github.com/mongodb/mongo-php-driver}
CHECKOUT_BRANCH=${DRIVER_BRANCH:-master}

echo "Compiling driver branch ${CHECKOUT_BRANCH} from repository ${CLONE_REPO}"

mkdir -p /tmp/compile
rm -rf /tmp/compile/mongo-php-driver
git clone ${CLONE_REPO} /tmp/compile/mongo-php-driver
cd /tmp/compile/mongo-php-driver

git checkout ${CHECKOUT_BRANCH}
git submodule update --init
phpize
./configure --enable-mongodb-developer-flags
make all -j20 > /dev/null
make install

cd ${PROJECT_DIRECTORY}
elif [ "x${DRIVER_VERSION}" != "x" ]; then
echo "Installing driver version ${DRIVER_VERSION} from PECL"
pecl install -f mongodb-${DRIVER_VERSION}
else
echo "Installing latest driver version from PECL"
pecl install -f mongodb
fi

sudo cp ${PROJECT_DIRECTORY}/.evergreen/config/php.ini ${PHP_PATH}/lib/php.ini
}

# Functions to fetch MongoDB binaries
. ${DRIVERS_TOOLS}/.evergreen/download-mongodb.sh
OS=$(uname -s | tr '[:upper:]' '[:lower:]')

get_distro

case "$DISTRO" in
cygwin*)
echo "Install Windows dependencies"
;;

darwin*)
echo "Install macOS dependencies"
;;

linux-rhel*)
echo "Install RHEL dependencies"
;;

linux-ubuntu*)
echo "Install Ubuntu dependencies"
sudo apt-get install -y awscli || true
;;

sunos*)
echo "Install Solaris dependencies"
sudo /opt/csw/bin/pkgutil -y -i sasl_dev || true
;;

*)
echo "All other platforms..."
;;
esac

case "$DEPENDENCIES" in
lowest*)
COMPOSER_FLAGS="${COMPOSER_FLAGS} --prefer-lowest"
;;

*)
;;
esac

PHP_PATH=/opt/php/${PHP_VERSION}-64bit
OLD_PATH=$PATH
PATH=$PHP_PATH/bin:$OLD_PATH

install_extension

php --ri mongodb

# Install composer
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
php -r "unlink('composer-setup.php');"

php composer.phar update $COMPOSER_FLAGS
41 changes: 41 additions & 0 deletions .evergreen/run-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/sh
set -o xtrace # Write all commands first to stderr
set -o errexit # Exit the script with error if any of the commands fail

# Supported/used environment variables:
# AUTH Set to enable authentication. Defaults to "noauth"
# SSL Set to enable SSL. Defaults to "nossl"
# MONGODB_URI Set the suggested connection MONGODB_URI (including credentials and topology info)
# MARCH Machine Architecture. Defaults to lowercase uname -m


AUTH=${AUTH:-noauth}
SSL=${SSL:-nossl}
MONGODB_URI=${MONGODB_URI:-}
TESTS=${TESTS:-}
PHP_VERSION=${PHP_VERSION:-7.2.21}

# The PLATFORM environment variable is used by the matrix testing project.
# For the time being, we can use that to install the correct extension version
if [ "x${PLATFORM}" != "x" ]; then
DIR=$(dirname $0)
DRIVER_VERSION=1.5.5 . $DIR/install-dependencies.sh
fi

OS=$(uname -s | tr '[:upper:]' '[:lower:]')
[ -z "$MARCH" ] && MARCH=$(uname -m | tr '[:upper:]' '[:lower:]')

echo "Running $AUTH tests over $SSL, connecting to $MONGODB_URI"

OLD_PATH=$PATH
PATH=/opt/php/${PHP_VERSION}-64bit/bin:$OLD_PATH

# Disable failing PHPUnit due to deprecations
export SYMFONY_DEPRECATIONS_HELPER=999999

# Run the tests, and store the results in a Evergreen compatible JSON results file
case "$TESTS" in
*)
php vendor/bin/phpunit --configuration phpunit.evergreen.xml
;;
esac
32 changes: 32 additions & 0 deletions phpunit.evergreen.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.3/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="tests/bootstrap.php"
>

<php>
<ini name="error_reporting" value="-1"/>
<env name="MONGODB_URI" value="mongodb://127.0.0.1:27017/?serverSelectionTimeoutMS=100"/>
<env name="MONGODB_DATABASE" value="phplib_test"/>
</php>

<testsuites>
<testsuite name="Default Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>

<logging>
<log type="junit" target="test-results.xml" />
</logging>
</phpunit>