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

Commit fd30770

Browse files
authored
Merge pull request #128 from pantheon-systems/contenta--take2
Contenta (Take2)
2 parents bc5aab5 + ff3c985 commit fd30770

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+19197
-238
lines changed

.circleci/config.yml

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# https://circleci.com/docs/2.0/workflows/#using-workspaces-to-share-data-among-jobs
2+
defaults: &defaults
3+
docker:
4+
- image: quay.io/pantheon-public/build-tools-ci:1.x
5+
working_directory: ~/example_drops_8_composer
6+
environment:
7+
#=========================================================================
8+
# In addition to the environment variables defined in this file, also
9+
# add the following variables in the Circle CI UI.
10+
#
11+
# See: https://circleci.com/docs/2.0/environment-variables/
12+
#
13+
# TERMINUS_SITE: Name of the Pantheon site to run tests on, e.g. my_site
14+
# TERMINUS_TOKEN: The Pantheon machine token
15+
# GITHUB_TOKEN: The GitHub personal access token
16+
# GIT_EMAIL: The email address to use when making commits
17+
#
18+
# TEST_SITE_NAME: The name of the test site to provide when installing.
19+
# ADMIN_PASSWORD: The admin password to use when installing.
20+
# ADMIN_EMAIL: The email address to give the admin when installing.
21+
#=========================================================================
22+
TZ: "/usr/share/zoneinfo/America/Los_Angeles"
23+
24+
# The variables below usually do not need to be modified.
25+
26+
#======================================================================================================================================
27+
# Circle CI 2.0 does not yet expand environment variables so they have to be manually EXPORTed
28+
# Once environment variables can be expanded the variables below can be uncommented and the EXPORTs in set-up-globals.sh can be removed
29+
# See: https://discuss.circleci.com/t/unclear-how-to-work-with-user-variables-circleci-provided-env-variables/12810/11
30+
# See: https://discuss.circleci.com/t/environment-variable-expansion-in-working-directory/11322
31+
# See: https://discuss.circleci.com/t/circle-2-0-global-environment-variables/8681
32+
#======================================================================================================================================
33+
34+
NOTIFY: 'scripts/github/add-commit-comment {project} {sha} "Created multidev environment [{site}#{env}]({dashboard-url})." {site-url}'
35+
ADMIN_USERNAME: admin
36+
# BUILD_TOOLS_VERSION: ^2.0.0-alpha4
37+
TERM: dumb
38+
39+
version: 2
40+
jobs:
41+
# @todo: common initialization: 'composer install' for the site-under-test
42+
build:
43+
<<: *defaults
44+
steps:
45+
- checkout
46+
47+
- restore_cache:
48+
keys:
49+
- composer-cache
50+
- terminus-install
51+
52+
- run:
53+
# Set TERMINUS_ENV and related environment variables.
54+
# https://github.com/pantheon-systems/docker-build-tools-ci/blob/1.x/scripts/set-environment
55+
name: environment
56+
command: /build-tools-ci/scripts/set-environment
57+
58+
- run:
59+
name: run composer install to get the vendor directory
60+
command: composer install
61+
62+
- save_cache:
63+
key: composer-cache
64+
paths:
65+
- $HOME/.composer/cache
66+
67+
- save_cache:
68+
key: terminus-install
69+
paths:
70+
- $(TERMINUS_PLUGINS_DIR:-~/.terminus/plugins)
71+
72+
- run:
73+
name: lint php code for syntax errors
74+
command: composer -n lint
75+
76+
- run:
77+
name: check coding standards
78+
command: composer -n code-sniff
79+
80+
- run:
81+
name: run unit tests
82+
command: composer -n unit-test
83+
84+
build_deploy_and_test:
85+
<<: *defaults
86+
steps:
87+
- checkout
88+
89+
- restore_cache:
90+
keys:
91+
- composer-cache
92+
- terminus-install
93+
94+
- run:
95+
# Set TERMINUS_ENV and related environment variables.
96+
# https://github.com/pantheon-systems/docker-build-tools-ci/blob/1.x/scripts/set-environment
97+
name: dependencies
98+
command: /build-tools-ci/scripts/set-environment
99+
100+
- run:
101+
name: install dev dependencies, build assets, etc.
102+
command: ./.circleci/scripts/pantheon/01-prepare
103+
104+
- run:
105+
name: build assets
106+
command: composer -n build-assets
107+
108+
- run:
109+
name: prepare database for site-under test
110+
command: ./.circleci/scripts/pantheon/02-init-site-under-test-clone-existing
111+
# command: ./.circleci/scripts/pantheon/02-init-site-under-test-reinstall-new
112+
113+
- run:
114+
name: run functional tests with Behat
115+
command: ./tests/scripts/run-behat
116+
117+
- run:
118+
name: post-test actions
119+
command: ./.circleci/scripts/pantheon/03-post-test
120+
121+
- run:
122+
name: handle merge to master (if needed)
123+
command: ./.circleci/scripts/pantheon/04-merge-master
124+
125+
- run:
126+
name: remove transient test fixtures
127+
command: ./.circleci/scripts/pantheon/09-cleanup-fixtures
128+
129+
# TODO:
130+
# 04-merge-master
131+
# 09-cleanup-fixtures
132+
133+
workflows:
134+
version: 2
135+
build_and_test:
136+
jobs:
137+
# Install dev dependencies and do simple tests (sniff, unit tests, etc.)
138+
- build
139+
# Build deploy and test on target platform
140+
- build_deploy_and_test

