Skip to content

Commit 181b3c0

Browse files
committed
PHPLIB-324: Cache extension installation for Travis CI jobs
1 parent 17da06f commit 181b3c0

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

.travis.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ cache:
1111
directories:
1212
- ${HOME}/.cache/pip
1313
- ${HOME}/.composer/cache/files
14+
- ${HOME}/php-ext
1415

1516
env:
1617
global:
@@ -46,11 +47,28 @@ before_install:
4647
- mongod --version
4748
- mongo-orchestration --version
4849
- export MO_PATH=`python -c 'import mongo_orchestration; from os import path; print(path.dirname(mongo_orchestration.__file__));'`
50+
- |
51+
INI=~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
52+
# tpecl is a helper to compile and cache php extensions
53+
tpecl () {
54+
local ext_name=$1
55+
local ext_so=$2
56+
local ext_dir=$(php -r "echo ini_get('extension_dir');")
57+
local ext_cache=~/php-ext/$(basename $ext_dir)/$ext_name
58+
if [[ -e $ext_cache/$ext_so ]]; then
59+
echo extension = $ext_cache/$ext_so >> $INI
60+
else
61+
mkdir -p $ext_cache
62+
echo yes | pecl install -f $ext_name &&
63+
cp $ext_dir/$ext_so $ext_cache
64+
fi
65+
}
66+
export -f tpecl
4967
5068
before_script:
5169
- mongo-orchestration start
5270
- pushd ${MO_PATH} && ${TRAVIS_BUILD_DIR}/.travis/mo.sh configurations/servers/clean.json start && popd
53-
- pecl install -f mongodb-${DRIVER_VERSION}
71+
- tpecl mongodb-${DRIVER_VERSION} mongodb.so
5472
- php --ri mongodb
5573
- composer install --no-interaction --no-progress --no-suggest
5674
- ulimit -c

0 commit comments

Comments
 (0)