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

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 Pantheon Automation committed May 9, 2022
1 parent cd29790 commit 495b94f
Show file tree
Hide file tree
Showing 15 changed files with 680 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
58 changes: 58 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
test-defaults: &test-defaults
docker:
- image: quay.io/pantheon-public/build-tools-ci:3.x
working_directory: ~/work/d7
environment:
TZ: "/usr/share/zoneinfo/America/Los_Angeles"
TERM: dumb

merge-defaults: &merge-defaults
docker:
- image: quay.io/getpantheon/upstream-update-build:1.x
working_directory: ~/work/d7
environment:
TZ: "/usr/share/zoneinfo/America/Los_Angeles"
TERM: dumb

version: 2
jobs:
test:
<<: *test-defaults
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:
<<: *merge-defaults
steps:
- checkout
- 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
drops-8:
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."
33 changes: 33 additions & 0 deletions .circleci/features/0-install.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Feature: Installer
In order to know that we can install the site via the installer
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 am on "/core/install.php"
Then I should see "Choose language"

Scenario: Language selection
Given I am on "/core/install.php"
And I press "Save and continue"
Then I should see "Select an installation profile"

Scenario: Profile selection
Given I am on "/core/install.php?langcode=en"
And I press "Save and continue"
And I wait for the progress bar to finish
Then I should see "Site name"

Scenario: Configure site
Given I am on "/core/install.php?langcode=en&profile=standard"
And I enter "Example Dot Com Test Site" for "edit-site-name"
And I enter "[email protected]" for "edit-site-mail"
And I enter "admin" for "Username"
And I enter the value of the env var "ADMIN_PASSWORD" for "edit-account-pass-pass1"
And I enter the value of the env var "ADMIN_PASSWORD" for "edit-account-pass-pass2"
And I enter "[email protected]" for "edit-account-mail"
And I press "Save and continue"
And I have run the drush command "pm-uninstall -y big_pipe"
And I visit "/"
Then I should see "Welcome to Example Dot Com"
Loading

1 comment on commit 495b94f

@pantheon-upstream
Copy link

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-843 for ci-drops-8.

Please sign in to comment.