This repository has been archived by the owner on Aug 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #128 from pantheon-systems/contenta--take2
Contenta (Take2)
- Loading branch information
Showing
48 changed files
with
19,197 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
22
.circleci/scripts/pantheon/02-init-site-under-test-clone-existing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
15
.circleci/scripts/pantheon/02-init-site-under-test-reinstall-new
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
fd30770
There was a problem hiding this comment.
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.