From 681f0e56f86f408335f8f3c4c05549b45b849688 Mon Sep 17 00:00:00 2001 From: Matthew Grasmick Date: Wed, 1 Jun 2016 16:23:52 -0400 Subject: [PATCH] Adding tugboat support. --- .editorconfig | 18 +++++++ README.md | 10 ++-- template/.editorconfig | 6 ++- template/build/core/README.md | 2 +- template/build/core/phing/build.xml | 3 ++ template/build/core/phing/tasks/blt.xml | 23 ++++++++ template/build/core/phing/tasks/ci.xml | 15 ++++++ .../build/core/phing/tasks/local-sync.xml | 10 ++-- template/build/core/phing/tasks/setup.xml | 54 +++++++++++-------- template/drush/drushrc.php | 4 ++ template/scripts/tugboat/Makefile | 8 +++ template/scripts/tugboat/README.md | 48 +++++++++++++++++ template/scripts/tugboat/build.sh | 6 +++ template/scripts/tugboat/init.sh | 14 +++++ template/scripts/tugboat/install-node.sh | 27 ++++++++++ .../tugboat/tugboat.drushrc.aliases.php | 6 +++ template/scripts/tugboat/update.sh | 8 +++ 17 files changed, 226 insertions(+), 36 deletions(-) create mode 100644 .editorconfig create mode 100644 template/build/core/phing/tasks/blt.xml create mode 100644 template/scripts/tugboat/Makefile create mode 100644 template/scripts/tugboat/README.md create mode 100755 template/scripts/tugboat/build.sh create mode 100755 template/scripts/tugboat/init.sh create mode 100755 template/scripts/tugboat/install-node.sh create mode 100644 template/scripts/tugboat/tugboat.drushrc.aliases.php create mode 100755 template/scripts/tugboat/update.sh diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..2a54f9895 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,18 @@ +# Drupal editor configuration normalization +# @see http://editorconfig.org/ + +# This is the top-most .editorconfig file; do not search in parent directories. +root = true + +# All files. +[*] +end_of_line = LF +indent_style = space +indent_size = 2 +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +# Tab indentation (no size specified) +[Makefile] +indent_style = tab diff --git a/README.md b/README.md index 551222434..7c09da135 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Follow the instructions in [INSTALL.md](INSTALL.md) to generate a new project us "How do I pull down upstream changes from BLT to my BLT-generated project?" -This is a popular question, and it's difficult to answer. +This is a popular question, and it's difficult to answer. BLT is designed as a "starter kit" rather than a "distribution". It intentionally began with a "fork it and forget it" approach to updates. This is largely due to the fact that BLT generated files are templates that are meant to be customized, and pulling in upstream updates would wipe out those customizations. @@ -74,7 +74,7 @@ The ideal approach would be to split each of these into a separate, versioned pr As a stopgap, you can run the following command to pull in upstream updates to specific files and directories in your BLT generated project: -`./blt.sh setup:blt:update` +`./blt.sh blt:update` After running, you can review changes via `git diff` and decide what should be committed. @@ -83,9 +83,9 @@ After running, you can review changes via `git diff` and decide what should be c BLT is provided as an open source tool in the hope that it will enabled developers to easily generate new Drupal projects that conform to Acquia Professional Services' best practices. Please feel free to contribute to the project or file issues via the GitHub issue queue. When doing so, please keep the following points in mind: - + * BLT is distributed under the GPLv2 license; WITHOUT ANY WARRANTY. -* The project maintainers make no commitment to respond to support requests, +* The project maintainers make no commitment to respond to support requests, feature requests, or pull requests. * All contributions to BLT will be reviewed for compliance with Drupal Coding Standards and best practices as defined by the project maintainer. @@ -93,5 +93,5 @@ Please feel free to contribute to the project or file issues via the GitHub issu will be prioritized for inclusion. BLT work is currently being tracked in the [BLT GitHub issue queue] -(https://github.com/acquia/blt/issues) and organized via a +(https://github.com/acquia/blt/issues) and organized via a [Waffle.io Kanban Board](https://waffle.io/acquia/blt). diff --git a/template/.editorconfig b/template/.editorconfig index f9249b5d2..2a54f9895 100644 --- a/template/.editorconfig +++ b/template/.editorconfig @@ -11,4 +11,8 @@ indent_style = space indent_size = 2 charset = utf-8 trim_trailing_whitespace = true -insert_final_newline = true \ No newline at end of file +insert_final_newline = true + +# Tab indentation (no size specified) +[Makefile] +indent_style = tab diff --git a/template/build/core/README.md b/template/build/core/README.md index 7b2a2ed74..387815257 100644 --- a/template/build/core/README.md +++ b/template/build/core/README.md @@ -1,7 +1,7 @@ This directory contains the core tasks that ship with BLT. No files in this directory should be customized. You may pull in upstream changes with: - ./blt.sh setup:blt:update + ./blt.sh blt:update Please note that pulling in upstream changes in this way may break your project. In some cases, you will need to change aspects of your project configuration or diff --git a/template/build/core/phing/build.xml b/template/build/core/phing/build.xml index 090bd71fc..e66f9b647 100644 --- a/template/build/core/phing/build.xml +++ b/template/build/core/phing/build.xml @@ -20,6 +20,9 @@ + + + diff --git a/template/build/core/phing/tasks/blt.xml b/template/build/core/phing/tasks/blt.xml new file mode 100644 index 000000000..2d5948ee0 --- /dev/null +++ b/template/build/core/phing/tasks/blt.xml @@ -0,0 +1,23 @@ + + + You may be prompted to trust GitHub's SSL certification and to enter your GitHub password. + If you have two factor authentication enabled for GitHub, you must use an access token in lieu of a password. + GitHub access tokens can be generated here: https://github.com/settings/tokens + + + + + + + + BLT can automatically create a Bash alias to make it easier to run BLT tasks. + This alias may be created in .bash_profile or .bashrc depending on your system architecture. + + + + + + + + + diff --git a/template/build/core/phing/tasks/ci.xml b/template/build/core/phing/tasks/ci.xml index 15f48cd8a..9d9b8964b 100644 --- a/template/build/core/phing/tasks/ci.xml +++ b/template/build/core/phing/tasks/ci.xml @@ -16,4 +16,19 @@ + + + + + + + + + + + + + + + diff --git a/template/build/core/phing/tasks/local-sync.xml b/template/build/core/phing/tasks/local-sync.xml index f10587c61..a0fefeb69 100644 --- a/template/build/core/phing/tasks/local-sync.xml +++ b/template/build/core/phing/tasks/local-sync.xml @@ -22,12 +22,10 @@ - - - - - - + + + + diff --git a/template/build/core/phing/tasks/setup.xml b/template/build/core/phing/tasks/setup.xml index 079fae533..37910f421 100644 --- a/template/build/core/phing/tasks/setup.xml +++ b/template/build/core/phing/tasks/setup.xml @@ -1,7 +1,7 @@ + depends="setup:build:all, setup:drupal:install, blt:alias"> For a full list of available Phing targets, run: ./blt.sh -l @@ -77,10 +77,17 @@ "install_configure_form.update_status_module='array(FALSE,FALSE)'" - - --partial + + + + + + + + + @@ -97,26 +104,27 @@ - - You may be prompted to trust GitHub's SSL certification and to enter your GitHub password. - If you have two factor authentication enabled for GitHub, you must use an access token in lieu of a password. - GitHub access tokens can be generated here: https://github.com/settings/tokens - - - - - - - - BLT can automatically create a Bash alias to make it easier to run BLT tasks. - This alias may be created in .bash_profile or .bashrc depending on your system architecture. - - - - - - - + + + + + + + + + + + + features + + + + drush + + + + + diff --git a/template/drush/drushrc.php b/template/drush/drushrc.php index 66fb35ea4..1d03f085c 100644 --- a/template/drush/drushrc.php +++ b/template/drush/drushrc.php @@ -63,6 +63,10 @@ require __DIR__ . '/../docroot/sites/default/local.drushrc.php'; } +if (getenv('TUGBOAT_URL')) { + $options['uri'] = $_ENV['TUGBOAT_URL']; +} + // Specify the base_url that should be used when generating links # $options['l'] = 'http://example.com/subdir'; diff --git a/template/scripts/tugboat/Makefile b/template/scripts/tugboat/Makefile new file mode 100644 index 000000000..ab9fb7f2b --- /dev/null +++ b/template/scripts/tugboat/Makefile @@ -0,0 +1,8 @@ +tugboat-init: + scripts/tugboat/init.sh + +tugboat-update: + scripts/tugboat/update.sh + +tugboat-build: + scripts/tugboat/build.sh diff --git a/template/scripts/tugboat/README.md b/template/scripts/tugboat/README.md new file mode 100644 index 000000000..557186fd3 --- /dev/null +++ b/template/scripts/tugboat/README.md @@ -0,0 +1,48 @@ +## Setup + +To set up this project with Tugboat, run the following commands from the project root: + +``` +./blt.sh ci:tugboat:init +``` + +## Workflow + +This workflow is for a brand new repository for which a base preview has never been built or committed. + +### Initial Setup +1. Visit `https://dashboard.tugboat.qa/[project]/latest` to access the Base Preview. +2. Initialize the Base Preview, click Actions -> init. +3. Makefile -> tugboat-init is triggered. +4. Commit the Base Preview, click actions -> commit. + +### Dev Workflow +5. Submit a Pull Request via GitHub, feature-branch-1 against master. +6. A new container with a clone of Base Preview is created for the PR. +8. Tugboat merges feature-branch-1 into master in PR Preview. +9. Makefile -> tugboat-build is triggered. +10. Merge Pull Request on GitHub. +11. Tugboat deletes the PR Preview. + +### Updating Base Preview + +12. Visit `https://dashboard.tugboat.qa/[project]/latest` to access the Base Preview. +13. Initialize the Base Preview, click Actions -> update. +14. Makefile -> tugboat-update is triggered. +15. Tugboat commits updated Base Preview. +16. Make manual changes to the Base Preview. +17. Realize that you made mistake. +18. Reset the Base Preview, click Actions -> reset. +19. Base preview is reverted to commit made in step 15 + +## Troubleshooting + +* `Makefile:2: *** missing separator. Stop.` + + This is caused by using spaces rather than tabs in your Makefile. If are using PHPStorm with Drupal Coding Standards configuration, you will need to overcome the automated usage of spaces by installing the [Editorconfig plugin](https://plugins.jetbrains.com/plugin/7294) and creating `.editorconfig` file with the following contents: + + ``` + # Tab indentation (no size specified) + [Makefile] + indent_style = tab +``` diff --git a/template/scripts/tugboat/build.sh b/template/scripts/tugboat/build.sh new file mode 100755 index 000000000..4527aa709 --- /dev/null +++ b/template/scripts/tugboat/build.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) + +# Update current database to reflect the state of the Drupal file system +$DIR/../../bolt.sh ci:update diff --git a/template/scripts/tugboat/init.sh b/template/scripts/tugboat/init.sh new file mode 100755 index 000000000..384f77ec4 --- /dev/null +++ b/template/scripts/tugboat/init.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +DOCROOT=/var/lib/tugboat/docroot + +mysql -h mysql -u tugboat -ptugboat -e 'CREATE DATABASE drupal;' +composer selfupdate +composer install + +# Install nvm and specified nodejs version. +$DIR/install-node.sh 4.4.1 + + +$DIR/../../bolt.sh ci:setup diff --git a/template/scripts/tugboat/install-node.sh b/template/scripts/tugboat/install-node.sh new file mode 100755 index 000000000..cae8c6927 --- /dev/null +++ b/template/scripts/tugboat/install-node.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +if [ $# -ne 1 ]; then + echo $0: usage: install-node.sh 4.4.1 + exit 1 +fi + +if [ ! -d "$HOME/.nvm" ]; then + echo "Downloading and installing nvm" + curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh | bash +fi + +NODE_VERSION=$1 +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm +if [[ $(nvm ls $NODE_VERSION | grep "N/A") ]]; then + echo "Downloading and installing node version $NODE_VERSION" + nvm download $NODE_VERSION + nvm install $NODE_VERSION +fi + +# Sets version of node in .node-version so that +# it can be picked up by tools like avn. +echo $NODE_VERSION > .node-version + +echo "Please run the following command": +echo "source ~/.bashrc && nvm use --delete-prefix $NODE_VERSION" diff --git a/template/scripts/tugboat/tugboat.drushrc.aliases.php b/template/scripts/tugboat/tugboat.drushrc.aliases.php new file mode 100644 index 000000000..cd9fb1e8b --- /dev/null +++ b/template/scripts/tugboat/tugboat.drushrc.aliases.php @@ -0,0 +1,6 @@ + $_ENV['TUGBOAT_URL'], + 'root' => '/var/lib/tugboat/docroot', +); diff --git a/template/scripts/tugboat/update.sh b/template/scripts/tugboat/update.sh new file mode 100755 index 000000000..0fe898e0a --- /dev/null +++ b/template/scripts/tugboat/update.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +# Import config +cd /var/lib/tugboat/docroot +chown -R www-data sites/default/files + +# Update current database to reflect the state of the Drupal file system +$DIR/../../bolt.sh ci:update