Skip to content

Commit

Permalink
CircleCI 2.0 tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-1-anderson authored and pwtyler committed Mar 8, 2024
1 parent 752db1e commit f248d0d
Show file tree
Hide file tree
Showing 15 changed files with 559 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .circleci/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.DS_Store
local.test
local.env
local.ssh
17 changes: 17 additions & 0 deletions .circleci/behat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# behat.yml
default:
suites:
default:
paths:
- features
contexts:
- Drupal\DrupalExtension\Context\DrupalContext
- Drupal\DrupalExtension\Context\MinkContext
- FeatureContext
extensions:
Behat\MinkExtension:
# base_url set by ENV
goutte: ~
Drupal\DrupalExtension:
blackbox: ~
api_driver: 'drush'
33 changes: 33 additions & 0 deletions .circleci/cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

# Echo commands as they are executed, but don't allow errors to stop the script.
set -x

if [ -z "$TERMINUS_SITE" ] || [ -z "$TERMINUS_ENV" ]; then
echo "TERMINUS_SITE and TERMINUS_ENV environment variables must be set"
exit 1
fi

# Only delete old environments if there is a pattern defined to
# match environments eligible for deletion. Otherwise, delete the
# current multidev environment immediately.
#
# To use this feature, set MULTIDEV_DELETE_PATTERN to '^ci-' or similar
# in the CI server environment variables.
if [ -z "$MULTIDEV_DELETE_PATTERN" ] ; then
terminus env:delete $TERMINUS_SITE.$TERMINUS_ENV --delete-branch --yes
exit 0
fi

# List all but the newest two environments.
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')

# Exit if there are no environments to delete
if [ -z "$OLDEST_ENVIRONMENTS" ] ; then
exit 0
fi

# Go ahead and delete the oldest environments.
for ENV_TO_DELETE in $OLDEST_ENVIRONMENTS ; do
terminus env:delete $TERMINUS_SITE.$ENV_TO_DELETE --delete-branch --yes
done
55 changes: 55 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
version: 2
jobs:
test:
docker:
- image: quay.io/pantheon-public/build-tools-ci:8.x-php7.4
working_directory: ~/work/d7
environment:
TZ: "/usr/share/zoneinfo/America/Los_Angeles"
TERM: dumb
steps:
- checkout
- run:
name: Set up environment
command: ./.circleci/set-up-globals.sh
- run:
name: Prepare
command: ./.circleci/prepare.sh
- run:
name: Test
command: ./.circleci/test.sh --strict
- run:
name: Cleanup
command: ./.circleci/cleanup.sh
- run:
name: Confirm that it is safe to merge
command: ./.circleci/confirm-safety.sh
merge:
docker:
- image: quay.io/getpantheon/upstream-update-build:1.x
working_directory: ~/work/d7
environment:
TZ: "/usr/share/zoneinfo/America/Los_Angeles"
TERM: dumb
steps:
- checkout
- add_ssh_keys:
fingerprints:
- "f8:c0:e1:28:4d:f9:1a:01:aa:7f:d0:8c:f6:e1:e6:88"
- run:
# https://github.com/pantheon-systems/upstream-update-build/blob/1.x/bin/automerge.sh
name: Merge the default branch back to the master branch
command: automerge.sh

workflows:
version: 2
drops7:
jobs:
- test
- merge:
requires:
- test
filters:
branches:
only:
- default
48 changes: 48 additions & 0 deletions .circleci/confirm-safety.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

#
# The purpose of this script is to examine the base branch that this PR is
# set to merge into by usig the GitHub API. We are only querying a public
# repo here, so we do not need to use the GITHUB_TOKEN.
#

# Exit if we are not running on Circle CI.
if [ -z "$CIRCLECI" ] ; then
exit 0
fi

# We only need to make this check for branches forked from default (right) / master (wrong).
# Skip the test for the default branch. (The .circleci directory will never be added to the master branch).
if [ "$CIRCLE_BRANCH" == "default" ] ; then
exit 0
fi

# We cannot continue unless we have a pull request.
if [ -z "$CIRCLE_PULL_REQUEST" ] ; then
echo "No CIRCLE_PULL_REQUEST defined; please create a pull request."
exit 1
fi

# CIRCLE_PULL_REQUEST=https://github.com/ORG/PROJECT/pull/NUMBER
PR_NUMBER=$(echo $CIRCLE_PULL_REQUEST | sed -e 's#.*/pull/##')

# Display the API call we are using
echo curl https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls/$PR_NUMBER

base=$(curl https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls/$PR_NUMBER 2>/dev/null | jq .base.ref)

echo "The base branch is $base"

# If the PR merges into 'default', then it is safe to merge.
if [ "$base" == '"default"' ] ; then
echo "It is safe to merge this PR into the $base branch"
exit 0
fi

# Force a test failure if the PR's base is the master branch.
if [ "$base" == '"master"' ] ; then
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."
exit 1
fi

echo "Merging probably okay, if you are merging one PR into another. Use caution; do not merge to the \"master\" branch."
10 changes: 10 additions & 0 deletions .circleci/features/0-install.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Feature: Installer
In order to know that we can install the site via drush
As a website user
I need to be able to install a Drupal site

Scenario: Installer is ready
Given I have wiped the site
And I have reinstalled "CI Drops-7 [{site-name}.{env}]"
And I visit "/"
Then I should see "Welcome to CI Drops-7"
Loading

2 comments on commit f248d0d

@pantheon-ci-bot
Copy link
Collaborator

Choose a reason for hiding this comment

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

Visit Site

Created multidev environment ci-491 for ci-update-drops-7.

@pantheon-ci-bot
Copy link
Collaborator

Choose a reason for hiding this comment

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

Visit Site

Created multidev environment ci-492 for ci-update-drops-7.

Please sign in to comment.