Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #128 from pantheon-systems/contenta--take2
Browse files Browse the repository at this point in the history
Contenta (Take2)
  • Loading branch information
stevector authored Jan 29, 2018
2 parents bc5aab5 + ff3c985 commit fd30770
Show file tree
Hide file tree
Showing 48 changed files with 19,197 additions and 238 deletions.
140 changes: 140 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# https://circleci.com/docs/2.0/workflows/#using-workspaces-to-share-data-among-jobs
defaults: &defaults
docker:
- image: quay.io/pantheon-public/build-tools-ci:1.x
working_directory: ~/example_drops_8_composer
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/2.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.
#=========================================================================
TZ: "/usr/share/zoneinfo/America/Los_Angeles"

# The variables below usually do not need to be modified.

#======================================================================================================================================
# Circle CI 2.0 does not yet expand environment variables so they have to be manually EXPORTed
# Once environment variables can be expanded the variables below can be uncommented and the EXPORTs in set-up-globals.sh can be removed
# See: https://discuss.circleci.com/t/unclear-how-to-work-with-user-variables-circleci-provided-env-variables/12810/11
# See: https://discuss.circleci.com/t/environment-variable-expansion-in-working-directory/11322
# See: https://discuss.circleci.com/t/circle-2-0-global-environment-variables/8681
#======================================================================================================================================

NOTIFY: 'scripts/github/add-commit-comment {project} {sha} "Created multidev environment [{site}#{env}]({dashboard-url})." {site-url}'
ADMIN_USERNAME: admin
# BUILD_TOOLS_VERSION: ^2.0.0-alpha4
TERM: dumb

version: 2
jobs:
# @todo: common initialization: 'composer install' for the site-under-test
build:
<<: *defaults
steps:
- checkout

- restore_cache:
keys:
- composer-cache
- terminus-install

- run:
# Set TERMINUS_ENV and related environment variables.
# https://github.com/pantheon-systems/docker-build-tools-ci/blob/1.x/scripts/set-environment
name: environment
command: /build-tools-ci/scripts/set-environment

- run:
name: run composer install to get the vendor directory
command: composer install

- save_cache:
key: composer-cache
paths:
- $HOME/.composer/cache

- save_cache:
key: terminus-install
paths:
- $(TERMINUS_PLUGINS_DIR:-~/.terminus/plugins)

- run:
name: lint php code for syntax errors
command: composer -n lint

- run:
name: check coding standards
command: composer -n code-sniff

- run:
name: run unit tests
command: composer -n unit-test

build_deploy_and_test:
<<: *defaults
steps:
- checkout

- restore_cache:
keys:
- composer-cache
- terminus-install

- run:
# Set TERMINUS_ENV and related environment variables.
# https://github.com/pantheon-systems/docker-build-tools-ci/blob/1.x/scripts/set-environment
name: dependencies
command: /build-tools-ci/scripts/set-environment

- run:
name: install dev dependencies, build assets, etc.
command: ./.circleci/scripts/pantheon/01-prepare

- run:
name: build assets
command: composer -n build-assets

- run:
name: prepare database for site-under test
command: ./.circleci/scripts/pantheon/02-init-site-under-test-clone-existing
# command: ./.circleci/scripts/pantheon/02-init-site-under-test-reinstall-new

- run:
name: run functional tests with Behat
command: ./tests/scripts/run-behat

- run:
name: post-test actions
command: ./.circleci/scripts/pantheon/03-post-test

- run:
name: handle merge to master (if needed)
command: ./.circleci/scripts/pantheon/04-merge-master

- run:
name: remove transient test fixtures
command: ./.circleci/scripts/pantheon/09-cleanup-fixtures

# TODO:
# 04-merge-master
# 09-cleanup-fixtures

workflows:
version: 2
build_and_test:
jobs:
# Install dev dependencies and do simple tests (sniff, unit tests, etc.)
- build
# Build deploy and test on target platform
- build_deploy_and_test
18 changes: 18 additions & 0 deletions .circleci/scripts/pantheon/01-prepare
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

set -eo pipefail

#
# This script starts up the test process.
#
# - Environment settings (e.g. git config) are initialized
# - Terminus plugins are installed
# - Any needed code updates are done
#
echo "Begin build for $DEFAULT_ENV. Pantheon test environment is $TERMINUS_SITE.$TERMINUS_ENV"

# Log in via Terminus
terminus -n auth:login --machine-token="$TERMINUS_TOKEN"

