Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 55 additions & 14 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ jobs:
name: run PHP build step
command: ./.ci/build/php

- run:
name: install theme composer dependencies
command: cd web/wp-content/themes/sage && composer install

- save_cache:
key: vendor-{{ checksum "composer.lock" }}
paths:
Expand All @@ -118,6 +122,41 @@ jobs:
- web
- vendor

build_yarn:
<<: *defaults
docker:
- image: circleci/node:10.16.2

steps:
- checkout

- restore_cache:
keys:
- yarn-packages-{{ checksum "web/wp-content/themes/sage/yarn.lock" }}
- yarn-packages- # used if checksum fails

- run:
name: install theme yarn dependencies
command: cd web/wp-content/themes/sage && yarn install

- run:
name: build theme assets
# If non-hashed versions of site assets are needed for 3rd parties, also run `yarn build:nohash`
command: cd web/wp-content/themes/sage && yarn build

- save_cache:
name: cache Yarn files
key: yarn-packages-{{ checksum "web/wp-content/themes/sage/yarn.lock" }}
paths:
- $HOME/.cache/yarn

- persist_to_workspace:
# Must be relative path from working_directory
root: .
# Must be relative path from root
paths:
- web/wp-content/themes/sage/dist

deploy_to_pantheon:
<<: *defaults
steps:
Expand Down Expand Up @@ -230,24 +269,26 @@ workflows:
build_deploy_and_test:
jobs:
- configure_env_vars
- static_tests
# - static_tests
- build_yarn
- build_php
- deploy_to_pantheon:
requires:
- static_tests
# - static_tests
- build_yarn
- build_php
- visual_regression_test:
requires:
- configure_env_vars
- deploy_to_pantheon
filters:
branches:
ignore:
- master
- behat_test:
requires:
- deploy_to_pantheon
- visual_regression_test
# - visual_regression_test:
# requires:
# - configure_env_vars
# - deploy_to_pantheon
# filters:
# branches:
# ignore:
# - master
# - behat_test:
# requires:
# - deploy_to_pantheon
# - visual_regression_test

scheduled_update_check:
triggers:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ web/*
!web/wp-config.php
!web/wp-content/
web/wp-content/*
!web/wp-content/cache
!web/wp-content/mu-plugins/
web/wp-content/mu-plugins/*
!web/wp-content/mu-plugins/custom
Expand Down
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 10.21.0
141 changes: 141 additions & 0 deletions README.template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
## Outline

- [Pantheon Environments](#pantheon-environments)
- [Local Development](#local-development)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Boot WordPress Application](#boot-word-press-application)
- [Boot Theme (Webpack) Server](#boot-theme-webpack-server)
- [Pull Files and Database from Pantheon](#pull-files-and-database-from-pantheon)
- [Deploying](#deploying)
- [Deployment Using Terminus](#deployment-using-terminus)
- [Test Environment](#test-environment)
- [Live Environment](#live-environment)
- [Troubleshooting](/docs/troubleshooting.md)

## Pantheon Environments

- **Live** - http://live-fix-me.pantheonsite.io/
- **Test** - http://test-fix-me.pantheonsite.io/
- **Dev** - http://dev-fix-me.pantheonsite.io/

## Local Development

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.

- **PHP Server** - http://fix-me.lndo.site/
- **Webpack Server** - https://localhost:3000

### Prerequisites

Install all the required local dependencies:

- [Git Version Control](https://git-scm.com/downloads)
- [Docker](https://www.docker.com/products/docker-desktop)
- Lando v3.0.6 ([Windows](https://docs.devwithlando.io/installation/windows.html), [macOS](https://docs.devwithlando.io/installation/macos.html))
- [Terminus](https://pantheon.io/docs/terminus/install/) 2.3.0, Pantheon’s CLI tool
- [Composer](https://getcomposer.org/doc/00-intro.md)
- [Node](https://nodejs.org/en/) 10.21.0
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
- Yarn
([Windows](https://yarnpkg.com/en/docs/install#windows-stable), [macOS](https://yarnpkg.com/en/docs/install#mac-stable))

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).

### Installation

1. Clone the Repo
`$ git clone https://github.com/Threespot/fix-me.git`
1. Install Application Composer Dependencies
`$ composer install`
1. Install Theme Composer Dependencies
- Navigate to the sage theme directory
`$ cd web/wp-content/themes/sage`
- Install Componser deps
`$ composer install`
1. Install Theme Node Dependencies
- Navigate to the sage theme directory
`$ cd web/wp-content/themes/sage`
- Install Node deps
`$ yarn install` from the theme directory

### Boot WordPress Application

With all the dependencies installed, from the root project directory run:

```
lando start
```

If this is the first time running this command, Lando will build the necessary Docker containers.

To stop the server run:

```
lando stop
```

Other Lando CLI command can be read here in the [Lando docs](https://docs.lando.dev/basics/usage.html)

### Boot Theme (Webpack) Server

Making CSS or JS updates requires running Webpack to recompile and inject the CSS and JS.

1. Navigate to the theme folder
`$ cd /web/wp-content/themes/sage`

1. Install npm dependencies using Yarn
`$ yarn install`

1. Start Webpack
`$ yarn start`

1. You should now be able to view the site locally at https://localhost:3000
1. To stop the server, press <kbd>Control</kbd> + <kbd>C</kbd>

### Pull Files and Database from Pantheon

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).

```
lando pull --database=test --files=test --code=none
```

## Deploying

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.

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).
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)

### Deployment Using Terminus

#### Test Environment

Code will be promoted from `dev` to `test`

```shell
lando composer run-script deploy:test
```

**NOTE:** this composer script will also purge Pantheon's cache.

or

```shell
lando terminus env:deploy fix-me.test
```

#### Live Environment

Code will be promoted from `test` to `live`

```shell
lando composer run-script deploy:live
```

or

```shell
lando terminus env:deploy fix-me.live
```
8 changes: 5 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pantheon-systems/example-wordpress-composer",
"description": "",
"name": "threespot/example-wordpress-composer",
"description": "Terminus build tools template for a Pantheon Composer WordPress application",
"type": "project",
"keywords": [],
"repositories": [
Expand Down Expand Up @@ -94,6 +94,8 @@
"unit-test": [
"./vendor/bin/phpunit tests/unit/*"
],
"lint": "find web/wp-content -name '*.php' -exec php -l {} \\;"
"lint": "find web/wp-content -name '*.php' -exec php -l {} \\;",
"deploy:test": "terminus env:deploy fix-me.test && terminus env:clear-cache fix-me.test",
"deploy:live": "terminus env:deploy fix-me.live"
}
}
22 changes: 22 additions & 0 deletions docs/troubleshooting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Troubleshooting

## Outline

- [Pulling Files and Database from Pantheon Test Environment](pulling-files-and-database-from-pantheon-test-environment)

## Pulling Files and Database from Pantheon Test Environment

Running this command:

```
lando pull --database=test --files=test --code=none
```

causes this error:

```
Notice: Undefined index: X-Pantheon-Styx-Hostname in /var/www/html/vendor/pantheon-systems/terminus/src/Models/Environment.php on line 851
[error] Pantheon headers missing, which is not quite right.
```

The `test` enviroment has not been created. Dev needs promoted first before the files or database can be pulled from it.
1 change: 1 addition & 0 deletions web/wp-content/cache