Skip to content

Commit 8626d31

Browse files
CircleCI 2.0 tests.
1 parent bf4248b commit 8626d31

15 files changed

+561
-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

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