Skip to content

Commit 15bb6b3

Browse files
committed
[BREAK UPSTREAM] include project specific docs
1 parent 0b58759 commit 15bb6b3

File tree

2 files changed

+111
-69
lines changed

2 files changed

+111
-69
lines changed

README.md

Lines changed: 108 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,146 @@
1-
# Example WordPress Composer
1+
# FIXME WordPress
22

3-
[![CircleCI](https://circleci.com/gh/pantheon-systems/example-wordpress-composer.svg?style=svg)](https://circleci.com/gh/pantheon-systems/example-wordpress-composer)
3+
[![Dev Site fix-me](https://img.shields.io/badge/site-fix_me-blue.svg)](http://dev-fix-me.pantheonsite.io/)
4+
[![Dashboard fix-me](https://img.shields.io/badge/dashboard-fix_me-yellow.svg)](https://dashboard.pantheon.io/sites/FIXME#dev/code)
5+
[![CircleCI](https://circleci.com/gh/Threespot/fix-me.svg?style=shield&circle-token=94d0633ad856a188c8cf3582fcc8f259269f74f9)](https://circleci.com/gh/Threespot/fix-me)
46

5-
This repository is a reference implementation and start state for a modern WordPress workflow utilizing [Composer](https://getcomposer.org/), Continuous Integration (CI), Automated Testing, and Pantheon. Even though this is a good starting point, you will need to customize and maintain the CI/testing set up for your projects.
7+
## Outline
68

7-
This repository is meant to be copied one-time by the the [Terminus Build Tools Plugin](https://github.com/pantheon-systems/terminus-build-tools-plugin) but can also be used as a template. It should not be cloned or forked directly.
9+
- [Pantheon Environments](#pantheon-environments)
10+
- [Local Development](#local-development)
11+
- [Prerequisites](#prerequisites)
12+
- [Installation](#installation)
13+
- [Boot WordPress Application](#boot-word-press-application)
14+
- [Boot Theme (Webpack) Server](#boot-theme-webpack-server)
15+
- [Pull Files and Database from Pantheon](#pull-files-and-database-from-pantheon)
16+
- [Deploying](#deploying)
17+
- [Deployment Using Terminus](#deployment-using-terminus)
18+
- [Test Environment](#test-environment)
19+
- [Live Environment](#live-environment)
820

9-
The Terminus Build Tools plugin will scaffold a new project, including:
21+
## Pantheon Environments
1022

11-
* A Git repository
12-
* A free Pantheon sandbox site
13-
* Continuous Integration configuration/credential set up
23+
- **Live** - http://live-fix-me.pantheonsite.io/
24+
- **Test** - http://test-fix-me.pantheonsite.io/
25+
- **Dev** - http://dev-fix-me.pantheonsite.io/
1426

15-
For more details and instructions on creating a new project, see the [Terminus Build Tools Plugin](https://github.com/pantheon-systems/terminus-build-tools-plugin/).
27+
## Local Development
1628

17-
## Important files and directories
29+
In order to more easily recreate the production environment locally, [Lando](https://lando.dev/) is used for local development. We also use Pantheon’s CLI, Terminus, to sync files and databases.
1830

19-
### `/web`
31+
- **PHP Server** - http://fix-me.lndo.site/
32+
- **Webpack Server** - https://localhost:3000
2033

21-
Pantheon will serve the site from the `/web` subdirectory due to the configuration in `pantheon.yml`. This is necessary for 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 or being web accessible from Pantheon. They may still be accessible from your version control project if it is public. See [the `pantheon.yml`](https://pantheon.io/docs/pantheon-yml/#nested-docroot) documentation for details.
34+
### Prerequisites
2235

23-
### `/web/wp`
36+
Install all the required local dependencies:
2437

25-
Even within the `/web` directory you may notice that other directories and files are in different places compared to a default WordPress installation. [WordPress allows installing WordPress core in its own directory](https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory), which is necessary when installing WordPress with Composer.
38+
- [Git Version Control](https://git-scm.com/downloads)
39+
- [Docker](https://www.docker.com/products/docker-desktop)
40+
- Lando v3.0.6 ([Windows](https://docs.devwithlando.io/installation/windows.html), [macOS](https://docs.devwithlando.io/installation/macos.html))
41+
- [Terminus](https://pantheon.io/docs/terminus/install/) 2.3.0, Pantheon’s CLI tool
42+
- [Composer](https://getcomposer.org/doc/00-intro.md)
43+
- [Node](https://nodejs.org/en/) 10.21.0
44+
Note: The sage theme dependencies do not support version of Node greater than 10. We recommend [asdf](https://github.com/asdf-vm/asdf) for managing multiple versions of Node
45+
- Yarn
46+
([Windows](https://yarnpkg.com/en/docs/install#windows-stable), [macOS](https://yarnpkg.com/en/docs/install#mac-stable))
2647

27-
See `/web/wp-config.php` for key settings, such as `WP_SITEURL`, which must be updated so that WordPress core functions properly in the relocated `/web/wp` directory. The overall layout of directories in the repo is inspired by, but doesn't exactly mirror, [Bedrock](https://github.com/roots/bedrock).
48+
You'll also need write access to this repo and be a member of the [Pantheon Project](https://dashboard.pantheon.io/sites/FIXME#dev/code).
2849

29-
### `composer.json`
30-
This project uses Composer to manage third-party PHP dependencies.
50+
### Installation
3151

32-
The `require` section of `composer.json` should be used for any dependencies your web project needs, even those that might only be used on non-Live environments. All dependencies in `require` will be pushed to Pantheon.
52+
1. Clone the Repo
53+
`$ git clone https://github.com/Threespot/fix-me.git`
54+
1. Install Application Composer Dependencies
55+
`$ composer install`
56+
1. Install Theme Composer Dependencies
57+
- Navigate to the sage theme directory
58+
`$ cd web/wp-content/themes/sage`
59+
- Install Componser deps
60+
`$ composer install`
61+
1. Install Theme Node Dependencies
62+
- Navigate to the sage theme directory
63+
`$ cd web/wp-content/themes/sage`
64+
- Install Node deps
65+
`$ yarn install` from the theme directory
3366

34-
The `require-dev` section should be used for dependencies that are not a part of the web application but are necesarry to build or test the project. Some example are `php_codesniffer` and `phpunit`. Dev dependencies will not be deployed to Pantheon.
67+
### Boot WordPress Application
3568

36-
If you are just browsing this repository on GitHub, you may not see some of the directories mentioned above, such as `web/wp`. That is because WordPress core and its plugins are installed via Composer and ignored in the `.gitignore` file.
69+
With all the dependencies installed, from the root project directory run:
3770

38-
A custom, [Composer version of WordPress for Pantheon](https://github.com/pantheon-systems/wordpress-composer/) is used as the source for WordPress core.
71+
```
72+
lando start
73+
```
3974

40-
Third party WordPress dependencies, such as plugins and themes, are added to the project via `composer.json`. The `composer.lock` file keeps track of the exact version of dependency. [Composer `installer-paths`](https://getcomposer.org/doc/faqs/how-do-i-install-a-package-to-a-custom-path-for-my-framework.md#how-do-i-install-a-package-to-a-custom-path-for-my-framework-) are used to ensure the WordPress dependencies are downloaded into the appropriate directory.
75+
If this is the first time running this command, Lando will build the necessary Docker containers.
4176

42-
Non-WordPress dependencies are downloaded to the `/vendor` directory.
77+
To stop the server run:
4378

44-
### `.ci`
45-
This `.ci` directory is where all of the scripts that run on Continuous Integration are stored. Provider specific configuration files, such as `.circle/config.yml` and `.gitlab-ci.yml`, make use of these scripts.
79+
```
80+
lando stop
81+
```
4682

47-
The scripts are organized into subdirectories of `.ci` according to their function: `build`, `deploy`, or `test`.
83+
Other Lando CLI command can be read here in the [Lando docs](https://docs.lando.dev/basics/usage.html)
4884

49-
#### Build Scripts `.ci/build`
50-
Steps for building an artifact suitable for deployment. Feel free to add other build scripts here, such as installing Node dependencies, depending on your needs.
85+
### Boot Theme (Webpack) Server
5186

52-
- `.ci/build/php` installs PHP dependencies with Composer
87+
Making CSS or JS updates requires running Webpack to recompile and inject the CSS and JS.
5388

54-
#### Build Scripts `.ci/deploy`
55-
Scripts for facilitating code deployment to Pantheon.
89+
1. Navigate to the theme folder
90+
`$ cd /web/wp-content/themes/sage`
5691

57-
- `.ci/deploy/pantheon/create-multidev` creates a new [Pantheon multidev environment](https://pantheon.io/docs/multidev/) for branches other than the default Git branch
58-
- Note that not all users have multidev access. Please consult [the multidev FAQ doc](https://pantheon.io/docs/multidev-faq/) for details.
59-
- `.ci/deploy/pantheon/dev-multidev` deploys the built artifact to either the Pantheon `dev` or a multidev environment, depending on the Git branch
92+
1. Install npm dependencies using Yarn
93+
`$ yarn install`
6094

61-
#### Automated Test Scripts `.ci/tests`
62-
Scripts that run automated tests. Feel free to add or remove scripts here depending on your testing needs.
95+
1. Start Webpack
96+
`$ yarn start`
6397

64-
**Static Testing** `.ci/test/static` and `tests/unit`
65-
Static tests analyze code without executing it. It is good at detecting syntax error but not functionality.
98+
1. You should now be able to view the site locally at https://localhost:3000
99+
1. To stop the server, press <kbd>Control</kbd> + <kbd>C</kbd>
66100

67-
- `.ci/test/static/run` Runs [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) with [WordPress coding standards](https://github.com/WordPress/WordPress-Coding-Standards), PHP Unit, and [PHP syntax checking](https://www.php.net/manual/en/function.php-check-syntax.php).
68-
- `tests/unit/bootstrap.php` Bootstraps the Composer autoloader
69-
- `tests/unit/TestAssert.php` An example Unit test. Project specific test files will need to be created in `tests/unit`.
101+
### Pull Files and Database from Pantheon
70102

71-
**Visual Regression Testing** `.ci/test/visual-regression`
72-
Visual regression testing uses a headless browser to take screenshots of web pages and compare them for visual differences.
103+
Lando is used to pull uploads and data from Pantheon. [See docs here](https://docs.lando.dev/config/pantheon.html#importing-your-database-and-files).
73104

74-
- `.ci/test/visual-regression/run` Runs [BackstopJS](https://github.com/garris/BackstopJS) visual regression testing.
75-
- `.ci/test/visual-regression/backstopConfig.js` The [BackstopJS](https://github.com/garris/BackstopJS) configuration file. Setting here will need to be updated for your project. For example, the `pathsToTest` variable determines the URLs to test.
105+
```
106+
lando pull --database=test --files=test --code=none
107+
```
76108

77-
**Behat Testing** `.ci/test/behat` and `tests/behat`
78-
[Behat](http://behat.org/en/latest/) is an acceptance/end-to-end testing framework written in PHP. It faciliates testing the fully built WordPress site on Pantheon infrastucture. [WordHat](https://wordhat.info/) is used to help with integrating Behat and WordPress.
109+
## Deploying
79110

80-
- `.ci/test/behat/initialize` deletes any existing WordPress user from Behat testing and creates a backup of the environment to be tested
81-
- `.ci/test/behat/run` sets the `BEHAT_PARAMS` environment variable with dynamic information necessary for Behat and configure it to use wp-cli via [Terminus](https://pantheon.io/docs/terminus/), creates the necessary WordPress user, starts headless Chrome, and runs Behat
82-
- `.ci/test/behat/cleanup` restores the previously made database backup, deletes the WordPress user used for Behat testing, and saves screenshots taken by Behat
83-
- `tests/behat/behat-pantheon.yml` Behat configuration file compatible with running tests against a Pantheon site
84-
- `tests/behat/tests/behat/features` Where Behat test files, with the `.feature` extension, should be stored. The provided example tests will need to be replaced with project specific tests.
85-
- `tests/behat/tests/behat/features/visit-homepage.feature` A Behat test file which visits the homepage and verifies a `200` response
86-
- `tests/behat/tests/behat/features/admin-login.feature` A Behat test file which logs into the WordPress dashboard as an administrator and verifies acess to new user creation
87-
- `tests/behat/tests/behat/features/admin-login.feature` A Behat test file which logs into the WordPress dashboard as an administrator, updates the `blogname` and `blogdescription` settings, clears the Pantheon cache, visits the home page, and verifies the update blog name and description appear.
111+
Code committed to the remote `master` branch is automatically deployed to the `dev` environement on Pantheon. After a local branch is pushed, [CircleCI](https://circleci.com/gh/Threespot/fix-me) will build and deploy the files to Pantheon’s [dev environment](https://dashboard.pantheon.io/sites/5118c78c-b29d-467c-b178-2728fe3f293c#dev/code). You can tell CircleCI to not run by adding `[skip ci]` to the commit message.
88112

113+
Code that exists on `dev` can be promoted to the `test` enviroment, and `test` can be promoted to the `live` environment. Details about the application lifecycle can be read [here](https://pantheon.io/agencies/development-workflow/dev-test-live-workflow).
114+
Feature branches with a corresponding pull request will create a multi-dev enviroment used for testing indiviual features. Docs are available [here](https://pantheon.io/docs/multidev)
89115

90-
## Working locally with Lando
91-
To get started using Lando to develop locally complete these one-time steps. Please note than Lando is an independent product and is not supported by Pantheon. For further assistance please refer to the [Lando documentation](https://docs.devwithlando.io/).
116+
### Deployment Using Terminus
92117

93-
* [Install Lando](https://docs.devwithlando.io/installation/system-requirements.html), if not already installed.
94-
* Clone your project repository from GitHub (or GitLab or BitBucket) locally.
95-
* Manually create a `.lando.yml` file with your preferred configuration, based on the [WordPress recipe](https://docs.lando.dev/config/wordpress.html#configuration).
96-
* Run `lando start` to start Lando.
97-
- Save the local site URL. It should be similar to `https://<PROJECT_NAME>.lndo.site`.
98-
* Run `lando composer install --no-ansi --no-interaction --optimize-autoloader --no-progress` to download dependencies
99-
* Run `lando pull --code=none` to download the media files and database from Pantheon.
100-
* Visit the local site URL saved from above.
118+
#### Test Environment
101119

102-
You should now be able to edit your site locally. The steps above do not need to be completed on subsequent starts. You can stop Lando with `lando stop` and start it again with `lando start`.
120+
Code will be promoted from `dev` to `test`
103121

104-
**Warning:** do NOT push/pull code between Lando and Pantheon directly. All code should be pushed to GitHub and deployed to Pantheon through a continuous integration service, such as CircleCI.
122+
```shell
123+
lando composer run-script deploy:test
124+
```
105125

106-
Composer, Terminus and wp-cli commands should be run in Lando rather than on the host machine. This is done by prefixing the desired command with `lando`. For example, after a change to `composer.json` run `lando composer update` rather than `composer update`.
126+
**NOTE:** this composer script will also purge Pantheon's cache.
127+
128+
or
129+
130+
```shell
131+
lando terminus env:deploy fix-me.test
132+
```
133+
134+
#### Live Environment
135+
136+
Code will be promoted from `test` to `live`
137+
138+
```shell
139+
lando composer run-script deploy:live
140+
```
141+
142+
or
143+
144+
```shell
145+
lando terminus env:deploy fix-me.live
146+
```

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@
9494
"unit-test": [
9595
"./vendor/bin/phpunit tests/unit/*"
9696
],
97-
"lint": "find web/wp-content -name '*.php' -exec php -l {} \\;"
97+
"lint": "find web/wp-content -name '*.php' -exec php -l {} \\;",
98+
"deploy:test": "terminus env:deploy fix-me.test && terminus env:clear-cache fix-me.test",
99+
"deploy:live": "terminus env:deploy fix-me.live"
98100
}
99101
}

0 commit comments

Comments
 (0)