Skip to content

Commit 2f7c5ab

Browse files
greg-1-andersonPantheon Automation
authored and
Pantheon Automation
committed
CircleCI 2.0 tests.
1 parent 47a5d0c commit 2f7c5ab

15 files changed

+559
-0
lines changed

.circleci/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.DS_Store
2+
local.test
3+
local.env
4+
local.ssh

.circleci/behat.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# behat.yml
2+
default:
3+
suites:
4+
default:
5+
paths:
6+
- features
7+
contexts:
8+
- Drupal\DrupalExtension\Context\DrupalContext
9+
- Drupal\DrupalExtension\Context\MinkContext
10+
- FeatureContext
11+
extensions:
12+
Behat\MinkExtension:
13+
# base_url set by ENV
14+
goutte: ~
15+
Drupal\DrupalExtension:
16+
blackbox: ~
17+
api_driver: 'drush'

.circleci/cleanup.sh

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
# Echo commands as they are executed, but don't allow errors to stop the script.
4+
set -x
5+
6+
if [ -z "$TERMINUS_SITE" ] || [ -z "$TERMINUS_ENV" ]; then
7+
echo "TERMINUS_SITE and TERMINUS_ENV environment variables must be set"
8+
exit 1
9+
fi
10+
11+
# Only delete old environments if there is a pattern defined to
12+
# match environments eligible for deletion. Otherwise, delete the
13+
# current multidev environment immediately.
14+
#
15+
# To use this feature, set MULTIDEV_DELETE_PATTERN to '^ci-' or similar
16+
# in the CI server environment variables.
17+
if [ -z "$MULTIDEV_DELETE_PATTERN" ] ; then
18+
terminus env:delete $TERMINUS_SITE.$TERMINUS_ENV --delete-branch --yes
19+
exit 0
20+
fi
21+
22+
# List all but the newest two environments.
23+
OLDEST_ENVIRONMENTS=$(terminus env:list "$TERMINUS_SITE" --format=list | grep -v dev | grep -v test | grep -v live | sort -k2 | grep "$MULTIDEV_DELETE_PATTERN" | sed -e '$d' | sed -e '$d')
24+
25+
# Exit if there are no environments to delete
26+
if [ -z "$OLDEST_ENVIRONMENTS" ] ; then
27+
exit 0
28+
fi
29+
30+
# Go ahead and delete the oldest environments.
31+
for ENV_TO_DELETE in $OLDEST_ENVIRONMENTS ; do
32+
terminus env:delete $TERMINUS_SITE.$ENV_TO_DELETE --delete-branch --yes
33+
done

.circleci/config.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
version: 2
2+
jobs:
3+
test:
4+
docker:
5+
- image: quay.io/pantheon-public/build-tools-ci:8.x-php7.4
6+
working_directory: ~/work/d7
7+
environment:
8+
TZ: "/usr/share/zoneinfo/America/Los_Angeles"
9+
TERM: dumb
10+
steps:
11+
- checkout
12+
- run:
13+
name: Set up environment
14+
command: ./.circleci/set-up-globals.sh
15+
- run:
16+
name: Prepare
17+
command: ./.circleci/prepare.sh
18+
- run:
19+
name: Test
20+
command: ./.circleci/test.sh --strict
21+
- run:
22+
name: Cleanup
23+
command: ./.circleci/cleanup.sh
24+
- run:
25+
name: Confirm that it is safe to merge
26+
command: ./.circleci/confirm-safety.sh
27+
merge:
28+
docker:
29+
- image: quay.io/getpantheon/upstream-update-build:1.x
30+
working_directory: ~/work/d7
31+
environment:
32+
TZ: "/usr/share/zoneinfo/America/Los_Angeles"
33+
TERM: dumb
34+
steps:
35+
- checkout
36+
- add_ssh_keys:
37+
fingerprints:
38+
- "f8:c0:e1:28:4d:f9:1a:01:aa:7f:d0:8c:f6:e1:e6:88"
39+
- run:
40+
# https://github.com/pantheon-systems/upstream-update-build/blob/1.x/bin/automerge.sh
41+
name: Merge the default branch back to the master branch
42+
command: automerge.sh
43+
44+
workflows:
45+
version: 2
46+
drops7:
47+
jobs:
48+
- test
49+
- merge:
50+
requires:
51+
- test
52+
filters:
53+
branches:
54+
only:
55+
- default

.circleci/confirm-safety.sh

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
3+
#
4+
# The purpose of this script is to examine the base branch that this PR is
5+
# set to merge into by usig the GitHub API. We are only querying a public
6+
# repo here, so we do not need to use the GITHUB_TOKEN.
7+
#
8+
9+
# Exit if we are not running on Circle CI.
10+
if [ -z "$CIRCLECI" ] ; then
11+
exit 0
12+
fi
13+
14+
# We only need to make this check for branches forked from default (right) / master (wrong).
15+
# Skip the test for the default branch. (The .circleci directory will never be added to the master branch).
16+
if [ "$CIRCLE_BRANCH" == "default" ] ; then
17+
exit 0
18+
fi
19+
20+
# We cannot continue unless we have a pull request.
21+
if [ -z "$CIRCLE_PULL_REQUEST" ] ; then
22+
echo "No CIRCLE_PULL_REQUEST defined; please create a pull request."
23+
exit 1
24+
fi
25+
26+
# CIRCLE_PULL_REQUEST=https://github.com/ORG/PROJECT/pull/NUMBER
27+
PR_NUMBER=$(echo $CIRCLE_PULL_REQUEST | sed -e 's#.*/pull/##')
28+
29+
# Display the API call we are using
30+
echo curl https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls/$PR_NUMBER
31+
32+
base=$(curl https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls/$PR_NUMBER 2>/dev/null | jq .base.ref)
33+
34+
echo "The base branch is $base"
35+
36+
# If the PR merges into 'default', then it is safe to merge.
37+
if [ "$base" == '"default"' ] ; then
38+
echo "It is safe to merge this PR into the $base branch"
39+
exit 0
40+
fi
41+
42+
# Force a test failure if the PR's base is the master branch.
43+
if [ "$base" == '"master"' ] ; then
44+
echo "ERROR: merging this PR into the $base branch is not allowed. Change the base branch for the PR to merge into the \"default\" branch instead."
45+
exit 1
46+
fi
47+
48+
echo "Merging probably okay, if you are merging one PR into another. Use caution; do not merge to the \"master\" branch."

.circleci/features/0-install.feature

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Feature: Installer
2+
In order to know that we can install the site via drush
3+
As a website user
4+
I need to be able to install a Drupal site
5+
6+
Scenario: Installer is ready
7+
Given I have wiped the site
8+
And I have reinstalled "CI Drops-7 [{site-name}.{env}]"
9+
And I visit "/"
10+
Then I should see "Welcome to CI Drops-7"

0 commit comments

Comments
 (0)