From 3e34ad5485bf73a091d3a68cca895e751c90a8c8 Mon Sep 17 00:00:00 2001 From: Mat Brady Date: Wed, 8 Jul 2020 15:03:34 -0400 Subject: [PATCH 1/3] threespot specific modifications --- .circleci/config.yml | 69 +++++++++++++++---- .tool-versions | 1 + README.template.md | 147 ++++++++++++++++++++++++++++++++++++++++ composer.json | 8 ++- docs/troubleshooting.md | 22 ++++++ 5 files changed, 230 insertions(+), 17 deletions(-) create mode 100644 .tool-versions create mode 100644 README.template.md create mode 100644 docs/troubleshooting.md diff --git a/.circleci/config.yml b/.circleci/config.yml index 5c13141d..0a9d052c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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: @@ -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: @@ -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: diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 00000000..d5c42e29 --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +nodejs 10.21.0 diff --git a/README.template.md b/README.template.md new file mode 100644 index 00000000..8cf24185 --- /dev/null +++ b/README.template.md @@ -0,0 +1,147 @@ +# FIXME WordPress + +[![Dev Site fix-me](https://img.shields.io/badge/site-fix_me-blue.svg)](http://dev-fix-me.pantheonsite.io/) +[![Dashboard fix-me](https://img.shields.io/badge/dashboard-fix_me-yellow.svg)](https://dashboard.pantheon.io/sites/FIXME#dev/code) +[![CircleCI](https://circleci.com/gh/Threespot/fix-me.svg?style=shield&circle-token=94d0633ad856a188c8cf3582fcc8f259269f74f9)](https://circleci.com/gh/Threespot/fix-me) + +## 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 Control + C + +### 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 +``` \ No newline at end of file diff --git a/composer.json b/composer.json index 0559b6af..969d561a 100644 --- a/composer.json +++ b/composer.json @@ -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": [ @@ -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" } } diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md new file mode 100644 index 00000000..66cfc0f3 --- /dev/null +++ b/docs/troubleshooting.md @@ -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. \ No newline at end of file From 1f26f91489a1e0eae28759ba92903cf417aa64a8 Mon Sep 17 00:00:00 2001 From: Mat Brady Date: Wed, 8 Jul 2020 15:24:49 -0400 Subject: [PATCH 2/3] remove duplicate readme title and badges --- README.template.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/README.template.md b/README.template.md index 8cf24185..2fa9a955 100644 --- a/README.template.md +++ b/README.template.md @@ -1,9 +1,3 @@ -# FIXME WordPress - -[![Dev Site fix-me](https://img.shields.io/badge/site-fix_me-blue.svg)](http://dev-fix-me.pantheonsite.io/) -[![Dashboard fix-me](https://img.shields.io/badge/dashboard-fix_me-yellow.svg)](https://dashboard.pantheon.io/sites/FIXME#dev/code) -[![CircleCI](https://circleci.com/gh/Threespot/fix-me.svg?style=shield&circle-token=94d0633ad856a188c8cf3582fcc8f259269f74f9)](https://circleci.com/gh/Threespot/fix-me) - ## Outline - [Pantheon Environments](#pantheon-environments) From 09bdacec03d817ca506783a7f9ec978406cff1c6 Mon Sep 17 00:00:00 2001 From: Mat Brady Date: Fri, 20 May 2022 12:05:20 -0400 Subject: [PATCH 3/3] move and symlink cache --- .gitignore | 1 + web/wp-content/cache | 1 + 2 files changed, 2 insertions(+) create mode 120000 web/wp-content/cache diff --git a/.gitignore b/.gitignore index 61bfbf58..6248bf57 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/web/wp-content/cache b/web/wp-content/cache new file mode 120000 index 00000000..29c104b8 --- /dev/null +++ b/web/wp-content/cache @@ -0,0 +1 @@ +uploads/cache \ No newline at end of file