Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Splitting Travis instructions into separate bash files. #1035

Merged
merged 17 commits into from
Feb 2, 2017
48 changes: 9 additions & 39 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ matrix:
fast_finish: true

env:
- DEPLOY_SOURCE_BRANCH=8.x
global:
- DEPLOY_SOURCE_BRANCH=8.x
- COMPOSER_BIN=$TRAVIS_BUILD_DIR/vendor/bin
- BLT_DIR=$TRAVIS_BUILD_DIR

cache:
bundler: true
Expand All @@ -22,53 +25,20 @@ cache:
- "$HOME/.nvm"
- "vendor"

notifications:
# slack: acquia:KKfgpOkDhcO26Erv5uoZMfdP

addons:
ssh_known_hosts:
- svn-5223.devcloud.hosting.acquia.com

before_install:
# Decrypt private SSH key id_rsa_blt.enc, save as ~/.ssh/id_rsa_blt.
- if [[ "$TRAVIS_PULL_REQUEST" == "false" ]]; then openssl aes-256-cbc -K $encrypted_c0b166e924da_key -iv $encrypted_c0b166e924da_iv -in id_rsa_blt.enc -out ~/.ssh/id_rsa -d; chmod 600 ~/.ssh/id_rsa; ls -lash ~/.ssh; eval "$(ssh-agent -s)"; ssh-add ~/.ssh/id_rsa; fi
- composer selfupdate
# Disable xdebug.
- phpenv config-rm xdebug.ini
# Enable $_ENV variables in PHP.
- echo 'variables_order = "EGPCS"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
# Ensure that always_populate_raw_post_data PHP setting: Not set to -1 does not happen.
- echo "always_populate_raw_post_data = -1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
# Set PHP memory limit to something more realistic.
- echo "memory_limit=256M" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- git config --global user.name "Travis-CI"
- git config --global user.email "[email protected]"
- mysql -u root -e "CREATE DATABASE drupal; CREATE USER 'drupal'@'localhost' IDENTIFIED BY 'drupal'; GRANT ALL ON drupal.* TO 'drupal'@'localhost';"
- source $BLT_DIR/scripts/travis/before_install

install:
# Load composer dependencies.
- composer validate --no-check-all --ansi
# Remove acquia packages from cache before running `composer install`.
- rm -rf vendor/acquia
- composer install -v
- export PATH=$TRAVIS_BUILD_DIR/vendor/bin:$PATH
# Install proper version of node for front end tasks.
- nvm install 4.4.1
- nvm use 4.4.1
# Initialize xvfb (see https://docs.travis-ci.com/user/gui-and-headless-browsers)
- sudo apt-get install xvfb
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
# Installs chromedriver to vendor/bin.
- ./scripts/linux/install-chrome.sh $TRAVIS_BUILD_DIR/vendor/bin
# Use JDK 8.
- jdk_switcher use oraclejdk8
- source $BLT_DIR/scripts/travis/install

