Skip to content

Commit 2a496ce

Browse files
committed
Squashing https://github.com/stevector/example-wordpress-composer into one commit to start fresh in pantheon-systems
0 parents  commit 2a496ce

18 files changed

+3321
-0
lines changed

.gitignore

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
###
2+
### GitHub repository .gitignore section
3+
###
4+
5+
# Ignore directories generated by Composer
6+
/vendor/
7+
8+
# Webroot #
9+
###########
10+
!web/
11+
web/*
12+
!web/index.php
13+
!web/wp-cli.yml
14+
!web/wp-config.php
15+
!web/wp-content/
16+
web/wp-content/*
17+
!web/wp-content/mu-plugins/
18+
web/wp-content/mu-plugins/*
19+
!web/wp-content/mu-plugins/alter_wpcfm_config_path.php
20+
!web/wp-content/plugins/
21+
web/wp-content/plugins/*
22+
!web/wp-content/themes
23+
web/wp-content/themes/*
24+
!web/wp-content/themes/twentyseventeen-child/
25+
!web/wp-content/config/
26+
!web/private/
27+
web/private/*
28+
!web/private/config/
29+
!web/private/scripts/
30+
31+
# Add directories containing build assets below.
32+
# Keep all additions above the "cut" line.
33+
34+
# This distinction is only important when using this
35+
# repository as a custom upstream. The .gitignore file
36+
# is not modified in the GitHub PR workflow.
37+
38+
39+
# :::::::::::::::::::::: cut ::::::::::::::::::::::
40+
41+
###
42+
### Pantheon site .gitignore section
43+
###
44+
### Items below the "cut" line are still ignored on
45+
### the Pantheon site. Items above the "cut" line
46+
### are ignored in the GitHub repository, but committed
47+
### to the Pantheon repository.
48+
###
49+
50+
# Ignore Drupal's file directory
51+
/web/sites/*/files/
52+
53+
# Ignore Drupal's file directory
54+
web/sites/default/files
55+
56+
# Pantheon commits a settings.php for environment-specific settings.
57+
# Place local settings in settings.local.php
58+
web/sites/*/settings.local.php
59+
web/sites/*/services*.yml
60+
61+
# Ignore SimpleTest multi-site environment.
62+
web/sites/simpletest
63+
64+
# Ignore files generated by PhpStorm
65+
.idea
66+
67+
# Packages #
68+
############
69+
*.7z
70+
*.dmg
71+
*.gz
72+
*.bz2
73+
*.iso
74+
*.jar
75+
*.rar
76+
*.tar
77+
*.zip
78+
*.tgz
79+
80+
# Logs and databases #
81+
######################
82+
*.log
83+
*.sql
84+
85+
# OS generated files #
86+
######################
87+
.DS_Store*
88+
ehthumbs.db
89+
Icon
90+
91+
Thumbs.db
92+
._*
93+
94+
# Vim generated files #
95+
######################
96+
*.un~
97+
98+
# SASS #
99+
##########
100+
.sass-cache
101+
102+
# Things in the core directory that Drupal 8 commits in the repository.
103+
!web/core/**/*.gz

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 Reload!
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Example WordPress Composer
2+
3+
4+
This repository is a start state for a Composer-based WordPress workflow with Pantheon. It is meant to be copied by the the [Terminus Build Tools Plugin](https://github.com/pantheon-systems/terminus-build-tools-plugin) which will set up for you a brand new
5+
6+
* GitHub repo
7+
* Free Pantheon sandbox site
8+
* A CircleCI configuration to run tests and push from the source repo (GitHub) to Pantheon.
9+
10+
For more background information on this style of workflow, see the [Pantheon documentation](https://pantheon.io/docs/guides/github-pull-requests/).
11+
12+
13+
## Installation
14+
15+
#### Prerequisites
16+
17+
Before running the `terminus build:project:create` command, make sure you have all of the prerequisites:
18+
19+
* [A Pantheon account](https://dashboard.pantheon.io/register)
20+
* [Terminus, the Pantheon command line tool](https://pantheon.io/docs/terminus/install/)
21+
* [The Terminus Build Tools Plugin](https://github.com/pantheon-systems/terminus-build-tools-plugin)
22+
* An account with GitHub and an authentication token capable of creating new repos.
23+
* An account with CircleCI and an authentication token.
24+
25+
You may find it easier to export the GitHub and CircleCI tokens as variables on your command line where the Build Tools Plugin can detect them automatically:
26+
27+
```
28+
export GITHUB_TOKEN=[REDACTED]
29+
export CIRCLE_TOKEN=[REDACTED]
30+
```
31+
32+
#### One command setup:
33+
34+
Once you have all of the prerequisites in place, you can create your copy of this repo with one command:
35+
36+
```
37+
terminus build:project:create pantheon-systems/example-wordpress-composer my-new-site --team="Agency Org Name"
38+
```
39+
40+
The parameters shown here are:
41+
42+
* The name of the source repo, `pantheon-systems/example-wordpress-composer`. If you are interest in other source repos like Drupal 8, see the [Terminus Build Tools Plugin](https://github.com/pantheon-systems/terminus-build-tools-plugin).
43+
* The machine name to be used by both the soon-to-be-created Pantheon site and GitHub repo. Change `my-new-site` to something meaningful for you.
44+
* The `--team` flag is optional and refers to a Pantheon organization. Pantheon organizations are often web development agencies or Universities. Setting this parameter causes the newly created site to go within the given organization. Run the Terminus command `terminus org:list` to see the organizations you are a member of. There might not be any.
45+
46+
47+
## Important files and directories
48+
49+
#### `/web`
50+
51+
Pantheon will serve the site from the `/web` subdirectory due to the configuration in `pantheon.yml`, facilitating a Composer based workflow. Having your website in this subdirectory also allows for tests, scripts, and other files related to your project to be stored in your repo without polluting your web document root.
52+
53+
#### `/web/wp`
54+
55+
Even within the `/web` directory you may notice that other directories and files are in different places [compared to a default WordPress installation](https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory). See `/web/wp-config.php` for key settings like `WP_SITEURL` which allows WordPress core to be relocated to `/web/wp`. The overall layout of directories in the repo is inspired by [Bedrock](https://github.com/roots/bedrock).
56+
57+
#### `composer.json`
58+
59+
If you are just browsing this repository on GitHub, you may not see some of the directories mentioned above like `wp-admin`. That is because WordPress core and its plugins are installed via Composer and ignored in the `.gitignore` file. Specific plugins are added to the project via `composer.json` and `composer.lock` keeps track of the exact version of each plugin (or other dependency). Generic Composer dependencies (not WordPress plugins or themes) are downloaded to the `/vendor` folder.
60+
61+
## Behat tests
62+
63+
So that CircleCI will have some test to run, this repository includes a configuration of [WordHat](https://wordhat.info/), A WordPress Behat extension. You can add your own `.feature` files within `/tests/behat/features`. [A fuller guide on WordPress testing with Behat is forthcoming.](https://github.com/pantheon-systems/documentation/issues/2469)

circle.yml

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# https://circleci.com/docs/configuration#machine
2+
machine:
3+
timezone:
4+
America/Chicago
5+
php:
6+
# https://circleci.com/docs/build-image-trusty/#php
7+
version: 7.1.0
8+
environment:
9+
# In addition to the environment variables defined in this file, also
10+
# add the following variables in the Circle CI UI.
11+
#
12+
# See: https://circleci.com/docs/1.0/environment-variables/
13+
#
14+
# TERMINUS_SITE: Name of the Pantheon site to run tests on, e.g. my_site
15+
# TERMINUS_TOKEN: The Pantheon machine token
16+
# GITHUB_TOKEN: The GitHub personal access token
17+
# GIT_EMAIL: The email address to use when making commits
18+
#
19+
# TEST_SITE_NAME: The name of the test site to provide when installing.
20+
# ADMIN_PASSWORD: The admin password to use when installing.
21+
# ADMIN_EMAIL: The email address to give the admin when installing.
22+
#
23+
# The variables below usually do not need to be modified.
24+
BRANCH: $(echo $CIRCLE_BRANCH | grep -v '^\(master\|[0-9]\+.x\)$')
25+
PR_ENV: ${BRANCH:+pr-$BRANCH}
26+
CIRCLE_ENV: ci-$CIRCLE_BUILD_NUM
27+
DEFAULT_ENV: $(echo ${PR_ENV:-$CIRCLE_ENV} | tr '[:upper:]' '[:lower:]' | sed 's/[^0-9a-z-]//g' | cut -c -11 | sed 's/-$//')
28+
TERMINUS_ENV: ${TERMINUS_ENV:-$DEFAULT_ENV}
29+
NOTIFY: 'scripts/github/add-commit-comment {project} {sha} "Created multidev environment [{site}#{env}]({dashboard-url})." {site-url}'
30+
PATH: $PATH:~/bin:tests/scripts
31+
WORDPRESS_ADMIN_USERNAME: admin
32+
# There is a mismatch in variable names used by
33+
# the terminus build plugin and the Behat tests.
34+
# So the variable ADMIN_PASSWORD needs to be
35+
# reassigned to WORDPRESS_ADMIN_PASSWORD.
36+
# And because CircleCI does not allow for simple
37+
# setting of a private variable to a public
38+
# variable, this workaround of writing to a file is
39+
# used.
40+
WORDPRESS_ADMIN_PASSWORD: $(cat ~/WORDPRESS_ADMIN_PASSWORD)
41+
42+
dependencies:
43+
cache_directories:
44+
- ~/.composer/cache
45+
pre:
46+
- echo "Begin build for $CIRCLE_ENV${PR_ENV:+ for }$PR_ENV. Pantheon test environment is $TERMINUS_SITE.$TERMINUS_ENV"
47+
- |
48+
if [ -n "$GITHUB_TOKEN" ] ; then
49+
composer config --global github-oauth.github.com $GITHUB_TOKEN
50+
fi
51+
- git config --global user.email "$GIT_EMAIL"
52+
- git config --global user.name "Circle CI"
53+
override:
54+
- echo $ADMIN_PASSWORD > ~/WORDPRESS_ADMIN_PASSWORD
55+
- composer global require -n "hirak/prestissimo:^0.3"
56+
- composer global require -n "consolidation/cgr"
57+
- cgr "pantheon-systems/terminus:^1"
58+
- terminus --version
59+
- mkdir -p ~/.terminus/plugins
60+
- composer create-project -n -d ~/.terminus/plugins pantheon-systems/terminus-build-tools-plugin:^1
61+
- composer create-project -n -d ~/.terminus/plugins pantheon-systems/terminus-secrets-plugin:^1
62+
post:
63+
- terminus auth:login -n --machine-token="$TERMINUS_TOKEN"
64+
- terminus build:env:delete:ci -n "$TERMINUS_SITE" --keep=2 --yes
65+
- composer -n build-assets
66+
- terminus env:wake -n "$TERMINUS_SITE.dev"
67+
- terminus build:env:create -n "$TERMINUS_SITE.dev" "$TERMINUS_ENV" --yes --notify="$NOTIFY"
68+
# This line will re-copy the database to the multidev environment to account
69+
# for multiple CI builds running on the same multidev.
70+
- terminus env:clone-content "$TERMINUS_SITE.dev" "$TERMINUS_ENV" --yes
71+
72+
test:
73+
override:
74+
- run-behat
75+
post:
76+
- terminus secrets:set -n "$TERMINUS_SITE.$TERMINUS_ENV" token "$GITHUB_TOKEN" --file='github-secrets.json' --clear --skip-if-empty
77+
78+
deployment:
79+
build-assets:
80+
branch: master
81+
commands:
82+
- terminus build-env:merge -n "$TERMINUS_SITE.$TERMINUS_ENV" --yes
83+
- terminus build-env:delete:pr -n "$TERMINUS_SITE" --yes

composer.json

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
{
2+
"name": "stevector/example-wordpress-composer",
3+
"description": "",
4+
"version": "0.1.0",
5+
"type": "project",
6+
"keywords": [],
7+
"minimum-stability": "dev",
8+
"repositories": [
9+
{
10+
"type": "composer",
11+
"url": "https://wpackagist.org"
12+
},
13+
{
14+
"type": "package",
15+
"package": {
16+
"name": "pantheon-systems/wordpress",
17+
"version": "4.8",
18+
"dist": {
19+
"url": "https://github.com/pantheon-systems/WordPress/archive/4.8.zip",
20+
"type": "zip"
21+
},
22+
"source": {
23+
"url": "[email protected]:pantheon-systems/WordPress.git",
24+
"type": "git",
25+
"reference": "4.8"
26+
},
27+
"type": "wordpress-core",
28+
"require": {
29+
"johnpbloch/wordpress-core-installer": "~0.1"
30+
},
31+
"extra": {
32+
"wordpress-install-dir": "web/wp"
33+
}
34+
}
35+
},
36+
{
37+
"type": "vcs",
38+
"url": "https://github.com/ataylorme/behat-wordpress-extension"
39+
}
40+
],
41+
"require": {
42+
"composer/installers": "~1.0",
43+
"vlucas/phpdotenv": "^2.4.0",
44+
"wpackagist-plugin/wp-native-php-sessions": "^0.6.0",
45+
"wpackagist-plugin/pantheon-advanced-page-cache": "^0.1.4",
46+
"wpackagist-plugin/wp-cfm": "^1.4.5",
47+
"wpackagist-theme/twentyseventeen": "^1.1",
48+
"pantheon-systems/wordpress": "^4.8",
49+
"roots/wp-password-bcrypt": "^1.0.0"
50+
},
51+
"require-dev": {
52+
"ataylorme/behat-wordpress-extension": "dev-pantheon-fixes",
53+
"behat/mink-goutte-driver": "^1.2",
54+
"behat/mink-selenium2-driver": "^1.3",
55+
"roave/security-advisories": "dev-master"
56+
},
57+
"config": {
58+
"vendor-dir": "vendor",
59+
"preferred-install": "dist",
60+
"secure-http": false
61+
},
62+
"extra": {
63+
"build-env": {
64+
"install-cms": [
65+
"wp core install --title={site-name} --url={site-url} --admin_user={account-name} --admin_email={account-mail} --admin_password={account-pass}",
66+
"wp option update permalink_structure '/%postname%/'"
67+
]
68+
},
69+
"installer-paths": {
70+
"web/wp-content/plugins/{$name}/": [
71+
"type:wordpress-plugin"
72+
],
73+
"web/wp-content/themes/{$name}/": [
74+
"type:wordpress-theme"
75+
]
76+
}
77+
},
78+
"scripts": {
79+
"build-assets": [
80+
"composer install --optimize-autoloader"
81+
],
82+
"cleanup": [
83+
"./scripts/composer/cleanup-composer"
84+
],
85+
"post-install-cmd": [
86+
"@cleanup"
87+
],
88+
"post-update-cmd": [
89+
"@cleanup"
90+
],
91+
"post-create-project-cmd": [
92+
"@cleanup"
93+
]
94+
},
95+
"prefer-stable": true
96+
}

0 commit comments

Comments
 (0)