.circleci/scripts/pantheon/01-prepare

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
set -eo pipefail
4+
5+
#
6+
# This script starts up the test process.
7+
#
8+
# - Environment settings (e.g. git config) are initialized
9+
# - Terminus plugins are installed
10+
# - Any needed code updates are done
11+
#
12+
echo "Begin build for $DEFAULT_ENV. Pantheon test environment is $TERMINUS_SITE.$TERMINUS_ENV"
13+
14+
# Log in via Terminus
15+
terminus -n auth:login --machine-token="$TERMINUS_TOKEN"
16+
17+
# Delete leftover CI environments
18+
terminus -n build:env:delete:ci "$TERMINUS_SITE" --keep=2 --yes
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
set -eo pipefail
4+
5+
#
6+
# This script prepares the site-under-test by cloning the database from
7+
# an existing site.
8+
#
9+
# Use EITHER this script OR the re-install-new script; do not run both.
10+
#
11+
12+
# Create a new multidev site to test on
13+
terminus -n env:wake "$TERMINUS_SITE.dev"
14+
terminus -n build:env:create "$TERMINUS_SITE.dev" "$TERMINUS_ENV" --yes --clone-content --notify="$NOTIFY"
15+
16+
# Run updatedb to ensure that the cloned database is updated for the new code.
17+
terminus -n drush "$TERMINUS_SITE.$TERMINUS_ENV" -- updatedb -y
18+
19+
# If exported configuration is available, then import it.
20+
if [ -f "config/system.site.yml" ] ; then
21+
terminus -n drush "$TERMINUS_SITE.$TERMINUS_ENV" -- config-import --yes
22+
fi
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
set -eo pipefail
4+
5+
#
6+
# This script prepares the site-under-test by re-installing a new site.
7+
#
8+
# Use EITHER this script OR the clone-existing script; do not run both.
9+
#
10+
11+
# Create a new multidev site to test on
12+
terminus -n build:env:create "$TERMINUS_SITE.dev" "$TERMINUS_ENV" --yes --notify="$NOTIFY"
13+
14+
# Re-run the site installation process
15+
terminus -n build:env:install "$TERMINUS_SITE.$TERMINUS_ENV" --site-name="$TEST_SITE_NAME" --account-mail="$ADMIN_EMAIL" --account-pass="$ADMIN_PASSWORD"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
set -eo pipefail
4+
5+
#
6+
# This script runs any post-test operations that may be needed.
7+
#
8+
9+
terminus -n secrets:set "$TERMINUS_SITE.$TERMINUS_ENV" token "$GITHUB_TOKEN" --file='github-secrets.json' --clear --skip-if-empty
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
set -eo pipefail
4+
5+
#
6+
# This script handles all operations that must be done when a
7+
# pull request is merged back into the master branch.
8+
#
9+
if [[ $CIRCLE_BRANCH != "master" ]] ; then
10+
exit 0
11+
fi
12+
13+
# Merge the multidev for the PR into the dev environment
14+
terminus -n build:env:merge "$TERMINUS_SITE.$TERMINUS_ENV" --yes
15+
16+
# Run updatedb on the dev environment
17+
terminus -n drush $TERMINUS_SITE.dev -- updatedb --yes
18+
19+
# If there are any exported configuration files, then import them
20+
if [ -f "config/system.site.yml" ] ; then
21+
terminus -n drush "$TERMINUS_SITE.dev" -- config-import --yes
22+
fi
23+
24+
# Delete old multidev environments associated with a PR that has been
25+
# merged or closed.
26+
terminus -n build:env:delete:pr "$TERMINUS_SITE" --yes
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
set -eo pipefail
4+
5+
#
6+
# This script deletes any fixtures that are no longer needed.
7+
#
8+
# Note that we allow the "ci-BUILD_NUMBER" and "pr-PULL_REQUEST_NUMBER"
9+
# multidev sites to persist until the next time the 'prepare' or
10+
# 'merge-master' scripts (respectively) are called.
11+
#
12+

.gitignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ web/autoload.php
2222
web/index.php
2323
web/robots.txt
2424
web/sites/default/default.services.pantheon.preproduction.yml
25-
web/sites/default/default.services.yml
2625
web/sites/default/default.settings.php
2726
web/sites/default/settings.pantheon.php
2827
web/sites/development.services.yml
@@ -50,16 +49,14 @@ web/web.config
5049
### to the Pantheon repository.
5150
###
5251

53-
# Ignore Drupal's file directory
54-
/web/sites/*/files/
55-
5652
# Ignore Drupal's file directory
5753
web/sites/default/files
5854

5955
# Pantheon commits a settings.php for environment-specific settings.
6056
# Place local settings in settings.local.php
6157
web/sites/*/settings.local.php
6258
web/sites/*/services*.yml
59+
!web/sites/*/services.pantheon.*.yml
6360

6461
# Ignore SimpleTest multi-site environment.
6562
web/sites/simpletest
@@ -104,3 +101,6 @@ Thumbs.db
104101

105102
# Things in the core directory that Drupal 8 commits in the repository.
106103
!web/core/**/*.gz
104+
105+
# Don't commit keys generated by contenta install
106+
/keys/

.gitlab-ci.yml

Lines changed: 0 additions & 78 deletions
This file was deleted.

0 commit comments

Comments
 (0)