# Delete leftover CI environments
terminus -n build:env:delete:ci "$TERMINUS_SITE" --keep=2 --yes
22 changes: 22 additions & 0 deletions .circleci/scripts/pantheon/02-init-site-under-test-clone-existing
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -eo pipefail

#
# This script prepares the site-under-test by cloning the database from
# an existing site.
#
# Use EITHER this script OR the re-install-new script; do not run both.
#

# Create a new multidev site to test on
terminus -n env:wake "$TERMINUS_SITE.dev"
terminus -n build:env:create "$TERMINUS_SITE.dev" "$TERMINUS_ENV" --yes --clone-content --notify="$NOTIFY"

# Run updatedb to ensure that the cloned database is updated for the new code.
terminus -n drush "$TERMINUS_SITE.$TERMINUS_ENV" -- updatedb -y

# If exported configuration is available, then import it.
if [ -f "config/system.site.yml" ] ; then
terminus -n drush "$TERMINUS_SITE.$TERMINUS_ENV" -- config-import --yes
fi
15 changes: 15 additions & 0 deletions .circleci/scripts/pantheon/02-init-site-under-test-reinstall-new
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -eo pipefail

#
# This script prepares the site-under-test by re-installing a new site.
#
# Use EITHER this script OR the clone-existing script; do not run both.
#

# Create a new multidev site to test on
terminus -n build:env:create "$TERMINUS_SITE.dev" "$TERMINUS_ENV" --yes --notify="$NOTIFY"

# Re-run the site installation process
terminus -n build:env:install "$TERMINUS_SITE.$TERMINUS_ENV" --site-name="$TEST_SITE_NAME" --account-mail="$ADMIN_EMAIL" --account-pass="$ADMIN_PASSWORD"
9 changes: 9 additions & 0 deletions .circleci/scripts/pantheon/03-post-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

set -eo pipefail

#
# This script runs any post-test operations that may be needed.
#

terminus -n secrets:set "$TERMINUS_SITE.$TERMINUS_ENV" token "$GITHUB_TOKEN" --file='github-secrets.json' --clear --skip-if-empty
26 changes: 26 additions & 0 deletions .circleci/scripts/pantheon/04-merge-master
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

set -eo pipefail

#
# This script handles all operations that must be done when a
# pull request is merged back into the master branch.
#
if [[ $CIRCLE_BRANCH != "master" ]] ; then
exit 0
fi

# Merge the multidev for the PR into the dev environment
terminus -n build:env:merge "$TERMINUS_SITE.$TERMINUS_ENV" --yes

# Run updatedb on the dev environment
terminus -n drush $TERMINUS_SITE.dev -- updatedb --yes

# If there are any exported configuration files, then import them
if [ -f "config/system.site.yml" ] ; then
terminus -n drush "$TERMINUS_SITE.dev" -- config-import --yes
fi

# Delete old multidev environments associated with a PR that has been
# merged or closed.
terminus -n build:env:delete:pr "$TERMINUS_SITE" --yes
12 changes: 12 additions & 0 deletions .circleci/scripts/pantheon/09-cleanup-fixtures
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -eo pipefail

#
# This script deletes any fixtures that are no longer needed.
#
# Note that we allow the "ci-BUILD_NUMBER" and "pr-PULL_REQUEST_NUMBER"
# multidev sites to persist until the next time the 'prepare' or
# 'merge-master' scripts (respectively) are called.
#

8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ web/autoload.php
web/index.php
web/robots.txt
web/sites/default/default.services.pantheon.preproduction.yml
web/sites/default/default.services.yml
web/sites/default/default.settings.php
web/sites/default/settings.pantheon.php
web/sites/development.services.yml
Expand Down Expand Up @@ -50,16 +49,14 @@ web/web.config
### to the Pantheon repository.
###

# Ignore Drupal's file directory
/web/sites/*/files/

# Ignore Drupal's file directory
web/sites/default/files

# Pantheon commits a settings.php for environment-specific settings.
# Place local settings in settings.local.php
web/sites/*/settings.local.php
web/sites/*/services*.yml
!web/sites/*/services.pantheon.*.yml

# Ignore SimpleTest multi-site environment.
web/sites/simpletest
Expand Down Expand Up @@ -104,3 +101,6 @@ Thumbs.db

# Things in the core directory that Drupal 8 commits in the repository.
!web/core/**/*.gz

# Don't commit keys generated by contenta install
/keys/
78 changes: 0 additions & 78 deletions .gitlab-ci.yml

This file was deleted.

Loading

1 comment on commit fd30770

@pantheon-upstream
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created multidev environment ci-example-d8-composer#pr-93.

Visit Site

Please sign in to comment.