-
Notifications
You must be signed in to change notification settings - Fork 1
/
circle.yml
98 lines (96 loc) · 4.89 KB
/
circle.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# https://circleci.com/docs/configuration#machine
machine:
timezone:
America/Chicago
php:
# https://circleci.com/docs/build-image-trusty/#php
version: 7.0.11
environment:
# In addition to the environment variables defined in this file, also
# add the following variables in the Circle CI UI.
#
# See: https://circleci.com/docs/1.0/environment-variables/
#
# TERMINUS_SITE: Name of the Pantheon site to run tests on, e.g. my_site
# TERMINUS_TOKEN: The Pantheon machine token
# GITHUB_TOKEN: The GitHub personal access token
# GIT_EMAIL: The email address to use when making commits
#
# TEST_SITE_NAME: The name of the test site to provide when installing.
# ADMIN_PASSWORD: The admin password to use when installing.
# ADMIN_EMAIL: The email address to give the admin when installing.
#
# CLONE_CONTENT: If defined, tests will use content cloned from the dev
# environment. Otherwise, the site will be re-installed
# for every test.
#
# The variables below usually do not need to be modified.
BRANCH: $(echo $CIRCLE_BRANCH | grep -v '^\(master\|[0-9]\+.x\)$')
PR_ENV: ${BRANCH:+pr-$BRANCH}
CIRCLE_ENV: ci-$CIRCLE_BUILD_NUM
DEFAULT_ENV: $(echo ${PR_ENV:-$CIRCLE_ENV} | cut -c -11 | sed 's/_/-/g' | sed 's/-$//')
TERMINUS_ENV: ${TERMINUS_ENV:-$DEFAULT_ENV}
CLONE_CONTENT_FLAG: ${CLONE_CONTENT:+--clone-content --db-only}
NOTIFY: 'scripts/github/add-commit-comment {project} {sha} "Created multidev environment [{site}#{env}]({dashboard-url})." {site-url}'
PATH: $PATH:~/.composer/vendor/bin:~/.config/composer/vendor/bin:tests/scripts
dependencies:
cache_directories:
- ~/.composer/cache
pre:
- echo "Begin build for $CIRCLE_ENV${PR_ENV:+ for }$PR_ENV. Pantheon test environment is $TERMINUS_SITE.$TERMINUS_ENV"
- php -f scripts/slack/slack_notify.php circle_start "${CIRCLE_BUILD_NUM}" "${TERMINUS_SITE}.${TERMINUS_ENV}"
- |
if [ -n "$GITHUB_TOKEN" ] ; then
composer config --global github-oauth.github.com $GITHUB_TOKEN
fi
- git config --global user.email "$GIT_EMAIL"
- git config --global user.name "Circle CI"
override:
- |
cd web/themes/custom/badcamp2017/
npm install -g gulp
npm install
- composer global require "pantheon-systems/terminus:^1"
- composer global require "drush/drush:~8"
- mkdir -p ~/.terminus/plugins
- mkdir -p ~/.drush
- composer create-project -n -d ~/.terminus/plugins pantheon-systems/terminus-build-tools-plugin:^1
- composer create-project -n -d ~/.terminus/plugins pantheon-systems/terminus-secrets-plugin:^1
post:
- terminus auth:login -n --machine-token="$TERMINUS_TOKEN"
- php -f scripts/slack/slack_notify.php pantheon_create "${TERMINUS_ENV}" "${BRANCH}"
- terminus build-env:delete:ci -n "$TERMINUS_SITE" --keep=2 --yes
- composer -n build-assets
- terminus env:wake -n "$TERMINUS_SITE.dev"
- terminus build-env:create -n "$TERMINUS_SITE.dev" "$TERMINUS_ENV" --yes $CLONE_CONTENT_FLAG --notify="$NOTIFY"
# Above command does not update with live environment data. Dev isn't always updated with live data.
- terminus env:clone-content "$TERMINUS_SITE.live" "$TERMINUS_ENV" --yes
- terminus drush "$TERMINUS_SITE.$TERMINUS_ENV" -- cr
- |
if [ -n "$CLONE_CONTENT" ] ; then
# Re-import configuration if exported configuration exists in config directory.
terminus drush "$TERMINUS_SITE.$TERMINUS_ENV" -- config-import --yes
elif [ ! -f "config/system.site.yml" ] ; then
# Install with the standard profile, and enable config_direct_save
terminus drush "$TERMINUS_SITE.$TERMINUS_ENV" -- site-install standard --yes --site-name="$TEST_SITE_NAME" --account-mail="$ADMIN_EMAIL" --account-pass="$ADMIN_PASSWORD"
terminus drush -n "$TERMINUS_SITE.$TERMINUS_ENV" -- pm-enable --yes config_direct_save
else
# Re-install with the config_installer to re-import configuration
chmod +w web/sites/default web/sites/default/settings.php
terminus drush "$TERMINUS_SITE.$TERMINUS_ENV" -- site-install config_installer --yes --site-name="$TEST_SITE_NAME" --account-mail="$ADMIN_EMAIL" --account-pass="$ADMIN_PASSWORD"
fi
- terminus drush "$TERMINUS_SITE.$TERMINUS_ENV" -- cr
test:
override:
- run-behat
post:
- terminus secrets:set -n "$TERMINUS_SITE.$TERMINUS_ENV" token "$GITHUB_TOKEN" --file='github-secrets.json' --clear --skip-if-empty
deployment:
build-assets:
branch: master
commands:
- php -f scripts/slack/slack_notify.php pantheon_merge "${TERMINUS_ENV}" "${BRANCH}"
- terminus build-env:merge -n "$TERMINUS_SITE.$TERMINUS_ENV" --yes
- terminus drush -n $TERMINUS_SITE.$TERMINUS_ENV -- updatedb --yes
- terminus drush "$TERMINUS_SITE.$TERMINUS_ENV" -- config-import --yes
- terminus build-env:delete:pr -n "$TERMINUS_SITE" --yes