Reputation: 203
For some reason when I use an if
statement it will not execute the configure for it. Here is my full travis.yml
below.
travis.yml:
language: php
php:
- '5.6.32'
- '7.0.26'
- '7.1.12'
- '7.2.0'
os:
- windows
- linux
git:
depth: 1
matrix:
fast_finish: true
sudo: false
before_install:
- if [[ ${TRAVIS_PHP_VERSION:0:3} == "7.2.0" ]]; then git clone -b stable https://github.com/jedisct1/libsodium.git; fi
- if [[ ${TRAVIS_PHP_VERSION:0:3} == "7.2.0" ]]; then cd libsodium && sudo ./configure && sudo make check && sudo make install && cd ..; fi
install:
- if [[ ${TRAVIS_PHP_VERSION:0:3} == "7.2.0" ]]; then pecl install libsodium; fi
- if [[ ${TRAVIS_PHP_VERSION:0:3} == "7.2.0" ]]; then echo "extension=sodium.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi
- travis_retry composer install --no-interaction
- wget -c -nc --retry-connrefused --tries=0 https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar
- chmod +x coveralls.phar
- php coveralls.phar --version
before_script:
- mkdir -p build/logs
- ls -al
script:
- ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml
after_success:
- travis_retry php coveralls.phar -v
branches:
only: master
cache:
directories:
- vendor
- $HOME/.cache/composer
So for some reason
- if [[ ${TRAVIS_PHP_VERSION:0:3} == "7.2.0" ]]; then
export git clone -b stable https://github.com/jedisct1/libsodium.git;
fi
does not work and I got this solution from this
My goal is to execute certain lines on certain PHP version.
Is there anything I missed?
Upvotes: 1
Views: 1204
Reputation: 2576
EDIT:
you extracted the first 3 characters of the TRAVIS_PHP_VERSION
and compared it with 5 characters.. of course that doesn't work. you can either try:
if [[ ${TRAVIS_PHP_VERSION:0:5} == "7.2.0" ]]
or
if [[ ${TRAVIS_PHP_VERSION:0:3} == "7.2" ]]
END EDIT
I had some problems running scripts inside the Travis config file, since i wanted blank lines and comments and Travis got confused with that. So in general i would recommend to do the scripting in a separate bash file.
The easiest way is to do all the bash scripting in a script file and use the script files in your travis.yml
before_install: ./travis-scripts/before_install.sh
Now you can write your scripts with the bash syntax and they work right away.
If you still want to write the scripts inside the travis file, try that (not everything worked for me everytime):
install: >
if [[ ${TRAVIS_PHP_VERSION:0:3} == "7.2" ]]; then pecl install libsodium; fi;
if [[ ${TRAVIS_PHP_VERSION:0:3} == "7.2" ]]; then echo "extension=sodium.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;
travis_retry composer install --no-interaction;
wget -c -nc --retry-connrefused --tries=0 https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar;
chmod +x coveralls.phar;
php coveralls.phar --version;
Or leave it as it is and only put the if statements in quotes.
Upvotes: 4