Skip to content

Instantly share code, notes, and snippets.

@cdnsteve
Forked from iamEAP/.travis.yml
Created February 7, 2014 02:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdnsteve/8856419 to your computer and use it in GitHub Desktop.
Save cdnsteve/8856419 to your computer and use it in GitHub Desktop.
language: php
#
# Important to note, this is the version of PHP used to run this build, not the
# one used to run your Drupal installation. Ensure compatibility with the Drush
# and Terminus versions you're using for this build.
#
php:
- 5.3
#
# Travis/Pantheon integration requires an RSA key that at least has read access
# to your GitHub repo and write access to Pantheon's git repo. Create a user on
# both systems with the most restricted access, given the aforementioned
# constraints. Then, for the given user, generate and load a public key to both
# GitHub/Pantheon. Follow instructions from Travis-CI on using this new key.
#
# Keep the Pantheon account e-mail address and password handy, you'll need it
# below in env.global.
#
# http://docs.travis-ci.com/user/travis-pro/
# https://help.github.com/articles/generating-ssh-keys
#
source_key: INSERT_KEY_HERE
env:
global:
# Your Pantheon site's UUID (e.g. from your dashboard URL)
- PUUID='aaaaaaaa-0000-bbbb-1111-cccccccccccc'
# Your Pantheon site's name.
- PNAME='site-name'
# The Pantheon environment name from which Multidev DB/files will be pulled.
# Probably one of: dev, test, live.
- PSOURCE='test'
#
# PEMAIL environment variable: represents the Pantheon account e-mail with
# access to this site. Used to authenticate to Pantheon via Terminus. You
# must cd to your project root and run:
#
# travis encrypt PEMAIL='test@example.com' --add env.global
#
# Which will eventually look something like the key below.
# See: http://docs.travis-ci.com/user/build-configuration/#Secure-environment-variables
#
- secure: "encrypted_email_value_here"
#
# PPASS environment variable: represents the Pantheon account password for
# the above encrypted e-mail address. Run:
#
# travis encrypt PPASS='my_account_password' --add env.global
#
- secure: "encrypted_password_value_here"
# Generate a random branch / multidev name, prefixed with "ci-"
- PSITE=$(cat /dev/urandom | tr -cd 'a-z' | head -c 8)
- PSITE="ci-$PSITE"
# You can use $PHOST as a reference to the resulting multidev hostname.
- PHOST="https://$PSITE-$PNAME.gotpantheon.com"
install:
# Dynamic hosts through Pantheon mean constantly checking interactively
# that we mean to connect to an unknown host. We ignore those here.
- echo "StrictHostKeyChecking no" > ~/.ssh/config
# Install Drush.
- pear channel-discover pear.drush.org
- pear install drush/drush-6.2.0.0
- phpenv rehash
# Install Terminus.
- git clone https://github.com/pantheon-systems/terminus.git $HOME/.drush/terminus
- cd $HOME/.drush/terminus
- composer update --no-dev
- drush cc drush
# Install additional test dependencies here (like Casper, Behat, etc).
before_script:
# Authenticate with Pantheon via Terminus.
- drush pauth $PEMAIL --password=$PPASS
# Create a new Git branch on Pantheon using our random ci-name.
- drush psite-bcreate $PUUID --name=$PSITE
# Add Pantheon as a remote to our repo and force push to it.
- cd $TRAVIS_BUILD_DIR
- git checkout -b $PSITE
- git remote add pantheon ssh://codeserver.dev.$PUUID@codeserver.dev.$PUUID.drush.in:2222/~/repository.git
- git push --force pantheon $PSITE
# Create a new Pantheon environment using the above branch.
- drush psite-ecreate $PUUID $PSITE --source=$PSOURCE
# Update our drush aliases file.
- drush paliases
- drush cc drush
# We cannot be in a Drupal directory to run aliased drush commands.
- cd $HOME
# Run all available updates as if deploying. For now, append the
# --strict=0 option for Drush 6.x compatibility on Pantheon.
- drush @pantheon.$PNAME.$PSITE updb -y --strict=0
# Enable additional test dependencies here, like SimpleTest.
- drush @pantheon.$PNAME.$PSITE en simpletest -y --strict=0
script:
#
# This is where you run your tests, be they SimpleTest, Casper, Behat,
# or otherwise. Here's a SimpleTest example. I've found that drush
# likes to exit with odd codes if you run multiple classes at once.
# You may have to run one class at a time.
#
- drush @pantheon.$PNAME.$PSITE test-run MyTestClass --strict=0
- drush @pantheon.$PNAME.$PSITE test-run MyTestClass2 --strict=0
after_script:
# Destroy the Pantheon environment
- drush psite-edelete $PUUID $PSITE -y
# Delete the git branch we created.
- drush psite-bdel $PUUID --name=$PSITE -y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment