-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Pantheon Automation
committed
Jul 16, 2024
1 parent
cfec055
commit 8a59c06
Showing
19 changed files
with
584 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.DS_Store | ||
local.test | ||
local.env | ||
local.ssh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# behat.yml | ||
default: | ||
suites: | ||
default: | ||
paths: | ||
- features | ||
contexts: | ||
- Behat\MinkExtension\Context\MinkContext | ||
- AdminLogIn | ||
- ResponseHeader | ||
extensions: | ||
Behat\MinkExtension: | ||
# base_url set by ENV | ||
goutte: ~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
test-defaults: &test-defaults | ||
docker: | ||
- image: quay.io/pantheon-public/build-tools-ci:8.x-php8.2 | ||
working_directory: ~/work/wp | ||
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/wp | ||
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: | ||
- add_ssh_keys: | ||
fingerprints: | ||
- "0e:e2:d5:f9:90:24:5b:fd:b9:18:40:4a:a5:00:13:07" | ||
- 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 | ||
wordpress: | ||
jobs: | ||
- test | ||
- merge: | ||
requires: | ||
- test | ||
context: | ||
- docker-executor-auth | ||
filters: | ||
branches: | ||
only: | ||
- default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
Feature: Install WordPress through the web UI | ||
|
||
@upstreamonly | ||
Scenario: Install WordPress with the en_US locale | ||
When I go to "/" | ||
Then print current URL | ||
And I should be on "/wp-admin/install.php" | ||
|
||
When I press "language-continue" | ||
Then print current URL | ||
And I should be on "/wp-admin/install.php?step=1" | ||
And I should see "Welcome to the famous five-minute WordPress installation process!" | ||
|
||
When I fill in "weblog_title" with "Pantheon WordPress Upstream" | ||
And I fill in "user_name" with the command line global variable: "WORDPRESS_ADMIN_USERNAME" | ||
And I fill in "admin_password" with the command line global variable: "WORDPRESS_ADMIN_PASSWORD" | ||
And I fill in "admin_password2" with the command line global variable: "WORDPRESS_ADMIN_PASSWORD" | ||
And I check "pw_weak" | ||
And I fill in "admin_email" with "[email protected]" | ||
And I press "submit" | ||
Then print current URL | ||
And I should be on "/wp-admin/install.php?step=2" | ||
And I should see "WordPress has been installed." | ||
And I follow "Log In" | ||
And I fill in "Username or Email Address" with the command line global variable: "WORDPRESS_ADMIN_USERNAME" | ||
And I fill in "Password" with the command line global variable: "WORDPRESS_ADMIN_PASSWORD" | ||
And I press "Log In" | ||
Then I should see "Welcome to WordPress!" | ||
|
||
Scenario: Attempting to install WordPress a second time should error | ||
When I go to "/wp-admin/install.php" | ||
Then I should see "You appear to have already installed WordPress." | ||
|
||
Scenario: Verify the site identifies as WordPress | ||
When I go to "/" | ||
Then I should see the WordPress generator meta tag | ||
|
||
@upstreamonly | ||
Scenario: Delete Akismet and Hello Dolly | ||
Given I log in as an admin | ||
|
||
When I go to "/wp-admin/plugins.php" | ||
Then I should see "2 items" in the ".displaying-num" element | ||
|
||
When I follow "Delete" | ||
Then I should see "You are about to remove the following plugin:" | ||
|
||
When I press "submit" | ||
Then print current URL | ||
And I should see "The selected plugin has been deleted." in the "#message" element | ||
And I should see "1 item" in the ".displaying-num" element | ||
|
||
When I follow "Delete" | ||
Then I should see "You are about to remove the following plugin:" | ||
|
||
When I press "submit" | ||
Then print current URL | ||
And I should see "The selected plugin has been deleted." in the "#message" element | ||
And I should see "No plugins are currently available." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
use Behat\Behat\Context\Context; | ||
use Behat\Behat\Context\SnippetAcceptingContext; | ||
use Behat\MinkExtension\Context\MinkContext; | ||
use Behat\Behat\Hook\Scope\BeforeScenarioScope; | ||
|
||
/** | ||
* Define application features from the specific context. | ||
*/ | ||
class AdminLogIn implements Context, SnippetAcceptingContext { | ||
|
||
/** @var \Behat\MinkExtension\Context\MinkContext */ | ||
private $minkContext; | ||
|
||
/** @BeforeScenario */ | ||
public function gatherContexts(BeforeScenarioScope $scope) | ||
{ | ||
$environment = $scope->getEnvironment(); | ||
$this->minkContext = $environment->getContext('Behat\MinkExtension\Context\MinkContext'); | ||
} | ||
|
||
/** | ||
* @Given I log in as an admin | ||
*/ | ||
public function ILogInAsAnAdmin() | ||
{ | ||
$this->minkContext->visit('wp-login.php'); | ||
$this->minkContext->fillField('log', getenv('WORDPRESS_ADMIN_USERNAME')); | ||
$this->minkContext->fillField('pwd', getenv('WORDPRESS_ADMIN_PASSWORD')); | ||
$this->minkContext->pressButton('wp-submit'); | ||
$this->minkContext->assertPageAddress("wp-admin/"); | ||
} | ||
|
||
/** | ||
* Fills in form field with specified id|name|label|value | ||
* Example: When I fill in "admin_password2" with the command line global variable: "WORDPRESS_ADMIN_PASSWORD" | ||
* | ||
* @When I fill in :arg1 with the command line global variable: :arg2 | ||
*/ | ||
public function fillFieldWithGlobal($field, $value) | ||
{ | ||
$this->minkContext->fillField($field, getenv($value)); | ||
} | ||
|
||
/** | ||
* Checks, that <meta name="generator" exists and that it contains content="WordPress *". | ||
* Example: Then I should see the WordPress generator meta tag | ||
* @Then I should see the WordPress generator meta tag | ||
*/ | ||
public function iShouldSeeTheWordPressGeneratorMetaTag() | ||
{ | ||
$this->minkContext->assertElementOnPage('meta[name="generator"]'); | ||
$this->minkContext->assertSession()->elementAttributeContains('css', 'meta[name="generator"]', 'content', 'WordPress'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
use Behat\MinkExtension\Context\RawMinkContext; | ||
|
||
class ResponseHeader extends RawMinkContext { | ||
|
||
/** | ||
* Checks, that current page response header is equal to specified. | ||
* | ||
* @Then /^the response header "(?P<name>(?:[^"]|\\")*)" should be "(?P<value>(?:[^"]|\\")*)"$/ | ||
*/ | ||
public function assertResponseHeader($name, $value) | ||
{ | ||
$this->assertSession()->responseHeaderEquals($name, $value); | ||
} | ||
|
||
/** | ||
* Checks, that current page response header is not equal to specified. | ||
* | ||
* @Then /^the response header "(?P<name>(?:[^"]|\\")*)" should not be "(?P<value>(?:[^"]|\\")*)"$/ | ||
*/ | ||
public function assertResponseHeaderIsNot($name, $value) | ||
{ | ||
$this->assertSession()->responseHeaderNotEquals($name, $value); | ||
} | ||
|
||
/** | ||
* Checks, that current page response header contains specified value. | ||
* | ||
* @Then /^the response header "(?P<name>(?:[^"]|\\")*)" should contain "(?P<value>(?:[^"]|\\")*)"$/ | ||
*/ | ||
public function assertResponseHeaderContains($name, $value) | ||
{ | ||
$this->assertSession()->responseHeaderContains($name, $value); | ||
} | ||
/** | ||
* Checks, that current page response header does not contain specified value. | ||
* | ||
* @Then /^the response header "(?P<name>(?:[^"]|\\")*)" should not contain "(?P<value>(?:[^"]|\\")*)"$/ | ||
*/ | ||
public function assertResponseHeaderNotContains($name, $value) | ||
{ | ||
$this->assertSession()->responseHeaderNotContains($name, $value); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Feature: Manage WordPress options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Feature: Verify various Pantheon features as a logged-out user | ||
|
||
Scenario: Cache-Control should default to TTL=604800 | ||
When I go to "/" | ||
And the response header "Cache-Control" should be "public, max-age=604800" | ||
And the response header "Pragma" should not contain "no-cache" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Feature: Perform Pantheon-specific actions | ||
|
||
Background: | ||
Given I log in as an admin | ||
|
||
Scenario: Change the cache TTL | ||
When I go to "/wp-admin/options-general.php?page=pantheon-cache" | ||
Then I should see "Pantheon Page Cache" | ||
And the "pantheon-cache[default_ttl]" field should contain "604800" | ||
|
||
When I fill in "pantheon-cache[default_ttl]" with "300" | ||
And I press "Save Changes" | ||
Then I should see "Settings saved." | ||
And the "pantheon-cache[default_ttl]" field should contain "300" | ||
|
||
When I fill in "pantheon-cache[default_ttl]" with "600" | ||
And I press "Save Changes" | ||
Then I should see "Settings saved." | ||
And the "pantheon-cache[default_ttl]" field should contain "600" | ||
|
||
Scenario: Clear the site cache | ||
When I go to "/wp-admin/options-general.php?page=pantheon-cache" | ||
Then I should see "Clear Site Cache" | ||
And I should not see "Site cache flushed." | ||
|
||
When I press "Clear Cache" | ||
Then print current URL | ||
And I should be on "/wp-admin/options-general.php?page=pantheon-cache&cache-cleared=true" | ||
And I should see "Site cache flushed." in the ".updated" element | ||
|
||
Scenario: Verify the Pantheon MU plugin is present | ||
When I go to "/wp-admin/plugins.php?plugin_status=mustuse" | ||
Then I should see "Files in the /wp-content/mu-plugins directory are executed automatically." in the ".tablenav" element | ||
And I should see "Pantheon" in the "#the-list" element | ||
And I should see "Building on Pantheon's and WordPress's strengths, together." in the "#the-list" element |
Oops, something went wrong.