before_script:
# Clear drush release history cache, to pick up new releases.
- rm -f ~/.drush/cache/download/*---updates.drupal.org-release-history-*
# Verify that no git diffs (caused by line ending variation) exist.
- git diff --exit-code
- source $BLT_DIR/scripts/travis/before_script

script:
# Ensure code quality of 'blt' itself.
Expand Down Expand Up @@ -115,11 +85,11 @@ script:
# Deploy build artifact.
- blt deploy:build
# Run 'blt' phpunit tests, excluding deploy-push tests.
- phpunit ../blt/tests/phpunit --group blt --exclude-group deploy-push
- phpunit $BLT_DIR/tests/phpunit --group blt --exclude-group deploy-push

deploy:
- provider: script
script: blt deploy -Ddeploy.commitMsg="Automated commit by Travis CI for Build ${TRAVIS_BUILD_ID}" -Ddeploy.branch="${DEPLOY_SOURCE_BRANCH}-build" && phpunit ../blt/tests/phpunit --group=deploy
script: $BLT_DIR/scripts/travis/deploy_branch && phpunit $BLT_DIR/tests/phpunit --group=deploy
skip_cleanup: true
on:
branch: $DEPLOY_SOURCE_BRANCH
Expand Down
55 changes: 18 additions & 37 deletions scripts/travis/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ php:
matrix:
fast_finish: true

env:
global:
- DEPLOY_SOURCE_BRANCH=8.x
- COMPOSER_BIN=$TRAVIS_BUILD_DIR/vendor/bin
- BLT_DIR=$TRAVIS_BUILD_DIR/vendor/acquia/blt

cache:
bundler: true
apt: true
Expand All @@ -32,57 +38,32 @@ notifications:
# - slack: '<account>:<token>#[channel]'

before_install:
# Enable aliases for non-interactive shell.
- shopt -s expand_aliases
- composer selfupdate
# Disable xdebug.
- phpenv config-rm xdebug.ini
# Enable $_ENV variables in PHP.
- echo 'variables_order = "EGPCS"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
# Ensure that always_populate_raw_post_data PHP setting: Not set to -1 does not happen.
- echo "always_populate_raw_post_data = -1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
# Set PHP memory limit to something more realistic.
- echo "memory_limit=256M" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- git config --global user.name "Travis-CI"
- git config --global user.email "[email protected]"
- mysql -u root -e "CREATE DATABASE drupal; CREATE USER 'drupal'@'localhost' IDENTIFIED BY 'drupal'; GRANT ALL ON drupal.* TO 'drupal'@'localhost';"
- source $BLT_DIR/scripts/travis/before_install

install:
# Load composer dependencies.
- composer validate --no-check-all --ansi
- composer install
- export PATH=$TRAVIS_BUILD_DIR/vendor/bin:$PATH
# Install proper version of node for front end tasks.
- nvm install 4.4.1
- nvm use 4.4.1
# Initialize xvfb (see https://docs.travis-ci.com/user/gui-and-headless-browsers)
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
# Installs chromedriver to vendor/bin.
- ./vendor/acquia/blt/scripts/linux/install-chrome.sh $TRAVIS_BUILD_DIR/vendor/bin
# Use JDK 8.
- jdk_switcher use oraclejdk8
- source $BLT_DIR/scripts/travis/install

before_script:
# Clear drush release history cache, to pick up new releases.
- rm -f ~/.drush/cache/download/*---updates.drupal.org-release-history-*
# Verify that no git diffs (caused by line ending variation) exist.
# - git diff --exit-code
# The local.hostname must be set to 127.0.0.1:8888 because we are using drush runserver to run the site on Travis CI.
- yaml-cli update:value blt/project.yml project.local.hostname '127.0.0.1:8888'
- source $BLT_DIR/scripts/travis/before_script

script:
- blt -Dbehat.run-server=true -Dcreate_alias=false -Dbehat.launch-phantom=true ci:build:validate:test -Dblt.verbose=true
- source $BLT_DIR/scripts/travis/script

deploy:
- provider: script
script: blt deploy -Ddeploy.commitMsg="Automated commit by Travis CI for Build ${TRAVIS_BUILD_ID}" -Ddeploy.branch="${TRAVIS_BRANCH}-build"
script: source $BLT_DIR/scripts/travis/deploy_branch
skip_cleanup: true
on:
branch: develop
php: 5.6
- provider: script
script: source $BLT_DIR/scripts/travis/deploy_branch
skip_cleanup: true
on:
branch: master
php: 5.6
- provider: script
script: blt deploy -Ddeploy.commitMsg="Automated commit by Travis CI for Build ${TRAVIS_TAG}" -Ddeploy.tag="${TRAVIS_TAG}-build" -Ddeploy.branch="${TRAVIS_BRANCH}-build"
script: source $BLT_DIR/scripts/travis/deploy_tag
skip_cleanup: true
on:
tags: true
Expand Down
18 changes: 18 additions & 0 deletions scripts/travis/before_install
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

set -ev

composer selfupdate
# Disable xdebug.
phpenv config-rm xdebug.ini
# Enable $_ENV variables in PHP.
echo 'variables_order = "EGPCS"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
# Ensure that always_populate_raw_post_data PHP setting: Not set to -1 does not happen.
echo "always_populate_raw_post_data = -1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
# Set PHP memory limit to something more realistic.
echo "memory_limit=256M" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
git config --global user.name "Travis-CI"
git config --global user.email "[email protected]"
mysql -u root -e "CREATE DATABASE drupal; CREATE USER 'drupal'@'localhost' IDENTIFIED BY 'drupal'; GRANT ALL ON drupal.* TO 'drupal'@'localhost';"

set +v
10 changes: 10 additions & 0 deletions scripts/travis/before_script
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set -ev

# Clear drush release history cache, to pick up new releases.
rm -f ~/.drush/cache/download/*---updates.drupal.org-release-history-*
# Verify that no git diffs (caused by line ending variation) exist.
# - git diff --exit-code

set +v
7 changes: 7 additions & 0 deletions scripts/travis/deploy_branch
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

set -ev

blt deploy -Ddeploy.commitMsg="Automated commit by Travis CI for Build ${TRAVIS_BUILD_ID}" -Ddeploy.branch="${TRAVIS_BRANCH}-build"

set +v
7 changes: 7 additions & 0 deletions scripts/travis/deploy_tag
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

set -ev

blt deploy -Ddeploy.commitMsg="Automated commit by Travis CI for Build ${TRAVIS_TAG}" -Ddeploy.tag="${TRAVIS_TAG}-build" -Ddeploy.branch="${TRAVIS_BRANCH}-build"

set +v
25 changes: 25 additions & 0 deletions scripts/travis/install
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

set -ev

# Load composer dependencies.
composer validate --no-check-all --ansi
composer install
export PATH=$COMPOSER_BIN:$PATH

# Install proper version of node for front end tasks.
nvm install 4.4.1
nvm use 4.4.1

# Initialize xvfb (see https://docs.travis-ci.com/user/gui-and-headless-browsers)
# sudo apt-get install xvfb
export DISPLAY=:99.0
sh -e /etc/init.d/xvfb start

# Installs chromedriver to vendor/bin.
$BLT_DIR/scripts/linux/install-chrome.sh $COMPOSER_BIN

# Set java version for selenium.
jdk_switcher use oraclejdk8

set +v
9 changes: 9 additions & 0 deletions scripts/travis/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -ev

# The local.hostname must be set to 127.0.0.1:8888 because we are using drush runserver to run the site on Travis CI.
yaml-cli update:value blt/project.yml project.local.hostname '127.0.0.1:8888'
blt -Dbehat.run-server=true -Dcreate_alias=false -Dbehat.launch-phantom=true ci:build:validate:test -Dblt.verbose=true

set +v