|
| 1 | +# https://circleci.com/docs/configuration#machine |
| 2 | +machine: |
| 3 | + timezone: |
| 4 | + America/Chicago |
| 5 | + php: |
| 6 | + # https://circleci.com/docs/build-image-trusty/#php |
| 7 | + version: 7.1.0 |
| 8 | + environment: |
| 9 | + # In addition to the environment variables defined in this file, also |
| 10 | + # add the following variables in the Circle CI UI. |
| 11 | + # |
| 12 | + # See: https://circleci.com/docs/1.0/environment-variables/ |
| 13 | + # |
| 14 | + # TERMINUS_SITE: Name of the Pantheon site to run tests on, e.g. my_site |
| 15 | + # TERMINUS_TOKEN: The Pantheon machine token |
| 16 | + # GITHUB_TOKEN: The GitHub personal access token |
| 17 | + # GIT_EMAIL: The email address to use when making commits |
| 18 | + # |
| 19 | + # TEST_SITE_NAME: The name of the test site to provide when installing. |
| 20 | + # ADMIN_PASSWORD: The admin password to use when installing. |
| 21 | + # ADMIN_EMAIL: The email address to give the admin when installing. |
| 22 | + # |
| 23 | + # The variables below usually do not need to be modified. |
| 24 | + BRANCH: $(echo $CIRCLE_BRANCH | grep -v '^\(master\|[0-9]\+.x\)$') |
| 25 | + PR_ENV: ${BRANCH:+pr-$BRANCH} |
| 26 | + CIRCLE_ENV: ci-$CIRCLE_BUILD_NUM |
| 27 | + DEFAULT_ENV: $(echo ${PR_ENV:-$CIRCLE_ENV} | tr '[:upper:]' '[:lower:]' | sed 's/[^0-9a-z-]//g' | cut -c -11 | sed 's/-$//') |
| 28 | + TERMINUS_ENV: ${TERMINUS_ENV:-$DEFAULT_ENV} |
| 29 | + NOTIFY: 'scripts/github/add-commit-comment {project} {sha} "Created multidev environment [{site}#{env}]({dashboard-url})." {site-url}' |
| 30 | + PATH: $PATH:~/bin:tests/scripts |
| 31 | + WORDPRESS_ADMIN_USERNAME: admin |
| 32 | + # There is a mismatch in variable names used by |
| 33 | + # the terminus build plugin and the Behat tests. |
| 34 | + # So the variable ADMIN_PASSWORD needs to be |
| 35 | + # reassigned to WORDPRESS_ADMIN_PASSWORD. |
| 36 | + # And because CircleCI does not allow for simple |
| 37 | + # setting of a private variable to a public |
| 38 | + # variable, this workaround of writing to a file is |
| 39 | + # used. |
| 40 | + WORDPRESS_ADMIN_PASSWORD: $(cat ~/WORDPRESS_ADMIN_PASSWORD) |
| 41 | + |
| 42 | +dependencies: |
| 43 | + cache_directories: |
| 44 | + - ~/.composer/cache |
| 45 | + pre: |
| 46 | + - echo "Begin build for $CIRCLE_ENV${PR_ENV:+ for }$PR_ENV. Pantheon test environment is $TERMINUS_SITE.$TERMINUS_ENV" |
| 47 | + - | |
| 48 | + if [ -n "$GITHUB_TOKEN" ] ; then |
| 49 | + composer config --global github-oauth.github.com $GITHUB_TOKEN |
| 50 | + fi |
| 51 | + - git config --global user.email "$GIT_EMAIL" |
| 52 | + - git config --global user.name "Circle CI" |
| 53 | + override: |
| 54 | + - echo $ADMIN_PASSWORD > ~/WORDPRESS_ADMIN_PASSWORD |
| 55 | + - composer global require -n "hirak/prestissimo:^0.3" |
| 56 | + - composer global require -n "consolidation/cgr" |
| 57 | + - cgr "pantheon-systems/terminus:^1" |
| 58 | + - terminus --version |
| 59 | + - mkdir -p ~/.terminus/plugins |
| 60 | + - composer create-project -n -d ~/.terminus/plugins pantheon-systems/terminus-build-tools-plugin:^1 |
| 61 | + - composer create-project -n -d ~/.terminus/plugins pantheon-systems/terminus-secrets-plugin:^1 |
| 62 | + post: |
| 63 | + - terminus auth:login -n --machine-token="$TERMINUS_TOKEN" |
| 64 | + - terminus build:env:delete:ci -n "$TERMINUS_SITE" --keep=2 --yes |
| 65 | + - composer -n build-assets |
| 66 | + - terminus env:wake -n "$TERMINUS_SITE.dev" |
| 67 | + - terminus build:env:create -n "$TERMINUS_SITE.dev" "$TERMINUS_ENV" --yes --notify="$NOTIFY" |
| 68 | + # This line will re-copy the database to the multidev environment to account |
| 69 | + # for multiple CI builds running on the same multidev. |
| 70 | + - terminus env:clone-content "$TERMINUS_SITE.dev" "$TERMINUS_ENV" --yes |
| 71 | + |
| 72 | +test: |
| 73 | + override: |
| 74 | + - run-behat |
| 75 | + post: |
| 76 | + - terminus secrets:set -n "$TERMINUS_SITE.$TERMINUS_ENV" token "$GITHUB_TOKEN" --file='github-secrets.json' --clear --skip-if-empty |
| 77 | + |
| 78 | +deployment: |
| 79 | + build-assets: |
| 80 | + branch: master |
| 81 | + commands: |
| 82 | + - terminus build-env:merge -n "$TERMINUS_SITE.$TERMINUS_ENV" --yes |
| 83 | + - terminus build-env:delete:pr -n "$TERMINUS_SITE" --yes |
0 commit comments