From 9a45a66f70827a870e8ed583970d6b0ee6704bfd Mon Sep 17 00:00:00 2001 From: Adam Ross Date: Fri, 16 Mar 2018 07:28:57 -0700 Subject: [PATCH] Initial commit of rig project create example. --- rig-project-create-drupal/.editorconfig | 12 + rig-project-create-drupal/.eslintignore | 19 + rig-project-create-drupal/.eslintrc | 29 ++ rig-project-create-drupal/.gitignore | 28 ++ rig-project-create-drupal/.yo-rc.json | 32 ++ rig-project-create-drupal/CONTRIBUTING.md | 148 ++++++++ rig-project-create-drupal/Gruntconfig.json | 58 +++ rig-project-create-drupal/Gruntfile.js | 11 + rig-project-create-drupal/README.md | 57 +++ rig-project-create-drupal/TODOS.md | 44 +++ rig-project-create-drupal/bin/db-export.sh | 32 ++ rig-project-create-drupal/bin/doctor.sh | 137 ++++++++ .../bin/features-health.sh | 22 ++ rig-project-create-drupal/bin/fix-perms.sh | 24 ++ rig-project-create-drupal/bin/framework.sh | 147 ++++++++ rig-project-create-drupal/bin/grunt/docker.js | 22 ++ .../bin/grunt/fetch-db.js | 47 +++ rig-project-create-drupal/bin/post-install.sh | 21 ++ rig-project-create-drupal/bin/pre-install.sh | 29 ++ rig-project-create-drupal/bin/rebuild.sh | 5 + rig-project-create-drupal/bin/seed-users.sh | 14 + rig-project-create-drupal/bin/start.sh | 14 + .../bin/update-scanner.sh | 23 ++ rig-project-create-drupal/build.devcloud.yml | 157 +++++++++ rig-project-create-drupal/build.yml | 160 +++++++++ rig-project-create-drupal/composer.json | 88 +++++ .../docker-compose.override.yml | 25 ++ rig-project-create-drupal/docker-compose.yml | 114 ++++++ rig-project-create-drupal/docs/DEVCLOUD.md | 105 ++++++ rig-project-create-drupal/docs/OUTRIGGER.md | 105 ++++++ rig-project-create-drupal/env/.gitignore | 7 + .../env/jenkins/config.xml | 198 +++++++++++ .../env/jenkins/jobs/ci/config.xml | 317 +++++++++++++++++ .../env/jenkins/jobs/cron-dev/config.xml | 64 ++++ .../env/jenkins/jobs/cron-local/config.xml | 64 ++++ .../env/jenkins/jobs/cron-qa/config.xml | 64 ++++ .../env/jenkins/jobs/cron-review/config.xml | 64 ++++ .../env/jenkins/jobs/deploy-dev/config.xml | 329 ++++++++++++++++++ .../env/jenkins/jobs/deploy-local/config.xml | 323 +++++++++++++++++ .../env/jenkins/jobs/deploy-qa/config.xml | 323 +++++++++++++++++ .../env/jenkins/jobs/deploy-review/config.xml | 323 +++++++++++++++++ .../env/jenkins/jobs/dev-support/config.xml | 125 +++++++ .../jobs/jenkins-test-default/config.xml | 27 ++ .../jobs/jenkins-test-docker/config.xml | 30 ++ .../jenkins/jobs/jenkins-test-fail/config.xml | 47 +++ .../jobs/password-reset-dev/config.xml | 60 ++++ .../jobs/password-reset-local/config.xml | 60 ++++ .../jenkins/jobs/password-reset-qa/config.xml | 60 ++++ .../jobs/password-reset-review/config.xml | 60 ++++ .../env/jenkins/jobs/start-dev/config.xml | 62 ++++ .../env/jenkins/jobs/start-local/config.xml | 62 ++++ .../env/jenkins/jobs/start-qa/config.xml | 62 ++++ .../env/jenkins/jobs/start-review/config.xml | 62 ++++ .../env/jenkins/jobs/stop-dev/config.xml | 62 ++++ .../env/jenkins/jobs/stop-local/config.xml | 62 ++++ .../env/jenkins/jobs/stop-qa/config.xml | 62 ++++ .../env/jenkins/jobs/stop-review/config.xml | 62 ++++ rig-project-create-drupal/jenkins.yml | 26 ++ rig-project-create-drupal/outrigger.yml | 130 +++++++ rig-project-create-drupal/package.json | 20 ++ rig-project-create-drupal/phpmd.xml | 22 ++ .../src/libraries/.gitkeep | 0 .../src/modules/.gitkeep | 0 .../src/profiles/.gitkeep | 0 .../src/sites/default/.gitkeep | 0 .../src/sites/settings.common.php | 36 ++ rig-project-create-drupal/src/static/.gitkeep | 0 rig-project-create-drupal/src/themes/.gitkeep | 0 rig-project-create-drupal/test/behat.yml | 26 ++ 69 files changed, 5030 insertions(+) create mode 100644 rig-project-create-drupal/.editorconfig create mode 100644 rig-project-create-drupal/.eslintignore create mode 100644 rig-project-create-drupal/.eslintrc create mode 100644 rig-project-create-drupal/.gitignore create mode 100644 rig-project-create-drupal/.yo-rc.json create mode 100644 rig-project-create-drupal/CONTRIBUTING.md create mode 100644 rig-project-create-drupal/Gruntconfig.json create mode 100644 rig-project-create-drupal/Gruntfile.js create mode 100644 rig-project-create-drupal/README.md create mode 100644 rig-project-create-drupal/TODOS.md create mode 100755 rig-project-create-drupal/bin/db-export.sh create mode 100755 rig-project-create-drupal/bin/doctor.sh create mode 100755 rig-project-create-drupal/bin/features-health.sh create mode 100755 rig-project-create-drupal/bin/fix-perms.sh create mode 100644 rig-project-create-drupal/bin/framework.sh create mode 100644 rig-project-create-drupal/bin/grunt/docker.js create mode 100644 rig-project-create-drupal/bin/grunt/fetch-db.js create mode 100644 rig-project-create-drupal/bin/post-install.sh create mode 100755 rig-project-create-drupal/bin/pre-install.sh create mode 100755 rig-project-create-drupal/bin/rebuild.sh create mode 100755 rig-project-create-drupal/bin/seed-users.sh create mode 100755 rig-project-create-drupal/bin/start.sh create mode 100755 rig-project-create-drupal/bin/update-scanner.sh create mode 100644 rig-project-create-drupal/build.devcloud.yml create mode 100644 rig-project-create-drupal/build.yml create mode 100644 rig-project-create-drupal/composer.json create mode 100644 rig-project-create-drupal/docker-compose.override.yml create mode 100644 rig-project-create-drupal/docker-compose.yml create mode 100644 rig-project-create-drupal/docs/DEVCLOUD.md create mode 100644 rig-project-create-drupal/docs/OUTRIGGER.md create mode 100644 rig-project-create-drupal/env/.gitignore create mode 100644 rig-project-create-drupal/env/jenkins/config.xml create mode 100644 rig-project-create-drupal/env/jenkins/jobs/ci/config.xml create mode 100644 rig-project-create-drupal/env/jenkins/jobs/cron-dev/config.xml create mode 100644 rig-project-create-drupal/env/jenkins/jobs/cron-local/config.xml create mode 100644 rig-project-create-drupal/env/jenkins/jobs/cron-qa/config.xml create mode 100644 rig-project-create-drupal/env/jenkins/jobs/cron-review/config.xml create mode 100644 rig-project-create-drupal/env/jenkins/jobs/deploy-dev/config.xml create mode 100644 rig-project-create-drupal/env/jenkins/jobs/deploy-local/config.xml create mode 100644 rig-project-create-drupal/env/jenkins/jobs/deploy-qa/config.xml create mode 100644 rig-project-create-drupal/env/jenkins/jobs/deploy-review/config.xml create mode 100644 rig-project-create-drupal/env/jenkins/jobs/dev-support/config.xml create mode 100644 rig-project-create-drupal/env/jenkins/jobs/jenkins-test-default/config.xml create mode 100644 rig-project-create-drupal/env/jenkins/jobs/jenkins-test-docker/config.xml create mode 100644 rig-project-create-drupal/env/jenkins/jobs/jenkins-test-fail/config.xml create mode 100644 rig-project-create-drupal/env/jenkins/jobs/password-reset-dev/config.xml create mode 100644 rig-project-create-drupal/env/jenkins/jobs/password-reset-local/config.xml create mode 100644 rig-project-create-drupal/env/jenkins/jobs/password-reset-qa/config.xml create mode 100644 rig-project-create-drupal/env/jenkins/jobs/password-reset-review/config.xml create mode 100644 rig-project-create-drupal/env/jenkins/jobs/start-dev/config.xml create mode 100644 rig-project-create-drupal/env/jenkins/jobs/start-local/config.xml create mode 100644 rig-project-create-drupal/env/jenkins/jobs/start-qa/config.xml create mode 100644 rig-project-create-drupal/env/jenkins/jobs/start-review/config.xml create mode 100644 rig-project-create-drupal/env/jenkins/jobs/stop-dev/config.xml create mode 100644 rig-project-create-drupal/env/jenkins/jobs/stop-local/config.xml create mode 100644 rig-project-create-drupal/env/jenkins/jobs/stop-qa/config.xml create mode 100644 rig-project-create-drupal/env/jenkins/jobs/stop-review/config.xml create mode 100644 rig-project-create-drupal/jenkins.yml create mode 100644 rig-project-create-drupal/outrigger.yml create mode 100644 rig-project-create-drupal/package.json create mode 100644 rig-project-create-drupal/phpmd.xml create mode 100644 rig-project-create-drupal/src/libraries/.gitkeep create mode 100644 rig-project-create-drupal/src/modules/.gitkeep create mode 100644 rig-project-create-drupal/src/profiles/.gitkeep create mode 100644 rig-project-create-drupal/src/sites/default/.gitkeep create mode 100644 rig-project-create-drupal/src/sites/settings.common.php create mode 100644 rig-project-create-drupal/src/static/.gitkeep create mode 100644 rig-project-create-drupal/src/themes/.gitkeep create mode 100644 rig-project-create-drupal/test/behat.yml diff --git a/rig-project-create-drupal/.editorconfig b/rig-project-create-drupal/.editorconfig new file mode 100644 index 0000000..5760be5 --- /dev/null +++ b/rig-project-create-drupal/.editorconfig @@ -0,0 +1,12 @@ +# http://editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false diff --git a/rig-project-create-drupal/.eslintignore b/rig-project-create-drupal/.eslintignore new file mode 100644 index 0000000..b82c7db --- /dev/null +++ b/rig-project-create-drupal/.eslintignore @@ -0,0 +1,19 @@ +## +# This file instructs eslint to skip certain directories in it's analysis. +# +# It is not needed by grunt-drupal-tasks but is intended to make direct use +# of eslint more effective. +# +# @see http://eslint.org/docs/user-guide/configuring.html +## + +# node_modules ignored by default + +# Ignore composer and bundler managed dependencies +vendor/**/* + +# Ignore generated files and upstream dependencies via Drush Make +build/**/* + +# Ignore JS in the Drupal files directory such as aggregations. +src/sites/**/files/**/*.js diff --git a/rig-project-create-drupal/.eslintrc b/rig-project-create-drupal/.eslintrc new file mode 100644 index 0000000..e7aac39 --- /dev/null +++ b/rig-project-create-drupal/.eslintrc @@ -0,0 +1,29 @@ +{ + "env": { + "browser": true + }, + "globals": { + "Drupal": true, + "jQuery": true, + "tinyMCE": true + }, + "rules": { + "eqeqeq": [2, "smart"], + "guard-for-in": 2, + "no-undef": 2, + //"no-unused-vars": [2, {"vars": "local", "args": "none"}], + "no-unused-vars": 0, + "strict": 0, + "new-cap": 0, + "quotes": 0, + "camelcase": 0, + "no-underscore-dangle": 0, + "no-new": 0, + "no-alert": 0, + "no-use-before-define": 0, + "consistent-return": 0, + "no-constant-condition": 0, + "comma-dangle" : 2, + "no-catch-shadow" : 2 + } +} diff --git a/rig-project-create-drupal/.gitignore b/rig-project-create-drupal/.gitignore new file mode 100644 index 0000000..09fa55b --- /dev/null +++ b/rig-project-create-drupal/.gitignore @@ -0,0 +1,28 @@ +# Files produced by bad patch & diff runs +*~*~ +*.rej +*.diff +*.orig +interdiff*.txt + +# Local caches. +.sass-cache + +# IDE artifacts +*~ +\#*\# +*.swp +.DS* +.project +.idea + +# Upstream dependencies. +vendor +node_modules +.bundle + +# Build output +/build + +# Site Content +/src/sites/*/files diff --git a/rig-project-create-drupal/.yo-rc.json b/rig-project-create-drupal/.yo-rc.json new file mode 100644 index 0000000..d91b046 --- /dev/null +++ b/rig-project-create-drupal/.yo-rc.json @@ -0,0 +1,32 @@ +{ + "generator-outrigger-drupal": { + "skipWelcome": true, + "skipGoodbye": true, + "insight": false, + "skipInstall": true, + "skip-install": true, + "namespace": "outrigger-drupal:app", + "_": [], + "skip-cache": false, + "projectName": "projectname", + "projectDescription": "Demo of 'rig project create' output with most features enabled.", + "drupalDistro": "octane", + "drupalDistroVersion": "8.x", + "hosting": "outrigger", + "webserver": "apache", + "cacheInternal": "redis", + "proxyCache": "varnish", + "mail": "mailhog", + "domain": "projectname", + "gitRepoUrl": "git@bitbucket.org:phase2tech/projectname.git", + "useCloud": true, + "cloudHost": "hosting.example.net", + "environments": [ + "dev", + "qa", + "review" + ], + "flowdockApiKey": "", + "usePLS": false + } +} \ No newline at end of file diff --git a/rig-project-create-drupal/CONTRIBUTING.md b/rig-project-create-drupal/CONTRIBUTING.md new file mode 100644 index 0000000..bb71474 --- /dev/null +++ b/rig-project-create-drupal/CONTRIBUTING.md @@ -0,0 +1,148 @@ +This extension to the README is necessary for all developers working on the +projectname codebase. + +## Build Process + +As described in the README, the many steps of assembling, installing, and managing +the site have been combined into a few simple commands using +[Grunt Drupal Tasks](https://github.com/phase2/grunt-drupal-tasks). + +You can see a list of all available actions by running +```bash +docker-compose -f build.yml run grunt help +``` + +### Build the Codebase + +Our build process downloads all upstream dependencies of the site to assemble +a functional docroot. + + * Create `build/html` directory + * Validate custom code with static analysis checks + * Download operational dependencies + * Set up symlinks from docroot to custom code + +### Role of Each Dependency Manager + +This action cuts across several different *dependency managers*, which are each +used to control the use of different types of external, Open Source libraries. +The table below illustrates how the downloaded libraries and modules are used +by the system. + +| Tool | Config Files | Development & QA | Build & Deployment | Production | +| ---------- | ------------- | :--------------: | :----------------: | :--------: | +| Composer | composer.json | ✔ | ✔ | ✗ | +| npm | package.json | ✔ | ✔ | ✗ | + +### When To Run + +* **First Run/Kitchen Sink**: `rig project setup` +* **After Merging Changes from Upstream**: `docker-compose -f build.yml run grunt` +* **Before Final Feature Branch Push**: `docker-compose -f build.yml run grunt validate` +* **Starting a New Feature:** + * `git checkout master && git checkout -b ` + * `docker-compose -f build.yml run grunt` + * Fetch a Fresh Database (see below) + * `docker-compose -f build.yml run grunt install` + * Run with `--no-db-load` to force a clean reinstall. + +If `package.json` has changes, you may need to re-run `npm install --force`. + +### Installation Practices + +#### Install from Scratch + +This command guarantees a clean site installation. + +```bash +docker-compose -f build.yml run grunt install --no-db-load +``` + +#### Install from Scratch with Database Fallback + +If a database is found in `/opt/backups/latest.sql.gz`, it will be loaded. +Otherwise a fresh site installation will be triggered. + +```bash +docker-compose -f build.yml run grunt install --no-db-load +``` + +#### Install from a Prepared Database + +To accelerate development, the Phase2 project infrastructure prepares a nightly database on the latest code. To retrieve it and re-install the site run the following command: + +``` +docker-compose -f build.yml run cli sh -c "grunt fetch-db && grunt install" +``` + +Sometimes the above command fails because of quirks with Docker's access to +external DNS. In that case, run as follows: + +``` +grunt fetch-db --db-path=./build/backups/latest.sql.gz +docker-compose -f build.yml run grunt install +``` + +This is subject to setting up Node.js and grunt for use in your host machine. + +##### fetch-db Options + +* Config **project.db**: The default download destination. +* Config **project.backups.url**: Base URL for remote backups. +* Config **project.backups.env**: Default value for the environment argument. +* Option **--db-path**: Override the download location for the database archive. Must include filename. +* Argument **Environment**: May be run with a grunt argument as `grunt fetch-db:qa`. This allows targeting different backup environments. This value is directly appended to the backup URL. + +## Git Practices + +* Git Flow conventions are in use. + * Changes committed to `master` should be ready for production. + * Change committed to `develop` should be technically approved and believed complete by the developer. + * All work should be done in feature branches, named such as `feature/KEY-123/short-description` and `bug/KEY-246/short-description`. + * For more information see http://nvie.com/posts/a-successful-git-branching-model/ +* Commit messages should always begin with `KEY-123: `, then follow with 20-60 characters explaining the change. This prefix to the commit message ties the commit back to +a specific JIRA issue, similar to how Drupal project commits should always be prefixed `Issue #123 `. +* Never commit CSS or other assets generated by the build process. + +All changes should be submitted for code review using a Pull Request. Pull Requests should target the `develop` branch. If you submit the PR before you've done end-to-end testing and code validation on your change include `[WIP]` in the PR title so reviewers know it's not ready for merge. + +## Coding Practices + +Development will follow these best practices. + +### Code Structure and Naming Things + +* [Drupal coding](http://www.drupal.org/coding-standards) & [commenting](http://www.drupal.org/node/1354) standards +* Commented out code is technical debt and should be avoided. + * Must always have comments describing + * the change the code would create + * the condition in which the code is uncommented + * the condition in which the code is removed + * All developers are responsible for reviewing this each time they come across the code in a new development task. +* Correct spelling when naming things. CamelCase and snake_case are okay, but inconsistent abbreviations, acronyms, and word concatenation without separators is not. + +Some of these guidelines are verified by the `grunt phpcs` task, which is run as part of `grunt validate`, in turn a step of the overall build process. + +### Code Layout and Scope + +* All markup should be defined in templates. +* API functions should be maintained at the bottom of the `.module` file or kept in a separate include file. In Drupal 8, helper functions should be wrapped in classes. +* Form callbacks should contain the minimum code to interact with the Form system, otherwise they should call API functions for options lists, validation logic, and submit handling. +* Menu callbacks should always be in a separate file from `.module`. +* hooks in the .module file should be implemented in the following thematic order: + * bootstrapping the site + * defining menu routes + * defining permissions, access control, and authentication + * manipulating data structures + * content display + +## How to Add... + +### A New Content Type + +* Who should sign off on requirements? +* Are update hooks needed? +* Are there any constraints on what can be done? +* Any specific field types or form elements preferred? +* Any existing fields to be reused when possible? +* What kinds of automated testing should be created? diff --git a/rig-project-create-drupal/Gruntconfig.json b/rig-project-create-drupal/Gruntconfig.json new file mode 100644 index 0000000..bcb54ab --- /dev/null +++ b/rig-project-create-drupal/Gruntconfig.json @@ -0,0 +1,58 @@ +{ + "srcPaths": { + "drupal": "src" + }, + "domain": "www.projectname.vm", + "packages": { + "srcFiles": [ + "!sites/*/files/**", + "!xmlrpc.php", + "!modules/php/*" + ], + "projFiles": [ + "README*", + "bin/**", + "hooks/**", + "src/*.make", + "vendor/**", + "composer.*" + ], + "dest": { + "docroot": "build/html", + "devResources": "" + } + }, + "phpcs": { + "path": "vendor/bin/phpcs" + }, + "phpmd": { + "path": "vendor/bin/phpmd" + }, + "drush": { + "cmd": "vendor/bin/drush" + }, + "behat": { + "flags": "--tags ~@wip" + }, + "eslint": true, + "scripts": { + "update": "<%= config.drush.cmd %> <%= config.alias %> features-revert-all -yv", + "pre-install": "bash bin/pre-install.sh", + "post-install": "bash bin/post-install.sh", + "cache-clear": "<%= config.drush.cmd %> <%= config.alias %> cache-rebuild", + "seed-users": "bash bin/seed-users.sh" + }, + "project": { + "profile": "lightning", + "db": "/opt/backups/latest.sql.gz", + "backups": { + "url": "http://backups.hosting.example.net/projectname", + "env": "int" + } + }, + "generated": { + "name": "generator-gadget", + "version": "1.2.0" + }, + "alias": "@projectname" +} diff --git a/rig-project-create-drupal/Gruntfile.js b/rig-project-create-drupal/Gruntfile.js new file mode 100644 index 0000000..08000e5 --- /dev/null +++ b/rig-project-create-drupal/Gruntfile.js @@ -0,0 +1,11 @@ +module.exports = function(grunt) { + + // Load all plugins and tasks defined by the grunt-drupal-tasks package. + require('grunt-drupal-tasks')(grunt); + + // If bin/grunt exists, load task files. + if (grunt.file.exists(__dirname + '/bin/grunt')) { + grunt.loadTasks(__dirname + '/bin/grunt'); + } + +}; diff --git a/rig-project-create-drupal/README.md b/rig-project-create-drupal/README.md new file mode 100644 index 0000000..ba9aa5e --- /dev/null +++ b/rig-project-create-drupal/README.md @@ -0,0 +1,57 @@ +# Projectname + +> Demo of 'rig project create' output with most features enabled. + + + + + +## About This Repository + +This codebase is maintained in a minimal working repository containing custom code +and manifests of upstream dependencies. [Grunt-Drupal-Tasks](https://github.com/phase2/grunt-drupal-tasks) +(a Node.js tool based on the popular Grunt task-runner) is used for development +and operational management of the application code. A build process downloads and assembles all dependencies for deployment into the webserver. + +## Docker-based Development + +* See [CONTRIBUTING.md](./CONTRIBUTING.md) for policies and practices on making changes to the codebase. +* See [OUTRIGGER.md](./docs/OUTRIGGER.md) for how to set up your local environment the Outrigger way. +* See [DEVCLOUD.md](./docs/DEVCLOUD.md) for Phase2's CI process and management of dev/testing environments. +* See [TODOS.md](./TODOS.md) for pending changes in the repository that developers should know about. + +### Troubleshooting + +Thank you for helping the project with a problem. For local issues please read +the [OUTRIGGER.md](./docs/OUTRIGGER.md) documentation. For Phase2 Dev Cloud issues please read [DEVCLOUD.md](./docs/DEVCLOUD.md). + +## Running without Docker + +### Requirements + +* [Node.js](https://nodejs.com) v6 via a [package manager](https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager) or [standalone installer](http://nodejs.org/download/) +* [Grunt](https://gruntjs.org) (`npm install -g grunt-cli`) +* PHP 5.6 +* [Composer](https://getcomposer.org/download) (e.g. `brew install composer`) + +### Installation + +* **`npm install`:** Retrieve build system dependencies. +* **`grunt`:** Validate and assemble functional Drupal codebase. +* **`drush si`:** From inside the Drupal docroot. + +### Get Oriented + +* To learn about available commands run `grunt help`. + +## Scaffolded with Generators + +Initial generation of this project's code structure was built with [Yo Outrigger Drupal](https://github.com/phase2/generator-outrigger-drupal) +and related code-generation projects. + +To refresh your project with our latest practices, update your local copy of this +tool, and run `yo outrigger-drupal --replay --force`. Do not forgot to carefully inspect each +change for compatibility with your ongoing project before committing. + +The `--replay` option pulls configuration values for the generator from *.yo-rc.json*, +where they can be reviewed or edited by experts at any time. diff --git a/rig-project-create-drupal/TODOS.md b/rig-project-create-drupal/TODOS.md new file mode 100644 index 0000000..47d5b07 --- /dev/null +++ b/rig-project-create-drupal/TODOS.md @@ -0,0 +1,44 @@ +# TODOS + +This file contains outstanding tasks that someone on the project team must +complete. As items are accomplished, they can be removed from this file. + +(This is a good place to record information about long-term technical debt.) + +* [ ] Project Codebase Ownership: The project team owns all the code in this repo. Assign a team member to perform the following: + * Read all the generated documentation. + * README.md, CONTRIBUTING.md, docs/* + * Be familiar with the configuration for Grunt, Docker, Outrigger, Drupal, and Drush + * Gruntconfig.json + * docker-compose.yml, docker-compose.override.yml, build.yml, build.devcloud.yml, and jenkins.yml + * .outrigger.yml + * src/sites/settings.common.php + * env/build/etc/drush/drushrc.php + * Note all the utility scripts in `./bin` + * Ensure everyone on the team understands what they need to know. + +* [ ] Test the Site Setup: Confirm the build and site installation works. + * Install and start [Outrigger](http://docs.outrigger.sh/). + * Run `docker-compose pull && docker-compose -f build.yml pull` to ensure you have the latest Docker images for local development. + * Run `rig project setup` to confirm the code works and setup your project. + * Move any code generated in src/sites/default/settings.php after the include of src/sites/settings.common.php into the latter file. + * If git can add a file, please add it to the code repository. Your src/sites/default/settings.php file should be committed. + +* [ ] Adapt the Code to the Project: This is only a starting place. + * Modify scripts to suite your needs, or remove scripts you will not use and maintain as it will simply be clutter. + * Rewrite codebase documentation to suite the audience. Make sure future onboarding will work. + +* [ ] Spin up Continuous Integration & Testing Environments: This is specific to Phase2-only infrastructure at this time. + * Ensure the Jenkins jobs have the correct Git URL. (You can correct this by editing .yo-rc.json and running the generator again with `--replay`.) + * Visit your CI Server and [spin up your Jenkins instance](http://build.hosting.example.net/job/ci-start/parambuild/?delay=0sec&NAME=projectname&GIT_URL=git%40bitbucket.org%3Aphase2tech%2Fprojectname.git&GIT_REF=develop). + +* [ ] Configure Email Testing: Add the SMTP module to the project to use MailHog for testing. + * Add the SMTP module to the codebase. + * Enable the module and turn on STMP mail transport at `admin/config/system/smtp`. + * Send a test email using the admin form and confirm mail is routed to the MailHog UI at `mail-` for devcloud, or `mail.projectname.vm:8025` locally. + +* [ ] Engage with the Community + * Report on any changes made to get the environment working, improve documentation, or automate development processes. + * Phase2 staff should join the **#devtools-support** flow to get help. Ask for one-on-one time for troubleshooting or additional coaching. + * Tweet [@outrigger_sh](https://twitter.com/outrigger_sh) with the big ideas. + * Collaborate in issue queues such as [Outrigger Drupal](https://github.com/phase2/generator-outrigger-drupal), [Outrigger Docs](https://github.com/phase2/outrigger-docs), [Rig CLI]((https://github.com/phase2/rig), and [others](https://github.com/search?q=topic%3Aoutrigger+org%3Aphase2&type=Repositories). diff --git a/rig-project-create-drupal/bin/db-export.sh b/rig-project-create-drupal/bin/db-export.sh new file mode 100755 index 0000000..acda2e3 --- /dev/null +++ b/rig-project-create-drupal/bin/db-export.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +## +# Database Export +# +# Sanitize and prepare the database for clean import in other environments. +# +# This script is intended to facilitate Jenkins jobs that export the database, +# especially for backups or local development. Jenkins usage might look like: +# +# > docker-compose -f build.yml run cli bash bin/db-export.sh nightlies/20151027.sql +# +# Arguments +# - Relative path to database export file inside the /opt/backups directory. +## + +# Prepare the destination. +FILE="/opt/backups/$1" +DIR=$(dirname "$FILE") +mkdir -pv "$DIR" + +# Scramble private data. +drush @projectname sql-sanitize -yv +# Ensure first cache clear after db import does not conflict with features export changes. +drush @projectname variable-set features_rebuild_on_flush 0 -y --exact +# Export the file. See /etc/drushrc.php for additional configuration defaults. +drush @projectname sql-dump --gzip --ordered-dump --result-file="$FILE" -yv + +# Maintain a symlink to the most recently generated database export for ease of download. +ln -fsv "./$1.gz" /opt/backups/latest.sql.gz + +# Purge all but the most recent 5 database exports in this directory. +cd $DIR && ls -t | awk 'NR>5' | xargs rm -f diff --git a/rig-project-create-drupal/bin/doctor.sh b/rig-project-create-drupal/bin/doctor.sh new file mode 100755 index 0000000..1d2ab37 --- /dev/null +++ b/rig-project-create-drupal/bin/doctor.sh @@ -0,0 +1,137 @@ +#!/usr/bin/env bash +## +# Doctor +# +# Evaluate the state of the project setup and report on problems. +## + +CALLPATH=`dirname $0` +source "$CALLPATH/framework.sh" + +STATUS=0 + +SUCCESS='echoInfo' +WARNING='echoWarn' +ERROR='echoError' + +# Flag the status of a particular check. +# $1 - Status/Output Function +# $2 - Category +# $3 - Message +flag() { + if [ "$1" == "$ERROR" ]; then + STATUS=1 + fi + echo -en "\t" + $1 "$2 $3\n" +} + +# Assert a command is available. +# $1 - The command +# $2 - Severity on failure. +assertCmd() { + if [ -z $(which $1) ]; then + flag $2 $1 'command not found.' + else + flag $SUCCESS $1 'found' + fi +} + +# Assert presence of a file. +# $1 - Path to File +# $2 - Severity on failure +assertFile() { + if [ -f "$1" ]; then + flag $SUCCESS $1 'found' + else + flag $2 $1 'file not found.' + fi +} + +# Assert presence of a directory. +# $1 - Path to directory +# $2 - Severity on failure +assertDir() { + if [ -d "$1" ]; then + flag $SUCCESS $1 'found' + else + flag $2 $1 'directory not found.' + fi +} + +# Assert a value is truthy. +# $1 - Value, typically the output of a command. +# $2 - Severity on failure +assertOk() { + if [ -z "$1" ]; then + flag $3 $2 "not running" + else + flag $SUCCESS $2 "running" + fi +} + +# Assert two values are equivalent. +# $1 - Value 1 +# $2 - Value 2 +# $3 - Severity on failure +assertEqual() { + if [ "$1" == "$2" ]; then + flag $3 "$1 and $2" "not equal" + else + flag $SUCCESS "$1" "confirmed" + fi +} + +# Assert two values are not equivalent. +# $1 - Value 1 +# $2 - Value 2 +# $3 - Severity on failure +assertNotEqual() { + if [ "$1" != "$2" ]; then + flag $SUCCESS $1 "confirmed" + else + flag $3 "$1 and $2" "equal and should not be" + fi +} + +if [ -z "$1" ] || [ "$1" == 'outrigger' ]; then + heading 'Docker Utilities' + assertCmd 'rig' $WARNING + assertCmd 'docker' $ERROR + assertCmd 'docker-compose' $ERROR + assertCmd 'docker-machine' $ERROR + assertNotEqual $(docker-machine active) 'No active host found' $WARNING +fi + +if [ -z "$1" ] || [ "$1" == 'generator' ]; then + heading 'Code Generated with Yo Outrigger Drupal' + assertDir 'src' $ERROR + assertFile 'package.json' $ERROR + assertFile 'composer.json' $ERROR + assertFile 'docker-compose.yml' $ERROR + assertFile 'build.yml' $ERROR +fi + +if [ -z "$1" ] || [ "$1" == 'requirements' ]; then + heading 'Project Requirements Met' + assertDir 'node_modules' $ERROR +fi + +if [ -z "$1" ] || [ "$1" == 'gdt' ]; then + heading 'Code Generated by Grunt Drupal Tasks Build Process' + assertDir 'build' $ERROR + assertDir 'build/html' $ERROR + assertFile 'build/html/index.php' $ERROR +fi + +if [ -z "$1" ] || [ "$1" == 'unison' ]; then + heading 'Unison File Sync Functionality' + docker-compose -f build.yml run base ls /var/www/src > /dev/null 2>&1 + assertOk $? 'unison file sync/volume bind mount' $ERROR +fi + +if [ "$STATUS" -gt 0 ]; then + echo 'Run "rig doctor" to address general Docker problems.' +fi + +exit $STATUS diff --git a/rig-project-create-drupal/bin/features-health.sh b/rig-project-create-drupal/bin/features-health.sh new file mode 100755 index 0000000..548c647 --- /dev/null +++ b/rig-project-create-drupal/bin/features-health.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +## +# Features Health Scanner +# +# Lists features and checks them for errors states: overridden, needs review, or +# conflict. Any such feature is counted as "unhleathy". If any features are +# unhealthy the script will return an error. +## + +DATA=`drush @projectname features-list --status=enabled` +echo "$DATA" +DATA=`echo "$DATA" | egrep -w "Overridden|Needs review|Conflicts"` +# remove leading whitespace characters +DATA="${DATA#"${DATA%%[![:space:]]*}"}" +# remove trailing whitespace characters +DATA="${DATA%"${DATA##*[![:space:]]}"}" +if [ "$DATA" ]; then + echo "===================================" + echo $(echo "$DATA" | wc -l) features need attention! + exit 1 +fi +exit 0 diff --git a/rig-project-create-drupal/bin/fix-perms.sh b/rig-project-create-drupal/bin/fix-perms.sh new file mode 100755 index 0000000..832c0d7 --- /dev/null +++ b/rig-project-create-drupal/bin/fix-perms.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +## +# Fix File Permissions +# +# Some of the file permissions are broken or mis-aligned as a result +# of the various Docker and filesystem layers. +# +# Paths used align with the volume mappings in the docker-compose +# and build configuration files. +## + +echo "Fixing up file permissions for development..." +echo "You can run this via 'docker-compose exec www /var/www/bin/fix-perms.sh'" +set -x +# Ensure the default private files directory is created. +# This was not automatically done via drush-based site install in Drupal 7. +mkdir -p /var/www/src/sites/default/files/private +# Ensure Apache manages the files directory. +chown -R apache:apache /var/www/src/sites/default/files +chmod 755 /var/www/src/sites/default/files +# Restore write access to Drupal settings directory after site install. +# This does not change the settings.php file itself, but helps avoid +# issues such as changes to settings across git branches. +chmod 755 /var/www/src/sites/default diff --git a/rig-project-create-drupal/bin/framework.sh b/rig-project-create-drupal/bin/framework.sh new file mode 100644 index 0000000..2e51d31 --- /dev/null +++ b/rig-project-create-drupal/bin/framework.sh @@ -0,0 +1,147 @@ +#!/usr/bin/env bash +## +# Framework.Shell +# +# Library of BASH helper functions. +## + +# Wrap commands for eval to conditionally output rather than execute. +# Requires an exported $NOOP variable. +cmd() { + echoInfo "$1\n" + if [ $NOOP != 1 ]; then + eval $1 + fi +} + +## +# Fancy output from earlier version of devtools. +# https://bitbucket.org/phase2tech/_devtools_vm +# +# This is a collection of variables and functions to make printing +# attractive output in our shell scripts easier for everyone. +# +# Sample usage: +# +# 1) To print an info message with success confirmation +# example: [INFO] Checking something ... OK +# +# echoInfo "Checking something ... \t" +# [add your somthing commands here] +# echoSuccess "OK\n" +# +# 2) To print an info message with failure confirmation +# example: [INFO] Checking something ... FAIL +# Something is screwed up +# +# echoInfo "Checking something ... \t" +# [add your somthing commands here] +# echoFail "Something is screwed up\n" +# +# 3) To print a warning: +# example: [WARN] Something is not just right! +# +# echoWarn "Something is just not right! \n" +# +# 4) To have a sub script print out with a bit of style/color (it will be cyan) +# +# outputColor +# [call your scripts] +# resetColor +# +# 5) To print the properties of something +# example: +# [INFO] Configuration: +# +# - Machine Name: dev +# - Shared Folder: /Users +# +# +# echoInfo "Configuration: " +# echo +# echo +# echoProperties "Machine Name: $name" +# echoProperties "Shared Folder: $folder" +## + +Reset='\e[0m'; +Red='\e[0;31m'; +Green='\e[0;32m'; +Yellow='\e[0;33m'; +Blue='\e[1;34m'; +Purple='\e[0;35m'; +Cyan='\e[0;36m'; + +Bold='\033[1m'; +Normal='\033[0m'; +Underline='\033[4m'; + +# @info: Prints error messages +# @args: error-message +echoError () { + printf "${Red}[ERROR] ${Reset}$1" +} + +# @info: Prints error messages +# @args: error-message +echoFail () { + printf "${Red}FAIL\n\n$1 ${Reset}" +} + +# @info: Prints warning messages +# @args: warning-message +echoWarn () { + printf "${Yellow}[WARN] ${Reset}$1" +} + +# @info: Prints success messages +# @args: success-message +echoSuccess () { + printf "${Green}$1${Reset}" +} + +# @info: Prints check messages +# @args: success-message +echoInfo () { + printf "${Blue}[INFO] ${Reset}$1" +} + +# @info: Prints property messages +# @args: property-message +echoProperties () { + printf "\t${Purple}- $1 \033[0m" +} + +# @info: Change color for subscript output +function outputColor { + printf "${Cyan}" +} + +# @info: Reset terminal color +function resetColor { + printf "${Reset}" +} + +# @info: Bold text +function outputBold { + printf "${Bold}" +} + +# @info: Normal text weight +function resetText { + printf "${Normal}" +} + +# @info: Output text with underline +function outputUnderline { + printf "${Underline}" +} + +# @info: Set a heading +function heading { + outputColor + outputBold + outputUnderline + echo -e "${Bold}$1${Normal}" + resetText +} diff --git a/rig-project-create-drupal/bin/grunt/docker.js b/rig-project-create-drupal/bin/grunt/docker.js new file mode 100644 index 0000000..a10cdee --- /dev/null +++ b/rig-project-create-drupal/bin/grunt/docker.js @@ -0,0 +1,22 @@ +'use strict'; + +/** + * Docker modifications for grunt-drupal-tasks + */ +module.exports = function(grunt) { + + if (!process.env.DOCKER_ENV) { + return; + } + + // If not explicitly set in Gruntconfig.json for the project set it. + // In many cases, grunt-drupal-task configuration cannot be set this way. + // This can be set because it is one of the commands which registers tasks + // in a "late-binding" manner such that it hasn't already copied the config + // into the related grunt plugins. + var cmd = grunt.config.get('config.git.hook-command'); + if (!cmd) { + grunt.config.set('config.git.hook-command', 'docker-compose -f build.yml run --rm grunt'); + } + +} diff --git a/rig-project-create-drupal/bin/grunt/fetch-db.js b/rig-project-create-drupal/bin/grunt/fetch-db.js new file mode 100644 index 0000000..46ed89b --- /dev/null +++ b/rig-project-create-drupal/bin/grunt/fetch-db.js @@ -0,0 +1,47 @@ +/** + * grunt fetch-db + * + * Retrieves the latest database export for the project. + */ + +module.exports = function(grunt) { + grunt.registerTask('fetch-db', 'Fetch a development database export from the CI server.', + function(env) { + grunt.loadNpmTasks('grunt-shell'); + + // If not specified, default to integration environment. + if (!env) { + env = grunt.config('config.project.backups.env'); + } + + // project.db might be unset in projects that want grunt install to do a + // clean install by default. + var dbPath = grunt.option('db-path') || grunt.config('config.project.db') || '/opt/backups/latest.sql.gz'; + + grunt.config.set('shell.fetch-db', { + command: 'curl -vv -f ' + grunt.config('config.project.backups.url') + '/' + env + + '/latest.sql.gz > ' + dbPath + }); + + grunt.config('mkdir.backups', { + options: { + create: [ + '<%= config.buildPaths.build %>/backups' + ] + } + }); + + grunt.task.run([ + 'mkdir:init', + 'mkdir:backups', + 'shell:fetch-db' + ]); + } + ); + + require('grunt-drupal-tasks/lib/help')(grunt).add({ + task: 'fetch-db', + group: 'Operations', + description: 'Retrieve a prepared database for use with "grunt install". May run with grunt fetch-db: to target different datasets.' + }); +} diff --git a/rig-project-create-drupal/bin/post-install.sh b/rig-project-create-drupal/bin/post-install.sh new file mode 100644 index 0000000..ef2be6f --- /dev/null +++ b/rig-project-create-drupal/bin/post-install.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +## +# Post-Install +# +# Take actions after the installation process. +# +# This script is automatically triggered by Grunt after performing the actions +# of `grunt install`. +## + +CALLPATH=$(dirname $0) +if [ -z $CALLPATH ]; then + CALLPATH=. +fi +# Drupal 8 sets the permissions of the default directory such that it is not +# writable causing subsequent installations to fail. Also, when doing an +# install through the build container any files created have incorrect +# ownership for the web container to write to and modify them. +${CALLPATH}/fix-perms.sh + +exit 0 \ No newline at end of file diff --git a/rig-project-create-drupal/bin/pre-install.sh b/rig-project-create-drupal/bin/pre-install.sh new file mode 100755 index 0000000..038c058 --- /dev/null +++ b/rig-project-create-drupal/bin/pre-install.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +## +# Pre-Install +# +# Take actions in between the build process and installation. +# +# Run from root of the code repository. +# +# This script is automatically triggered by Grunt before performing the actions +# of `grunt install`. +## + +if [ ! -f src/sites/default/default.settings.php ]; then + echo "Please run pre-install after successfully building the docroot." + exit 1 +fi + +# Ensure Redis does not hold onto stale data in between site installation runs. +echo "Flush Redis cache with 'FLUSHALL'" +(echo -en "FLUSHALL\r\n"; sleep 1) | nc cache 6379 + +if [ ! -f src/sites/default/settings.php ]; then + cp src/sites/default/default.settings.php src/sites/default/settings.php + echo -e "\nrequire __DIR__ . '/../settings.common.php';" >> src/sites/default/settings.php +else + echo "'src/sites/default/settings.php' already exists." +fi + +exit 0 diff --git a/rig-project-create-drupal/bin/rebuild.sh b/rig-project-create-drupal/bin/rebuild.sh new file mode 100755 index 0000000..72f68fb --- /dev/null +++ b/rig-project-create-drupal/bin/rebuild.sh @@ -0,0 +1,5 @@ +#!/bin/sh +# Script to rebuild site (drush make) +CALLPATH=`dirname $0` + +$CALLPATH/start.sh --update diff --git a/rig-project-create-drupal/bin/seed-users.sh b/rig-project-create-drupal/bin/seed-users.sh new file mode 100755 index 0000000..71cbe4c --- /dev/null +++ b/rig-project-create-drupal/bin/seed-users.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +## +# Seed Users +# +# Creates dummy users for testing. +# +# Run from root of the code repository. +# +# This script is not automatically triggered by Grunt, and must be run/automated +# separately if desired in a given environment. +## + +drush @projectname user-create "projectnameadmin" --password="admin1" --mail="projectnameadmin@example.com" +drush @projectname user-add-role "administrator" "projectnameadmin" diff --git a/rig-project-create-drupal/bin/start.sh b/rig-project-create-drupal/bin/start.sh new file mode 100755 index 0000000..b7055d2 --- /dev/null +++ b/rig-project-create-drupal/bin/start.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +## +# Start +# +# This script takes your freshly cloned repository and takes it to a working +# Drupal site hosted in a Docker container stack. +## + +CALLPATH=`dirname $0` +source "$CALLPATH/framework.sh" + +echoWarn "Outrigger Drupal v4 dropped support for the start.sh script utility.\n" +echoWarn "For local development, replace your daily operations with rig project commands.\n" +echoError "Jenkins jobs should re-generated or refactored to use the individual steps.\n" diff --git a/rig-project-create-drupal/bin/update-scanner.sh b/rig-project-create-drupal/bin/update-scanner.sh new file mode 100755 index 0000000..2afa512 --- /dev/null +++ b/rig-project-create-drupal/bin/update-scanner.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +## +# Update Scanner +# +# Uses drush pm-updatestatus to identify those modules that are outdated +# due to regular updates or important security releases. This produces +# clean output that focuses on action items and will cleanly fail so +# Jenkins jobs can report that module health is in an error state. +## + +DATA=`drush @projectname pm-updatestatus 2> /dev/null` +echo "$DATA" +DATA=`echo "$DATA" | grep "available"` +# remove leading whitespace characters +DATA="${DATA#"${DATA%%[![:space:]]*}"}" +# remove trailing whitespace characters +DATA="${DATA%"${DATA##*[![:space:]]}"}" +if [ "$DATA" ]; then + echo "===================================" + echo $(echo "$DATA" | wc -l) packages need updating! + exit 1 +fi +exit 0 diff --git a/rig-project-create-drupal/build.devcloud.yml b/rig-project-create-drupal/build.devcloud.yml new file mode 100644 index 0000000..b4c9b90 --- /dev/null +++ b/rig-project-create-drupal/build.devcloud.yml @@ -0,0 +1,157 @@ +## +# Build and command-line operations containers for Outrigger Cloud hosted Docker environments. +# +# In-line documentation assumes the "Integration" or 'int' environment, in practice +# any environment name can be used. Standard names also include: Development (dev), +# Testing (qa), and Review/Milestone (ms). +# +# "Dev Cloud" is the name of the internal Phase2 development infrastructure. +# +# To ensure this works as expected for multiple environments, both environment +# settings must be carefully respected in *every* command invocation: +# +# * The `DOCKER_ENV` environment variable which is used as a template parameter for +# how this configuration is used. +# * The -p|--project-name option for Docker Compose, which uses the provided name +# in lieu of deriving key Docker namespacing from whatever the current directory +# happens to be named. +# +# @see https://docs.docker.com/compose/reference/overview/ +# @see https://docs.docker.com/compose/compose-file/compose-file-v2/ +## +version: '2.1' + +services: + # Container for starting a cli for build commands + # Usage: DOCKER_ENV=int docker-compose -f build.devcloud.yml -p projectname_int run --rm cli + cli: + extends: + service: operational + command: /bin/bash + + # Container for running composer in the repo root. + # Usage: DOCKER_ENV=int docker-compose -f build.devcloud.yml -p projectname_int run --rm composer + composer: + extends: + service: base + entrypoint: [ "/init", "composer", "--ansi" ] + command: "" + + # Container for running drush in the docroot. + # Usage: DOCKER_ENV=int docker-compose -f build.devcloud.yml -p projectname_int run --rm drush + # Where is a direct drush command like cache-rebuild + drush: + extends: + service: operational + entrypoint: [ "/init", "drush", "@projectname" ] + working_dir: /var/www/build/html + + # Container for running Drupal Console in the docroot. + # Usage: DOCKER_ENV=int docker-compose -f build.devcloud.yml -p projectname_int run --rm drupal + # Where is a direct drupal command like generate + # Note: Only works if the project includes Drupal Console as a composer dependency. + drupal: + extends: + service: operational + entrypoint: [ "/init", "/var/www/vendor/bin/drupal", "--ansi" ] + working_dir: /var/www/build/html + + + # Container for running grunt in the docroot. + # Usage: DOCKER_ENV=int docker-compose -f build.devcloud.yml -p projectname_int run --rm grunt + grunt: + extends: + service: operational + entrypoint: [ "/init", "grunt" ] + + # Container for running PHPUnit tests. + # Usage: docker-compose -f build.yml run --rm phpunit + # E.g. docker-compose -f build.yml run --rm phpunit -c ./core/phpunit.xml.dist ./modules/custom + phpunit: + extends: + service: operational + entrypoint: [ "/init", "/var/www/vendor/bin/phpunit" ] + working_dir: /var/www/build/html + + # Operational base service definition for Phase2 Dev Cloud environment. + # + # Unlike `base`, this layer is functional for application interactions. + # + # Other services inherit these settings via the extends property. + # See https://docs.docker.com/compose/extends/#extending-services + operational: + extends: + service: base + external_links: + - projectname_${DOCKER_ENV:-local}_db:db + - projectname_${DOCKER_ENV:-local}_cache:cache + # Unset the bin/bash command used by base and cli. + command: "" + + # Base service definition for Phase2 Dev Cloud environment. + # + # This is not a fully operational build container, lacking access to other + # services such as the database or cache needed to properly interact with the + # application. + # + # Uses for this container include filesystem operations. For example: + # + # DOCKER_ENV=int docker-compose -f build.devcloud.yml -p projectname_int run --rm base 'rm -Rf node_modules' + # + # Other services inherit these settings via the extends property. + # See https://docs.docker.com/compose/extends/#extending-services + base: + image: + network_mode: "bridge" + entrypoint: [ "/init" ] + working_dir: /var/www + command: /bin/bash + volumes: + # Main code volume mount. + - .:/var/www + # /var/www/src is used here rather than /var/www/build/html to + # prevent the grunt clean:default task from encountering an error + # because docker won't let the files directory be removed as the + # container is using it in its filesystem magic. Since the + # /var/www/build/html/sites/default item is a symlink it can be + # successfully cleaned without then needing to touch the files + # directory. This mount is present so that drush and other build + # container operations can operate on the files for a site. + - /data/projectname/${DOCKER_ENV:-local}/files:/var/www/src/sites/default/files + # By volume mounting project Drush configuration to the user profile the + # Docker image can carry Drush configuration and commands itself. + # Would be more clean if this volume mount placed the Drush configuration + # within the Drupal directory structure. + - ./env/build/etc/drush:/root/.drush + # DevCloud backups are homed in /data/backups directory. + - /data/backups/projectname/${DOCKER_ENV:-local}:/opt/backups + # Persist the cache directories associated with various tools. + # The first volume mount covers: npm, composer, bower, fontconfig, & yarn + - /data/projectname/cache:/root/.cache + - /data/projectname/cache/drush:/root/.drush/cache + - /data/projectname/cache/behat_gherkin:/tmp/behat_gherkin_cache + # SSH key grants read access to private Git repositories. + - ~/.ssh/${OUTRIGGER_SSH_KEY:-id_rsa}:/root/.ssh/outrigger.key + # Preserve BASH history across build container runs. + - /data/projectname/${DOCKER_ENV:-local}/bash:/root/bash + labels: + outrigger.project: projectname + environment: + APP_DOMAIN: ${DOCKER_ENV:-local}-projectname.hosting.example.net + GDT_DOMAIN: ${DOCKER_ENV:-local}-projectname.hosting.example.net + # Check https://hub.docker.com/r/phase2/devtools-build/ for other Node version options. + NODE_VERSION: 6 + PHP_XDEBUG: "true" + # Suppress the loading of grunt-drupal-tasks desktop notification functionality. + GDT_QUIET: 1 + # Include the DOCKER_ENV so Drupal settings can be aware of environment. + DOCKER_ENV: ${DOCKER_ENV:-local} + # Centralized build cache configuration. + # This might move to the Docker build image. + NPM_CONFIG_CACHE: /root/.cache/npm + COMPOSER_CACHE_DIR: /root/.cache/composer + PROXY_VIRTUAL_HOST: ${DOCKER_ENV:-local}-projectname.hosting.example.net + # PHPUnit variables. + SIMPLETEST_DB: mysql://admin:admin@db/projectname_drupal + SIMPLETEST_URL: projectname.hosting.example.net + BROWSERTEST_OUTPUT_DIRECTORY: /tmp diff --git a/rig-project-create-drupal/build.yml b/rig-project-create-drupal/build.yml new file mode 100644 index 0000000..a96c89d --- /dev/null +++ b/rig-project-create-drupal/build.yml @@ -0,0 +1,160 @@ +## +# Build and command-line operations containers for your local environment. +# +# By setting your local DOCKER_ENV environment variable you can spin up +# multiple environments. Keep in mind you should also vary the docker-compose +# --project-name as needed by running commands with that flag, the -p alias, +# or setting the COMPOSE_PROJECT_NAME environment variable. +# +# @see https://docs.docker.com/compose/reference/overview/ +# @see https://docs.docker.com/compose/compose-file/compose-file-v2/ +## +version: '2.1' + +services: + # Container for starting a cli for build commands + # Usage: docker-compose -f build.yml run --rm cli + cli: + extends: + service: operational + command: /bin/bash + + # Container for running composer in the repo root. + # Usage: docker-compose -f build.yml run --rm composer + composer: + extends: + service: base + entrypoint: [ "/init", "composer", "--ansi" ] + command: "" + + # Container for running drush in the docroot. + # Usage: docker-compose -f build.yml run --rm drush + # Where is a direct drush command like cache-rebuild + drush: + extends: + service: operational + entrypoint: [ "/init", "drush", "@projectname" ] + working_dir: /var/www/build/html + + # Container for running Drupal Console in the docroot. + # Usage: docker-compose -f build.yml run --rm drupal + # Where is a direct drupal command like generate + # Note: Only works if the project includes Drupal Console as a composer dependency. + drupal: + extends: + service: operational + entrypoint: [ "/init", "/var/www/vendor/bin/drupal", "--ansi" ] + working_dir: /var/www/build/html + + # Container for running grunt in the repo root. + # Usage: docker-compose -f build.yml run --rm grunt + grunt: + extends: + service: operational + entrypoint: [ "/init", "grunt" ] + + # Container for running PHPUnit tests. + # Usage: docker-compose -f build.yml run --rm phpunit + # E.g. docker-compose -f build.yml run --rm phpunit -c ./core/phpunit.xml.dist ./modules/custom + phpunit: + extends: + service: operational + entrypoint: [ "/init", "/var/www/vendor/bin/phpunit" ] + working_dir: /var/www/build/html + + # Operational base service definition for Local environment. + # + # Unlike `base`, this layer is functional for application interactions. + # + # Other services inherit these settings via the extends property. + # See https://docs.docker.com/compose/extends/#extending-services + operational: + extends: + service: base + external_links: + - projectname_${DOCKER_ENV:-local}_db:db + - projectname_${DOCKER_ENV:-local}_cache:cache + # Unset the bin/bash command used by base and cli. + command: "" + + # Base service definition for Local environment. + # + # This is not a fully operational build container, lacking access to other + # services such as the database or cache needed to properly interact with the + # application. + # + # Uses for this container include filesystem operations. For example: + # + # docker-compose -f build.yml run --rm base 'rm -Rf node_modules' + # + # Other services inherit these settings via the extends property. + # See https://docs.docker.com/compose/extends/#extending-services + base: + image: outrigger/build:php70 + network_mode: "bridge" + entrypoint: [ "/init" ] + working_dir: /var/www + command: /bin/bash + volumes: + # Use 'rig project sync' to leverage unison-based filesystem for app code. + # @see + - projectname-sync:/var/www + # /var/www/src is used here rather than /var/www/build/html to + # prevent the grunt clean:default task from encountering an error + # because docker won't let the files directory be removed as the + # container is using it in its filesystem magic. Since the + # /var/www/build/html/sites/default item is a symlink it can be + # successfully cleaned without then needing to touch the files + # directory. This mount is present so that drush and other build + # container operations can operate on the files for a site. + - /data/projectname/${DOCKER_ENV:-local}/files:/var/www/src/sites/default/files + # By volume mounting project Drush configuration to the user profile the + # Docker image can carry Drush configuration and commands itself. + # Would be more clean if this volume mount placed the Drush configuration + # within the Drupal directory structure. + - ./env/build/etc/drush:/root/.drush + # Local backups are managed within the project directory. This varies by + # platform. + - ./build/backups:/opt/backups + # Persist the cache directories associated with various tools. + # The first volume mount covers: npm, composer, bower, fontconfig, & yarn + - /data/projectname/cache:/root/.cache + - /data/projectname/cache/drush:/root/.drush/cache + - /data/projectname/cache/behat_gherkin:/tmp/behat_gherkin_cache + # SSH key grants read access to private Git repositories. + - ~/.ssh/${OUTRIGGER_SSH_KEY:-id_rsa}:/root/.ssh/outrigger.key + # Preserve BASH history across build container runs. + - /data/projectname/${DOCKER_ENV:-local}/bash:/root/bash + labels: + outrigger.project: projectname + environment: + APP_DOMAIN: www.projectname.vm + GDT_DOMAIN: www.projectname.vm + # See https://hub.docker.com/r/outrigger/build for other Node version options. + NODE_VERSION: 6 + + # Configure Xdebug + # See http://docs.outrigger.sh/common-tasks/using-xdebug-with-phpstorm/ + PHP_XDEBUG: "true" + PHP_IDE_CONFIG: "serverName=app.projectname.vm" + # Suppress the loading of grunt-drupal-tasks desktop notification functionality. + GDT_QUIET: 1 + # Include the DOCKER_ENV so Drupal settings can be aware of environment. + DOCKER_ENV: ${DOCKER_ENV:-local} + # Centralized build cache configuration. + # This might move to the Docker build image. + NPM_CONFIG_CACHE: /root/.cache/npm + COMPOSER_CACHE_DIR: /root/.cache/composer + PROXY_VIRTUAL_HOST: www.projectname.vm + # PHPUnit variables. + SIMPLETEST_DB: mysql://admin:admin@db/projectname_drupal + SIMPLETEST_URL: www.projectname.vm + BROWSERTEST_OUTPUT_DIRECTORY: /tmp + COMPOSER_EXIT_ON_PATCH_FAILURE: 1 + +volumes: + # This defines the filesystem synchronization volume used for application + # code by the web container. + # @see + projectname-sync: + external: true diff --git a/rig-project-create-drupal/composer.json b/rig-project-create-drupal/composer.json new file mode 100644 index 0000000..f963f57 --- /dev/null +++ b/rig-project-create-drupal/composer.json @@ -0,0 +1,88 @@ +{ + "name": "organization/projectname", + "description": "Demo of 'rig project create' output with most features enabled.", + "repositories": [ + { + "type": "composer", + "url": "https://packages.drupal.org/8" + } + ], + "require": { + "composer/installers": "^1.0", + "drupal-composer/drupal-scaffold": "^2.0.0", + "cweagans/composer-patches": "^1.6", + "roave/security-advisories": "dev-master", + "acquia/lightning": "^2.1", + "drupal/field_group": "^1.0", + "drupal/paragraphs": "^1.1", + "drupal/restui": "^1.0", + "drupal/search_api_solr": "1.x-dev", + "drupal/search_api_page": "^1.0", + "drupal/facets": "1.x-dev", + "drupal/components": "^1.0" + }, + "require-dev": { + "behat/mink": "~1.7", + "behat/mink-zombie-driver": "~1.2", + "behat/mink-goutte-driver": "~1.2", + "drupal/drupal-extension": "~3.2", + "jcalderonzumba/gastonjs": "~1.0.2", + "jcalderonzumba/mink-phantomjs-driver": "~0.3.1", + "mikey179/vfsstream": "~1.2", + "phpunit/phpunit": "~4.8", + "drush/drush": "^8", + "drupal/console": "^1.0", + "phpmd/phpmd": "~2.1", + "drupal/coder": "^8.2", + "behat/behat": "^3.0", + "mikey179/vfsStream": "~1.2", + "se/selenium-server-standalone": "^2.53", + "drupal/admin_toolbar": "^1.18", + "drupal/devel": "^1.0", + "drupal/masquerade": "2.0.0-beta1", + "symfony/css-selector": "~2.8" + }, + "conflict": { + "drupal/drupal": "*" + }, + "minimum-stability": "dev", + "prefer-stable": true, + "config": { + "preferred-install": "dist", + "sort-packages": true + }, + "scripts": { + "drupal-scaffold": "DrupalComposer\\DrupalScaffold\\Plugin::scaffold" + }, + "extra": { + "installer-paths": { + "build/html/core": [ + "type:drupal-core" + ], + "build/html/modules/contrib/{$name}": [ + "type:drupal-module" + ], + "build/html/profiles/contrib/{$name}": [ + "type:drupal-profile" + ], + "build/html/themes/contrib/{$name}": [ + "type:drupal-theme" + ], + "build/drush/contrib/{$name}": [ + "type:drupal-drush" + ] + }, + "enable-patching": true, + "patches": { + "drupal/core": { + "2699157 - Plugin Lazy loading can cause usort warning": "https://www.drupal.org/files/issues/2699157-23.drupal.Plugin-Lazy-loading-can-cause-usort-warning.patch", + "2759397 - Patch EntityReferenceItemNormalizer to prevent recursion": "https://www.drupal.org/files/issues/2759397-1-entity_reference_recursion.patch", + "2679775 - Fixes float issue with inline label fields (entity references on most cases).": "https://www.drupal.org/files/issues/2679775-11-inline-labels.patch", + "2788777 - Allow a profile to be installed from existing config": "https://www.drupal.org/files/issues/2788777-91.patch" + }, + "drupal/paragraphs": { + "2788607 - Empty required fields not providing meaningful error messages": "https://www.drupal.org/files/issues/empty_required_fields-2788607-52.patch" + } + } + } +} diff --git a/rig-project-create-drupal/docker-compose.override.yml b/rig-project-create-drupal/docker-compose.override.yml new file mode 100644 index 0000000..2138b9d --- /dev/null +++ b/rig-project-create-drupal/docker-compose.override.yml @@ -0,0 +1,25 @@ +## +# Local development override for docker-compose.yml. +# +# This file replaces the standard volume mount that shares code into the docker +# container with the Outrigger unison filesystem sync. +# +# Run 'rig project sync' to start syncing. +# @see http://docs.outrigger.sh/project-setup/filesystem-sync/ +# +# This configuration is automatically applied when you use the implicit default +# docker-compose.yml configuration file (e.g., when you **do not** specify the +# -f flag.) +# +# To skip including this configuration, run 'docker-compose -f docker-compose.yml ...' +## +version: '3.1' + +services: + www: + volumes: + - projectname-sync:/var/www + +volumes: + projectname-sync: + external: true diff --git a/rig-project-create-drupal/docker-compose.yml b/rig-project-create-drupal/docker-compose.yml new file mode 100644 index 0000000..5a7da57 --- /dev/null +++ b/rig-project-create-drupal/docker-compose.yml @@ -0,0 +1,114 @@ +## +# Operational services to run the application in your local or Outrigger Cloud environment. +# +# To ensure this works as expected for multiple environments, both environment +# settings must be carefully respected in *every* command invocation: +# +# * The `DOCKER_ENV` environment variable which is used as a template parameter for +# how this configuration is used. +# * The -p|--project-name option for Docker Compose, which uses the provided name +# in lieu of deriving key Docker namespacing from whatever the current directory +# happens to be named. You can also set the COMPOSE_PROJECT_NAME environment variable. +# +# Warning: Multiple environments for local use require customizing the DNSDock +# Configuration. A generic approach for this has not yet been determined. +# +# @see https://docs.docker.com/compose/reference/overview/ +# @see https://docs.docker.com/compose/compose-file/compose-file/ +## +version: '3.1' + +services: + # Database service + db: + container_name: projectname_${DOCKER_ENV:-local}_db + image: outrigger/mariadb:10.1 + environment: + MYSQL_DATABASE: projectname_drupal + # This is used by the nginx-proxy service which is part of Phase2's Outrigger hosting platform. + # Outrigger Cloud as a hosting platform is still for Phase2 internal use only. + # Add a VIRTUAL_PORT to access the service externally over port 80. + VIRTUAL_HOST: db-${DOCKER_ENV:-local}-projectname.hosting.example.net + volumes: + - /data/projectname/${DOCKER_ENV:-local}/mysql:/var/lib/mysql + network_mode: "bridge" + labels: + com.dnsdock.name: db + com.dnsdock.image: projectname + outrigger.project: projectname + + # Application Cache service + cache: + container_name: projectname_${DOCKER_ENV:-local}_cache + image: outrigger/redis + network_mode: "bridge" + environment: + # This is used by the nginx-proxy service which is part of Phase2's Outrigger hosting platform. + # Outrigger Cloud as a hosting platform is still for Phase2 internal use only. + # Add a VIRTUAL_PORT to access the service externally over port 80. + VIRTUAL_HOST: cache-${DOCKER_ENV:-local}-projectname.hosting.example.net + labels: + com.dnsdock.name: cache + com.dnsdock.image: projectname + outrigger.project: projectname + + # Reverse-proxy Cache service + proxy: + container_name: projectname_${DOCKER_ENV:-local}_proxy + image: outrigger/varnish:4.0 + network_mode: "bridge" + environment: + VARNISH_BACKEND_HOST: www + # This is used by the nginx-proxy service which is part of Phase2's Outrigger hosting platform. + # Outrigger Cloud as a hosting platform is still for Phase2 internal use only. + VIRTUAL_HOST: ${DOCKER_ENV:-local}-projectname.hosting.example.net + links: + - www + labels: + com.dnsdock.name: www + com.dnsdock.image: projectname + outrigger.project: projectname + + # MailHog SMTP and UI service. + mail: + container_name: projectname_${DOCKER_ENV:-local}_mail + image: mailhog/mailhog + network_mode: "bridge" + labels: + com.dnsdock.name: mail + com.dnsdock.image: projectname + outrigger.project: projectname + environment: + # This is used by the nginx-proxy service which is part of Phase2's Outrigger Cloud hosting. + # Outrigger Cloud as a hosting platform is still for Phase2 internal use only. + VIRTUAL_HOST: mail-${DOCKER_ENV:-local}-projectname.hosting.example.net + VIRTUAL_PORT: '8025' + + # Main Application service. + www: + container_name: projectname_${DOCKER_ENV:-local}_www + image: outrigger/apache-php:php70 + network_mode: "bridge" + environment: + DOCROOT: /var/www/build/html + PHP_MAX_EXECUTION_TIME: 60 + PHP_XDEBUG: "true" + PHP_XHPROF: "true" + # Include the DOCKER_ENV so Drupal settings can be aware of environment. + DOCKER_ENV: ${DOCKER_ENV:-local} + # This is used by the nginx-proxy service which is part of Phase2's Outrigger Cloud hosting. + # Outrigger Cloud as a hosting platform is still for Phase2 internal use only. + VIRTUAL_HOST: app-${DOCKER_ENV:-local}-projectname.hosting.example.net + links: + - db + - cache + - mail + volumes: + # Main code volume mount. + - .:/var/www + # /var/www/src is used for consistency with the build container. + - /data/projectname/${DOCKER_ENV:-local}/files:/var/www/src/sites/default/files + labels: + com.dnsdock.name: app + com.dnsdock.image: projectname + outrigger.project: projectname diff --git a/rig-project-create-drupal/docs/DEVCLOUD.md b/rig-project-create-drupal/docs/DEVCLOUD.md new file mode 100644 index 0000000..e9e58c0 --- /dev/null +++ b/rig-project-create-drupal/docs/DEVCLOUD.md @@ -0,0 +1,105 @@ +# Outrigger Cloud: Docker-based Development Hosting + +> Learn how to work with and manage Phase2's Outrigger Cloud hosting platform. + +Outrigger Hosting is Phase2's docker-based hosting platform for our development projects. This solution is still internal-only and evolving, and will eventually be documented so others can set it up as well. + +## Server Location + +These Docker-based hosted sites are on servers managed by the Phase2 Infrastructure Team. + +You can reach an environment on the server via: + +``` +http://[env]-projectname.projectname.hosting.example.net +``` + +You will find this on disk at `/opt/development/projectname/jenkins/env/deploy-[env]` + +In order to run commands such as clearing the Drupal application cache, you +would run: + +``` +cd /opt/development/projectname/jenkins/env/deploy-[env] +DOCKER_ENV=[env] docker-compose -f build.devcloud.yml -p projectname_[env] run --rm drush cache-rebuild +``` + +## Jenkins Integration + +This project is packaged with the ability to easily spin up a project-specific +Jenkins instance to facilitate some of the operational practices of Phase2 +development. This includes maintaining standing environments, performing +overnight tasks without developer involvement, and reporting on problems. + +Jenkins is hosted via any Docker environment. + +This Jenkins implementation does a majority of its work by spinning up Docker +containers for the different environments of the project and executing necessary +commands to build code, run tests, or generate reports. + +### Starting Up Jenkins + +This is normally done by the "master Jenkins" ci-start job, you will use this +for local development of Jenkins jobs, configuration, and customization. + +```bash +docker-compose -f jenkins.yml -p projectname run jenkins +``` + +### Accessing Private Repositories + +When you startup Jenkins it will automatically create a volume mount to pull in +your `id_rsa` key for use in SSH-based git checkouts. + +If you do not have an id_rsa key, or do not use one for this project, you can +specify an environment variable locally to substitute in the key name of your +choice: + +```bash +export OUTRIGGER_SSH_KEY=devcloud_bitbucket_rsa +``` + +This same mechanism is available to the build container. + +### Developing Your Jenkins System + +By pulling Jenkins into the project repository it is under more direct control +by the development team. The recommended approach is to focus on Jenkins as a +"thin controller", carrying the minimum functionality to execute its needs as a +Docker-based CI & build tool. Most of the functionality should be found in tools +or scripts that are leveraged by Jenkins from the `bin/` directory. + +### Maintained Jenkins Configuration + +Jenkins has required configuration maintained as part of the project codebase. + +* The main configuration can be viewed at `env/jenkins/config.xml` +* Individual jobs are found in `env/jenkins/jobs`. + +When working with the Jenkins UI to make changes, configuration will be directly +written to these files. This way you can manage Jenkins changes as part of the +development process. + +> **Known Problem** +> Saving administrative pages that write to the main Jenkins config.xml leads to +> a fatal error. Get back to a working Jenkins page, as despite this fatal error +> Jenkins will continue to work. + +### Default Jenkins Jobs + +There are several Jenkins jobs packaged in the repository. + +* **ci**: Triggered by every push to the configured Git repository, CI runs all + tests and checks and reports back on the health of the code branch. +* **dev-support:** Produces a nightly snapshot database of a clean install made + available at `/opt/backups/nightlies`. The most recent snapshot can be found at `/opt/backups/latest.sql.gz`. Also runs a module updates scan. +* For each supported environment (Development, QA, Review) has a deployment, + cron, and admin password reset job. +* See a running Jenkins instance for additional jobs. + +## Updating for Use Outside Phase2 Infrastructure + +Phase2 uses [Flowdock](https://flowdock.com) for team messaging, commonly the +Jenkins jobs are configured to send a message to the project chat room. +Please reconfigure or disable this setting when using this to set up Jenkins +outside a Phase2 environment. diff --git a/rig-project-create-drupal/docs/OUTRIGGER.md b/rig-project-create-drupal/docs/OUTRIGGER.md new file mode 100644 index 0000000..5e0c975 --- /dev/null +++ b/rig-project-create-drupal/docs/OUTRIGGER.md @@ -0,0 +1,105 @@ +# Outrigger and Docker + +> Set up and work with your project via [Outrigger](http://outrigger.sh) our local Docker management system. + +Running this project on Docker streamlines the installation steps. +The Docker configuration in this repository handles all necessary environment +setup for local development or testing environments. + +Local environments assume the use of Phase2's "Outrigger" system to manage the +filesystem, DNS, and any necessary virtualization. Read more about this in the +[Outrigger documentation](http://docs.outrigger.sh). (Linux users +should follow the [Linux instructions](http://docs.outrigger.sh/getting-started/linux-installation/) +for simple things like DNS consistency with macOS users.) + +> **You should never run code outside the Outrigger Build container other than rig project commands, docker commands, or BASH scripts you understand handle running docker commands as needed. Imagine your system has no development environment setup.** + +## First-time Application Setup + +Once you have a working Outrigger + Docker environment, you can have a +locally-hosted, web-browsable site instance in just a few minutes with two +commands. + +```bash +git clone git@bitbucket.org:phase2tech/projectname.git +rig project setup +``` + +## Daily Routine + +* `rig start` +* `eval "$(rig config)"` +* `cd path/to/project` +* `rig project up` +* [PRODUCTIVE!] +* `rig project stop` +* `rig stop` + +You can leave rig running day to day but periodic restarts are recommended. + +## Running Commands in the Build Container + +All command-line operations to interact with the application are executed via a dedicated build container that has many tools built-in. + +### Using Build Services + +You can run any of the services defined at the root directory in build.yml, including services for cli, composer, drush, drupal (console), grunt, and theme, +with either of the following commands: + +#### Using Rig Project + +``` +rig project run " " +rig project run "composer install" +``` + +#### Using docker-compose + +``` +docker-compose -f build.yml run --rm +docker-compose -f build.yml run --rm composer install +``` + +### Using a "Remote Server" Workflow + +If you want to run an interactive BASH session, use the `cli` service without further arguments: + +``` +rig project run cli +``` + +This will open a BASH session that allows you to run any commands or use any tools available in the build container. + +### Environment Configuration + +* **OUTRIGGER_SSH_KEY**: [Default: `id_rsa`] The filename of the private SSH key +to use to access private servers or git repositories. Assumes lookup in ~/.ssh/. + +### Aliases & Shortcuts + +You may want to add an alias to your shell to reduce the typing: + +``` +alias r='docker-compose -f build.yml run --rm' +``` + +Then execute commands with: + +``` +r drush cr +``` + +## Common Operations + +To see a list of common operations run `rig project`. + +## Services + +* **Website:** [http://www.projectname.vm](http://www.projectname.vm) +* **Website w/out Varnish:** [http://app.projectname.vm](http://app.projectname.vm) +* **MailHog Service:** http://mail.projectname.vm](http://mail.projectname.vm) + +* **Database:** `db.projectname.vm` + * **User**: `admin` + * **Password**: `admin` + * **Database**: `projectname_drupal` diff --git a/rig-project-create-drupal/env/.gitignore b/rig-project-create-drupal/env/.gitignore new file mode 100644 index 0000000..c2e6702 --- /dev/null +++ b/rig-project-create-drupal/env/.gitignore @@ -0,0 +1,7 @@ +jenkins/jobs/*/builds +jenkins/jobs/*/lastStable +jenkins/jobs/*/lastSuccessful +jenkins/jobs/*/workspace +jenkins/jobs/*/nextBuildNumber +jenkins/jobs/*/*.log +build/etc/drush/cache diff --git a/rig-project-create-drupal/env/jenkins/config.xml b/rig-project-create-drupal/env/jenkins/config.xml new file mode 100644 index 0000000..33ef851 --- /dev/null +++ b/rig-project-create-drupal/env/jenkins/config.xml @@ -0,0 +1,198 @@ + + + + 1.625.1 + 1 + NORMAL + true + + + false + + /opt/development/projectname/jenkins/env/workspace/${ITEM_FULL_NAME} + ${ITEM_ROOTDIR}/builds + + + + + 5 + 0 + + + + All + false + false + + + + + Local + Operations for the Local environment at 'www.projectname.vm'. + false + false + + + + + + + + + + + + + + + .*local.* + false + + + + Integration + Operations for the Integration/PR Testing/Maintenance environment at 'int-projectname.hosting.example.net'. + false + false + + + + + + + + + + + + + + + .*(ci|int|dev\-support).* + false + + + + Development + Operations for the Development environment at 'dev-projectname.hosting.example.net'. + false + false + + + + + + + + + + + + + + + .*dev(?!\-support).* + false + + + + QA + Operations for the QA/Testing environment at 'qa-projectname.hosting.example.net'. + false + false + + + + + + + + + + + + + + + .*qa.* + false + + + + Review + Operations for the Review environment at 'review-projectname.hosting.example.net'. + false + false + + + + + + + + + + + + + + + .*(ms|review).* + false + + + Utility + Facilitate Jenkins troubleshooting. + false + false + + + + + + + + + + + + + + + .*jenkins.* + false + + + + Primary + Primary jobs for use in day to day operations. + false + false + + + ci + deploy-qa + deploy-review + dev-support + password-reset-qa + password-reset-review + + + + + + + + + + + + false + + + Primary + 0 + + + + diff --git a/rig-project-create-drupal/env/jenkins/jobs/ci/config.xml b/rig-project-create-drupal/env/jenkins/jobs/ci/config.xml new file mode 100644 index 0000000..39845cc --- /dev/null +++ b/rig-project-create-drupal/env/jenkins/jobs/ci/config.xml @@ -0,0 +1,317 @@ + + + + Automatically run a test suite against any code change. Does not process changes to the 'develop' branch, for that see "deploy-dev". This job is managed in the project code repository, changes made via UI will be lost. + + false + + + + -1 + 5 + -1 + -1 + + + + false + false + + + + + GIT_REF + Git branch, tag, or commit revision to build. + :^((?!develop).)*$ + + + + + + 2 + + + git@bitbucket.org:phase2tech/projectname.git + + + + + ${GIT_REF} + + + false + + + + true + false + false + false + + + * * * * * + false + + + false + + + #!/usr/bin/env bash +export DOCKER_ENV=int +export COMPOSE_PROJECT_NAME=projectname_${DOCKER_ENV:--local} +export COMPOSE_FILE=build.devcloud.yml + +# Break down the Docker environment and remove generated files. +teardown() { + docker-compose -f docker-compose.yml stop || true + docker-compose -f docker-compose.yml rm -f || true + # Now that www container is stopped it's safe to clean up. + # For speed, CI job does not do this, and relies on build process to perform + # steps on an as-needed basis. + # git clean -fd +} + +# Handler for errors or other interruptions. +cancel() { + echo "$JOB_NAME: Error: Line $1: $2" + # Since CI runs teardown on exit it is not needed here. + # teardown + exit 34 +} + +# End-of-job cleanup. +complete() { + ret=$1 + [ "$ret" -eq 0 ] || echo >&2 "$JOB_NAME: aborted ($ret)" + teardown +} + +# Abort build step on errors. +trap 'cancel $LINENO $BASH_COMMAND' ERR SIGINT SIGTERM SIGQUIT SIGHUP +# Clean up on program termination. +trap 'complete $?' EXIT + +teardown + +# Set up and install site +docker-compose -f docker-compose.yml up -d +docker-compose run --rm cli "NPM_CONFIG_LOGLEVEL=error npm install" +docker-compose run --rm grunt --timer + +# Remove --no-db-load if each deploy should re-load a database from /opt/backups/latest.sql.gz. +# The location and name of this file can be changed in Gruntconfig.json. +docker-compose run --rm grunt install --no-db-load + +# Warm cache and review HTTP response headers +echo "Warm cache and review HTTP response headers..." +curl -I -vvv http://${DOCKER_ENV}-projectname.hosting.example.net + +# Run Behat Tests +docker-compose run --rm cli "GDT_DOMAIN=${DOCKER_ENV}-projectname.hosting.example.net grunt test --force --timer" + +# Run Features Health Check +docker-compose run --rm cli bin/features-health.sh || true + +# Generate Static Analysis Reports +docker-compose run --rm grunt analyze --timer + + + + + + + + low + [CHECKSTYLE] + + false + false + false + false + + + + + + + + + + + + + + + + + + + false + true + false + build/reports/phpcs.xml + + + + + low + [PMD] + + false + false + false + false + + + + + + + + + + + + + + + + + + + false + true + false + build/reports/phpmd.xml + + + + + low + [WARNINGS] + + false + false + false + false + + + + + + + + + + + + + + + + + + + false + true + true + + + + + + + PHP Runtime + + + + + + + low + [TASKS] + + false + false + false + false + + + + + + + + + + + + + + + + + + + false + true + false + + + + true + false + src/**/*.php,src/**/*.module,src/**/*.inc,src/**/*.install,src/**/*.js + + + + + + low + [ANALYSIS-COLLECTOR] + + false + false + false + false + + + + + + + + + + + + + + + + + + + false + true + false + false + false + false + false + false + false + + + + + + xterm + + + + true + true + + + diff --git a/rig-project-create-drupal/env/jenkins/jobs/cron-dev/config.xml b/rig-project-create-drupal/env/jenkins/jobs/cron-dev/config.xml new file mode 100644 index 0000000..a0edb94 --- /dev/null +++ b/rig-project-create-drupal/env/jenkins/jobs/cron-dev/config.xml @@ -0,0 +1,64 @@ + + + + Manage cron for the dev environment. + + -1 + 5 + -1 + -1 + + false + + + false + + + false + false + + + + true + false + false + false + + + H 9 * * * + + + false + /opt/development/projectname/jenkins/env/workspace/deploy-dev + + + #!/usr/bin/env bash +export DOCKER_ENV=dev +export COMPOSE_PROJECT_NAME=projectname_${DOCKER_ENV:--local} +export COMPOSE_FILE=build.devcloud.yml + +# Handler for errors or other interruptions. +cancel() { + echo "$JOB_NAME: Error: Line $1: $2" + exit 35 +} + +# Abort build step on errors. +trap 'cancel $LINENO $BASH_COMMAND' ERR SIGINT SIGTERM SIGQUIT SIGHUP + +docker-compose run --rm drush cron -v + + + + + Only Failure + 2 + true + + + + + xterm + + + diff --git a/rig-project-create-drupal/env/jenkins/jobs/cron-local/config.xml b/rig-project-create-drupal/env/jenkins/jobs/cron-local/config.xml new file mode 100644 index 0000000..7d89ecf --- /dev/null +++ b/rig-project-create-drupal/env/jenkins/jobs/cron-local/config.xml @@ -0,0 +1,64 @@ + + + + Manage cron for the local environment. + + -1 + 5 + -1 + -1 + + false + + + false + + + false + false + + + + true + false + false + false + + + H 9 * * * + + + false + /opt/development/projectname/jenkins/env/workspace/deploy-local + + + #!/usr/bin/env bash +export DOCKER_ENV=local +export COMPOSE_PROJECT_NAME=projectname_${DOCKER_ENV:--local} +export COMPOSE_FILE=build.yml + +# Handler for errors or other interruptions. +cancel() { + echo "$JOB_NAME: Error: Line $1: $2" + exit 35 +} + +# Abort build step on errors. +trap 'cancel $LINENO $BASH_COMMAND' ERR SIGINT SIGTERM SIGQUIT SIGHUP + +docker-compose run --rm drush cron -v + + + + + Only Failure + 2 + true + + + + + xterm + + + diff --git a/rig-project-create-drupal/env/jenkins/jobs/cron-qa/config.xml b/rig-project-create-drupal/env/jenkins/jobs/cron-qa/config.xml new file mode 100644 index 0000000..c11eaa1 --- /dev/null +++ b/rig-project-create-drupal/env/jenkins/jobs/cron-qa/config.xml @@ -0,0 +1,64 @@ + + + + Manage cron for the qa environment. + + -1 + 5 + -1 + -1 + + false + + + false + + + false + false + + + + true + false + false + false + + + H 9 * * * + + + false + /opt/development/projectname/jenkins/env/workspace/deploy-qa + + + #!/usr/bin/env bash +export DOCKER_ENV=qa +export COMPOSE_PROJECT_NAME=projectname_${DOCKER_ENV:--local} +export COMPOSE_FILE=build.devcloud.yml + +# Handler for errors or other interruptions. +cancel() { + echo "$JOB_NAME: Error: Line $1: $2" + exit 35 +} + +# Abort build step on errors. +trap 'cancel $LINENO $BASH_COMMAND' ERR SIGINT SIGTERM SIGQUIT SIGHUP + +docker-compose run --rm drush cron -v + + + + + Only Failure + 2 + true + + + + + xterm + + + diff --git a/rig-project-create-drupal/env/jenkins/jobs/cron-review/config.xml b/rig-project-create-drupal/env/jenkins/jobs/cron-review/config.xml new file mode 100644 index 0000000..5973333 --- /dev/null +++ b/rig-project-create-drupal/env/jenkins/jobs/cron-review/config.xml @@ -0,0 +1,64 @@ + + + + Manage cron for the review environment. + + -1 + 5 + -1 + -1 + + false + + + false + + + false + false + + + + true + false + false + false + + + H 9 * * * + + + false + /opt/development/projectname/jenkins/env/workspace/deploy-review + + + #!/usr/bin/env bash +export DOCKER_ENV=review +export COMPOSE_PROJECT_NAME=projectname_${DOCKER_ENV:--local} +export COMPOSE_FILE=build.devcloud.yml + +# Handler for errors or other interruptions. +cancel() { + echo "$JOB_NAME: Error: Line $1: $2" + exit 35 +} + +# Abort build step on errors. +trap 'cancel $LINENO $BASH_COMMAND' ERR SIGINT SIGTERM SIGQUIT SIGHUP + +docker-compose run --rm drush cron -v + + + + + Only Failure + 2 + true + + + + + xterm + + + diff --git a/rig-project-create-drupal/env/jenkins/jobs/deploy-dev/config.xml b/rig-project-create-drupal/env/jenkins/jobs/deploy-dev/config.xml new file mode 100644 index 0000000..e410082 --- /dev/null +++ b/rig-project-create-drupal/env/jenkins/jobs/deploy-dev/config.xml @@ -0,0 +1,329 @@ + + + + Deploy changes to 'dev-projectname.hosting.example.net'. Behat tests and code analysis are performed, user accounts seeded if configured, features health reviewed and cron is executed. This job is managed in the project code repository, changes made via UI will be lost. + false + + + false + false + + + + + GIT_REF + Git branch, tag, or commit revision to build. + refs/heads/develop + + + UPDATE + Skip the install step of the deployment process. Useful to preserve prepared test or demo content through deployments. + false + + + + + + 2 + + + git@bitbucket.org:phase2tech/projectname.git + + + + + ${GIT_REF} + + + false + + + + true + false + false + false + + + * * * * * + false + + false + + + #!/usr/bin/env bash +export DOCKER_ENV=dev +export COMPOSE_PROJECT_NAME=projectname_${DOCKER_ENV:--local} +export COMPOSE_FILE=build.devcloud.yml +export SITE_DOMAIN=${DOCKER_ENV}-projectname.hosting.example.net + +# Break down the Docker environment and remove generated files. +teardown() { + docker-compose -f docker-compose.yml stop || true + docker-compose -f docker-compose.yml rm -f || true + # Now that www container is stopped it's safe to clean up. + # This is not done by default to keep most environments fast. + # git clean -fd +} + +# Handler for errors or other interruptions. +cancel() { + echo "$JOB_NAME: Error: Line $1: $2" + + teardown + exit 34 +} + +# End-of-job cleanup. +complete() { + ret=$1 + [ "$ret" -eq 0 ] || echo >&2 "$JOB_NAME: aborted ($ret)" +} + +# Abort build step on errors. +trap 'cancel $LINENO $BASH_COMMAND' ERR SIGINT SIGTERM SIGQUIT SIGHUP +# Clean up on program termination. +trap 'complete $?' EXIT + +teardown + +# Set up and install site +docker-compose -f docker-compose.yml up -d +docker-compose run --rm cli "NPM_CONFIG_LOGLEVEL=error npm install" +docker-compose run --rm grunt --timer + +if [ $UPDATE = "true" ]; then + docker-compose run --rm grunt update +else + # Remove --no-db-load if each deploy should re-load a database from /opt/backups/latest.sql.gz. + # The location and name of this file can be changed in Gruntconfig.json. + docker-compose run --rm grunt install --no-db-load +fi + +echo "Visit $(docker-compose run --rm drush sa @projectname --format=list --fields=uri)" + +# Warm cache and review HTTP response headers +echo "Warm cache and review HTTP response headers..." +curl -I -vvv http://${SITE_DOMAIN} + +# Run Behat Tests +docker-compose run --rm cli "GDT_DOMAIN=${SITE_DOMAIN} grunt test --force --timer" + +# Run Features Health Check +docker-compose run --rm cli bin/features-health.sh || true + +# Generate a one-time password reset link. +echo "Generating a one-time password-reset link..." +docker-compose run --rm drush uli + +if [ $UPDATE != "true" ]; then + # Generating test users. + echo "Generating Drupal test accounts..." + docker-compose run --rm grunt seed-users +fi + +# Run drush cron to make sure site is in "typical" cron state. +docker-compose run --rm drush cron -v + +# Generate Static Analysis Reports +docker-compose run --rm grunt analyze --timer + + + + + + + + low + [CHECKSTYLE] + + false + false + false + false + + + + + + + + + + + + + + + + + + + false + true + false + build/reports/phpcs.xml + + + + + low + [PMD] + + false + false + false + false + + + + + + + + + + + + + + + + + + + false + true + false + build/reports/phpmd.xml + + + + + low + [WARNINGS] + + false + false + false + false + + + + + + + + + + + + + + + + + + + false + true + true + + + + + + + PHP Runtime + + + + + + + low + [TASKS] + + false + false + false + false + + + + + + + + + + + + + + + + + + + false + true + false + + + + true + false + src/**/*.php,src/**/*.module,src/**/*.inc,src/**/*.install,src/**/*.js + + + + + + low + [ANALYSIS-COLLECTOR] + + false + false + false + false + + + + + + + + + + + + + + + + + + + false + true + false + false + false + false + false + false + false + + + + + xterm + + + + true + true + + + diff --git a/rig-project-create-drupal/env/jenkins/jobs/deploy-local/config.xml b/rig-project-create-drupal/env/jenkins/jobs/deploy-local/config.xml new file mode 100644 index 0000000..fa9d609 --- /dev/null +++ b/rig-project-create-drupal/env/jenkins/jobs/deploy-local/config.xml @@ -0,0 +1,323 @@ + + + + Deploy changes to 'www.projectname.vm'. Behat tests and code analysis are performed, user accounts seeded if configured, features health reviewed and cron is executed. This job is managed in the project code repository, changes made via UI will be lost. + false + + + false + false + + + + + GIT_REF + Git branch, tag, or commit revision to build. + refs/heads/develop + + + UPDATE + Skip the install step of the deployment process. Useful to preserve prepared test or demo content through deployments. + false + + + + + + 2 + + + git@bitbucket.org:phase2tech/projectname.git + + + + + ${GIT_REF} + + + false + + + + true + false + false + false + + false + + + #!/usr/bin/env bash +export DOCKER_ENV=local +export COMPOSE_PROJECT_NAME=projectname_${DOCKER_ENV:--local} +export COMPOSE_FILE=build.yml +export SITE_DOMAIN=www.projectname.vm + +# Break down the Docker environment and remove generated files. +teardown() { + docker-compose -f docker-compose.yml stop || true + docker-compose -f docker-compose.yml rm -f || true + # Now that www container is stopped it's safe to clean up. + # This is not done by default to keep most environments fast. + # git clean -fd +} + +# Handler for errors or other interruptions. +cancel() { + echo "$JOB_NAME: Error: Line $1: $2" + exit 32 +} + +# End-of-job cleanup. +complete() { + ret=$1 + [ "$ret" -eq 0 ] || echo >&2 "$JOB_NAME: aborted ($ret)" +} + +# Abort build step on errors. +trap 'cancel $LINENO $BASH_COMMAND' ERR SIGINT SIGTERM SIGQUIT SIGHUP +# Clean up on program termination. +trap 'complete $?' EXIT + +teardown + +# Set up and install site +docker-compose -f docker-compose.yml up -d +docker-compose run --rm cli "NPM_CONFIG_LOGLEVEL=error npm install" +docker-compose run --rm grunt --timer + +if [ $UPDATE = "true" ]; then + docker-compose run --rm grunt update +else + # Remove --no-db-load if each deploy should re-load a database from /opt/backups/latest.sql.gz. + # The location and name of this file can be changed in Gruntconfig.json. + docker-compose run --rm grunt install --no-db-load +fi + +echo "Visit $(docker-compose run --rm drush sa @projectname --format=list --fields=uri)" + +# Warm cache and review HTTP response headers +echo "Warm cache and review HTTP response headers..." +curl -I -vvv http://${SITE_DOMAIN} + +# Run Behat Tests +docker-compose run --rm cli "GDT_DOMAIN=${SITE_DOMAIN} grunt test --force --timer" + +# Run Features Health Check +docker-compose run --rm cli bin/features-health.sh || true + +# Generate a one-time password reset link. +echo "Generating a one-time password-reset link..." +docker-compose run --rm drush uli + +if [ $UPDATE != "true" ]; then + # Generating test users. + echo "Generating Drupal test accounts..." + docker-compose run --rm grunt seed-users +fi + +# Run drush cron to make sure site is in "typical" cron state. +docker-compose run --rm drush cron -v + +# Generate Static Analysis Reports +docker-compose run --rm grunt analyze --timer + + + + + + + + low + [CHECKSTYLE] + + false + false + false + false + + + + + + + + + + + + + + + + + + + false + true + false + build/reports/phpcs.xml + + + + + low + [PMD] + + false + false + false + false + + + + + + + + + + + + + + + + + + + false + true + false + build/reports/phpmd.xml + + + + + low + [WARNINGS] + + false + false + false + false + + + + + + + + + + + + + + + + + + + false + true + true + + + + + + + PHP Runtime + + + + + + + low + [TASKS] + + false + false + false + false + + + + + + + + + + + + + + + + + + + false + true + false + + + + true + false + src/**/*.php,src/**/*.module,src/**/*.inc,src/**/*.install,src/**/*.js + + + + + + low + [ANALYSIS-COLLECTOR] + + false + false + false + false + + + + + + + + + + + + + + + + + + + false + true + false + false + false + false + false + false + false + + + + + xterm + + + + true + true + + + diff --git a/rig-project-create-drupal/env/jenkins/jobs/deploy-qa/config.xml b/rig-project-create-drupal/env/jenkins/jobs/deploy-qa/config.xml new file mode 100644 index 0000000..cf0bf93 --- /dev/null +++ b/rig-project-create-drupal/env/jenkins/jobs/deploy-qa/config.xml @@ -0,0 +1,323 @@ + + + + Deploy changes to 'qa-projectname.hosting.example.net'. Behat tests and code analysis are performed, user accounts seeded if configured, features health reviewed and cron is executed. This job is managed in the project code repository, changes made via UI will be lost. + false + + + false + false + + + + + GIT_REF + Git branch, tag, or commit revision to build. + refs/heads/develop + + + UPDATE + Skip the install step of the deployment process. Useful to preserve prepared test or demo content through deployments. + false + + + + + + 2 + + + git@bitbucket.org:phase2tech/projectname.git + + + + + ${GIT_REF} + + + false + + + + true + false + false + false + + false + + + #!/usr/bin/env bash +export DOCKER_ENV=qa +export COMPOSE_PROJECT_NAME=projectname_${DOCKER_ENV:--local} +export COMPOSE_FILE=build.devcloud.yml +export SITE_DOMAIN=${DOCKER_ENV}-projectname.hosting.example.net + +# Break down the Docker environment and remove generated files. +teardown() { + docker-compose -f docker-compose.yml stop || true + docker-compose -f docker-compose.yml rm -f || true + # Now that www container is stopped it's safe to clean up. + # This is not done by default to keep most environments fast. + # git clean -fd +} + +# Handler for errors or other interruptions. +cancel() { + echo "$JOB_NAME: Error: Line $1: $2" + exit 32 +} + +# End-of-job cleanup. +complete() { + ret=$1 + [ "$ret" -eq 0 ] || echo >&2 "$JOB_NAME: aborted ($ret)" +} + +# Abort build step on errors. +trap 'cancel $LINENO $BASH_COMMAND' ERR SIGINT SIGTERM SIGQUIT SIGHUP +# Clean up on program termination. +trap 'complete $?' EXIT + +teardown + +# Set up and install site +docker-compose -f docker-compose.yml up -d +docker-compose run --rm cli "NPM_CONFIG_LOGLEVEL=error npm install" +docker-compose run --rm grunt --timer + +if [ $UPDATE = "true" ]; then + docker-compose run --rm grunt update +else + # Remove --no-db-load if each deploy should re-load a database from /opt/backups/latest.sql.gz. + # The location and name of this file can be changed in Gruntconfig.json. + docker-compose run --rm grunt install --no-db-load +fi + +echo "Visit $(docker-compose run --rm drush sa @projectname --format=list --fields=uri)" + +# Warm cache and review HTTP response headers +echo "Warm cache and review HTTP response headers..." +curl -I -vvv http://${SITE_DOMAIN} + +# Run Behat Tests +docker-compose run --rm cli "GDT_DOMAIN=${SITE_DOMAIN} grunt test --force --timer" + +# Run Features Health Check +docker-compose run --rm cli bin/features-health.sh || true + +# Generate a one-time password reset link. +echo "Generating a one-time password-reset link..." +docker-compose run --rm drush uli + +if [ $UPDATE != "true" ]; then + # Generating test users. + echo "Generating Drupal test accounts..." + docker-compose run --rm grunt seed-users +fi + +# Run drush cron to make sure site is in "typical" cron state. +docker-compose run --rm drush cron -v + +# Generate Static Analysis Reports +docker-compose run --rm grunt analyze --timer + + + + + + + + low + [CHECKSTYLE] + + false + false + false + false + + + + + + + + + + + + + + + + + + + false + true + false + build/reports/phpcs.xml + + + + + low + [PMD] + + false + false + false + false + + + + + + + + + + + + + + + + + + + false + true + false + build/reports/phpmd.xml + + + + + low + [WARNINGS] + + false + false + false + false + + + + + + + + + + + + + + + + + + + false + true + true + + + + + + + PHP Runtime + + + + + + + low + [TASKS] + + false + false + false + false + + + + + + + + + + + + + + + + + + + false + true + false + + + + true + false + src/**/*.php,src/**/*.module,src/**/*.inc,src/**/*.install,src/**/*.js + + + + + + low + [ANALYSIS-COLLECTOR] + + false + false + false + false + + + + + + + + + + + + + + + + + + + false + true + false + false + false + false + false + false + false + + + + + xterm + + + + true + true + + + diff --git a/rig-project-create-drupal/env/jenkins/jobs/deploy-review/config.xml b/rig-project-create-drupal/env/jenkins/jobs/deploy-review/config.xml new file mode 100644 index 0000000..8808c95 --- /dev/null +++ b/rig-project-create-drupal/env/jenkins/jobs/deploy-review/config.xml @@ -0,0 +1,323 @@ + + + + Deploy changes to 'review-projectname.hosting.example.net'. Behat tests and code analysis are performed, user accounts seeded if configured, features health reviewed and cron is executed. This job is managed in the project code repository, changes made via UI will be lost. + false + + + false + false + + + + + GIT_REF + Git branch, tag, or commit revision to build. + refs/heads/develop + + + UPDATE + Skip the install step of the deployment process. Useful to preserve prepared test or demo content through deployments. + false + + + + + + 2 + + + git@bitbucket.org:phase2tech/projectname.git + + + + + ${GIT_REF} + + + false + + + + true + false + false + false + + false + + + #!/usr/bin/env bash +export DOCKER_ENV=review +export COMPOSE_PROJECT_NAME=projectname_${DOCKER_ENV:--local} +export COMPOSE_FILE=build.devcloud.yml +export SITE_DOMAIN=${DOCKER_ENV}-projectname.hosting.example.net + +# Break down the Docker environment and remove generated files. +teardown() { + docker-compose -f docker-compose.yml stop || true + docker-compose -f docker-compose.yml rm -f || true + # Now that www container is stopped it's safe to clean up. + # This is not done by default to keep most environments fast. + git clean -fd +} + +# Handler for errors or other interruptions. +cancel() { + echo "$JOB_NAME: Error: Line $1: $2" + exit 32 +} + +# End-of-job cleanup. +complete() { + ret=$1 + [ "$ret" -eq 0 ] || echo >&2 "$JOB_NAME: aborted ($ret)" +} + +# Abort build step on errors. +trap 'cancel $LINENO $BASH_COMMAND' ERR SIGINT SIGTERM SIGQUIT SIGHUP +# Clean up on program termination. +trap 'complete $?' EXIT + +teardown + +# Set up and install site +docker-compose -f docker-compose.yml up -d +docker-compose run --rm cli "NPM_CONFIG_LOGLEVEL=error npm install" +docker-compose run --rm grunt --timer + +if [ $UPDATE = "true" ]; then + docker-compose run --rm grunt update +else + # Remove --no-db-load if each deploy should re-load a database from /opt/backups/latest.sql.gz. + # The location and name of this file can be changed in Gruntconfig.json. + docker-compose run --rm grunt install --no-db-load +fi + +echo "Visit $(docker-compose run --rm drush sa @projectname --format=list --fields=uri)" + +# Warm cache and review HTTP response headers +echo "Warm cache and review HTTP response headers..." +curl -I -vvv http://${SITE_DOMAIN} + +# Run Behat Tests +docker-compose run --rm cli "GDT_DOMAIN=${SITE_DOMAIN} grunt test --force --timer" + +# Run Features Health Check +docker-compose run --rm cli bin/features-health.sh || true + +# Generate a one-time password reset link. +echo "Generating a one-time password-reset link..." +docker-compose run --rm drush uli + +if [ $UPDATE != "true" ]; then + # Generating test users. + echo "Generating Drupal test accounts..." + docker-compose run --rm grunt seed-users +fi + +# Run drush cron to make sure site is in "typical" cron state. +docker-compose run --rm drush cron -v + +# Generate Static Analysis Reports +docker-compose run --rm grunt analyze --timer + + + + + + + + low + [CHECKSTYLE] + + false + false + false + false + + + + + + + + + + + + + + + + + + + false + true + false + build/reports/phpcs.xml + + + + + low + [PMD] + + false + false + false + false + + + + + + + + + + + + + + + + + + + false + true + false + build/reports/phpmd.xml + + + + + low + [WARNINGS] + + false + false + false + false + + + + + + + + + + + + + + + + + + + false + true + true + + + + + + + PHP Runtime + + + + + + + low + [TASKS] + + false + false + false + false + + + + + + + + + + + + + + + + + + + false + true + false + + + + true + false + src/**/*.php,src/**/*.module,src/**/*.inc,src/**/*.install,src/**/*.js + + + + + + low + [ANALYSIS-COLLECTOR] + + false + false + false + false + + + + + + + + + + + + + + + + + + + false + true + false + false + false + false + false + false + false + + + + + xterm + + + + true + true + + + diff --git a/rig-project-create-drupal/env/jenkins/jobs/dev-support/config.xml b/rig-project-create-drupal/env/jenkins/jobs/dev-support/config.xml new file mode 100644 index 0000000..e41010e --- /dev/null +++ b/rig-project-create-drupal/env/jenkins/jobs/dev-support/config.xml @@ -0,0 +1,125 @@ + + + + Perform nightly maintenance and checks against the develop branch. This includes clean database generation and module update checks. + + -1 + 5 + -1 + -1 + + false + + + + + GIT_REF + Git branch, tag, or commit revision to build. + develop + + + + + false + false + + + + 2 + + + git@bitbucket.org:phase2tech/projectname.git + + + + + ${GIT_REF} + + + false + + + + true + false + false + false + + + H 8 * * * + + + false + + + #!/usr/bin/env bash +export DOCKER_ENV=int +export COMPOSE_PROJECT_NAME=projectname_${DOCKER_ENV:--local} +export COMPOSE_FILE=build.devcloud.yml + +# Break down the Docker environment and remove generated files. +teardown() { + docker-compose -f docker-compose.yml stop || true + docker-compose -f docker-compose.yml rm -f || true + # Now that www container is stopped it's safe to clean up. + # dev-support does this for the cleanest possible checkup. + # git clean -fd +} + +# Handler for errors or other interruptions. +cancel() { + echo "$JOB_NAME: Error: Line $1: $2" + # Since CI runs teardown on exit it is not needed here. + # teardown + exit 34 +} + +# End-of-job cleanup. +complete() { + ret=$1 + [ "$ret" -eq 0 ] || echo >&2 "$JOB_NAME: aborted ($ret)" + teardown +} + +# Abort build step on errors. +trap 'cancel $LINENO $BASH_COMMAND' ERR SIGINT SIGTERM SIGQUIT SIGHUP +# Clean up on program termination. +trap 'complete $?' EXIT + +teardown + +# Set up and install site +docker-compose -f docker-compose.yml up -d +docker-compose run --rm cli "NPM_CONFIG_LOGLEVEL=error npm install" +docker-compose run --rm grunt --timer + +# Remove --no-db-load if each deploy should re-load a database from /opt/backups/latest.sql.gz. +# The location and name of this file can be changed in Gruntconfig.json. +docker-compose run --rm grunt install --no-db-load + +# Run cron for maximized database freshness. +docker-compose run --rm drush cron + +# Export database. This process preserves the latest 5 databases. +DATE=$(date +%Y-%m-%d_%H:%M:%S) +docker-compose run --rm cli bin/db-export.sh nightlies/$DATE.sql + +# Run Behat Tests +# Highly recommended, but not always used on projects. +# docker-compose run --rm cli sh -c "GDT_DOMAIN=${DOCKER_ENV}-projectname.hosting.example.net grunt test --force --timer" + +# Perform a scan for module updates. +docker-compose run --rm cli bash bin/update-scanner.sh + + + + + + + xterm + + + + + + diff --git a/rig-project-create-drupal/env/jenkins/jobs/jenkins-test-default/config.xml b/rig-project-create-drupal/env/jenkins/jobs/jenkins-test-default/config.xml new file mode 100644 index 0000000..dfe342a --- /dev/null +++ b/rig-project-create-drupal/env/jenkins/jobs/jenkins-test-default/config.xml @@ -0,0 +1,27 @@ + + + + + + -1 + 5 + -1 + -1 + + false + + + true + false + false + false + + false + + + echo "The time is" $(date '+%Y %b %d %H:%M') + + + + + diff --git a/rig-project-create-drupal/env/jenkins/jobs/jenkins-test-docker/config.xml b/rig-project-create-drupal/env/jenkins/jobs/jenkins-test-docker/config.xml new file mode 100644 index 0000000..89db0a6 --- /dev/null +++ b/rig-project-create-drupal/env/jenkins/jobs/jenkins-test-docker/config.xml @@ -0,0 +1,30 @@ + + + + Run a docker command to prove docker in docker is working. + + -1 + 5 + -1 + -1 + + false + + + true + false + false + false + + false + + + whoami +docker --version +docker ps +docker-compose version + + + + + diff --git a/rig-project-create-drupal/env/jenkins/jobs/jenkins-test-fail/config.xml b/rig-project-create-drupal/env/jenkins/jobs/jenkins-test-fail/config.xml new file mode 100644 index 0000000..7723163 --- /dev/null +++ b/rig-project-create-drupal/env/jenkins/jobs/jenkins-test-fail/config.xml @@ -0,0 +1,47 @@ + + + + + false + + + + -1 + 5 + -1 + -1 + + + + false + false + + + + true + false + false + false + + false + + + #!/usr/bin/env bash +cancel() { + echo "Line $1: Error encountered. Stopping..." + exit 34 +} + +# Abort build step on errors. +trap 'cancel $LINENO' ERR SIGINT SIGTERM SIGQUIT SIGHUP + +# Sleep will fail on a usage error. +sleep + +echo "Continuing past the error, let's check the time." +echo "The time is" $(date '+%Y %b %d %H:%M') + + + + + diff --git a/rig-project-create-drupal/env/jenkins/jobs/password-reset-dev/config.xml b/rig-project-create-drupal/env/jenkins/jobs/password-reset-dev/config.xml new file mode 100644 index 0000000..b56e11c --- /dev/null +++ b/rig-project-create-drupal/env/jenkins/jobs/password-reset-dev/config.xml @@ -0,0 +1,60 @@ + + + + Generate a password reset URL for the dev environment. + + -1 + 5 + -1 + -1 + + false + + + false + + + false + false + + + + true + false + false + false + + false + /opt/development/projectname/jenkins/env/workspace/deploy-dev + + + #!/usr/bin/env bash +export DOCKER_ENV=dev +export COMPOSE_PROJECT_NAME=projectname_${DOCKER_ENV:--local} +export COMPOSE_FILE=build.devcloud.yml + +# Handler for errors or other interruptions. +cancel() { + echo "$JOB_NAME: Error: Line $1: $2" + exit 35 +} + +# Abort build step on errors. +trap 'cancel $LINENO $BASH_COMMAND' ERR SIGINT SIGTERM SIGQUIT SIGHUP + +docker-compose run --rm drush uli + + + + + http://%[^\s]* + + false + + + + + xterm + + + diff --git a/rig-project-create-drupal/env/jenkins/jobs/password-reset-local/config.xml b/rig-project-create-drupal/env/jenkins/jobs/password-reset-local/config.xml new file mode 100644 index 0000000..8a06d86 --- /dev/null +++ b/rig-project-create-drupal/env/jenkins/jobs/password-reset-local/config.xml @@ -0,0 +1,60 @@ + + + + Generate a password reset URL for the local environment. + + -1 + 5 + -1 + -1 + + false + + + false + + + false + false + + + + true + false + false + false + + false + /opt/development/projectname/jenkins/env/workspace/deploy-local + + + #!/usr/bin/env bash +export DOCKER_ENV=local +export COMPOSE_PROJECT_NAME=projectname_${DOCKER_ENV:--local} +export COMPOSE_FILE=build.yml + +# Handler for errors or other interruptions. +cancel() { + echo "$JOB_NAME: Error: Line $1: $2" + exit 35 +} + +# Abort build step on errors. +trap 'cancel $LINENO $BASH_COMMAND' ERR SIGINT SIGTERM SIGQUIT SIGHUP + +docker-compose run --rm drush uli + + + + + http://%[^\s]* + + false + + + + + xterm + + + diff --git a/rig-project-create-drupal/env/jenkins/jobs/password-reset-qa/config.xml b/rig-project-create-drupal/env/jenkins/jobs/password-reset-qa/config.xml new file mode 100644 index 0000000..e966b44 --- /dev/null +++ b/rig-project-create-drupal/env/jenkins/jobs/password-reset-qa/config.xml @@ -0,0 +1,60 @@ + + + + Generate a password reset URL for the qa environment. + + -1 + 5 + -1 + -1 + + false + + + false + + + false + false + + + + true + false + false + false + + false + /opt/development/projectname/jenkins/env/workspace/deploy-qa + + + #!/usr/bin/env bash +export DOCKER_ENV=qa +export COMPOSE_PROJECT_NAME=projectname_${DOCKER_ENV:--local} +export COMPOSE_FILE=build.devcloud.yml + +# Handler for errors or other interruptions. +cancel() { + echo "$JOB_NAME: Error: Line $1: $2" + exit 35 +} + +# Abort build step on errors. +trap 'cancel $LINENO $BASH_COMMAND' ERR SIGINT SIGTERM SIGQUIT SIGHUP + +docker-compose run --rm drush uli + + + + + http://%[^\s]* + + false + + + + + xterm + + + diff --git a/rig-project-create-drupal/env/jenkins/jobs/password-reset-review/config.xml b/rig-project-create-drupal/env/jenkins/jobs/password-reset-review/config.xml new file mode 100644 index 0000000..9c56a64 --- /dev/null +++ b/rig-project-create-drupal/env/jenkins/jobs/password-reset-review/config.xml @@ -0,0 +1,60 @@ + + + + Generate a password reset URL for the review environment. + + -1 + 5 + -1 + -1 + + false + + + false + + + false + false + + + + true + false + false + false + + false + /opt/development/projectname/jenkins/env/workspace/deploy-review + + + #!/usr/bin/env bash +export DOCKER_ENV=review +export COMPOSE_PROJECT_NAME=projectname_${DOCKER_ENV:--local} +export COMPOSE_FILE=build.devcloud.yml + +# Handler for errors or other interruptions. +cancel() { + echo "$JOB_NAME: Error: Line $1: $2" + exit 35 +} + +# Abort build step on errors. +trap 'cancel $LINENO $BASH_COMMAND' ERR SIGINT SIGTERM SIGQUIT SIGHUP + +docker-compose run --rm drush uli + + + + + http://%[^\s]* + + false + + + + + xterm + + + diff --git a/rig-project-create-drupal/env/jenkins/jobs/start-dev/config.xml b/rig-project-create-drupal/env/jenkins/jobs/start-dev/config.xml new file mode 100644 index 0000000..1115f1c --- /dev/null +++ b/rig-project-create-drupal/env/jenkins/jobs/start-dev/config.xml @@ -0,0 +1,62 @@ + + + + Start the dev environment without performing any installation functions. Depends on a previously successfully executed deploy-dev job having been done. This job is managed in the project code repository, changes made via UI will be lost. + false + + + false + false + + + + true + false + false + false + + false + /opt/development/projectname/jenkins/env/workspace/deploy-dev + + + #!/usr/bin/env bash +export DOCKER_ENV=dev +export COMPOSE_PROJECT_NAME=projectname_${DOCKER_ENV:--local} +export COMPOSE_FILE=build.devcloud.yml +export SITE_DOMAIN=${DOCKER_ENV}-projectname.hosting.example.net + +# Break down the Docker environment and remove generated files. +teardown() { + docker-compose -f docker-compose.yml stop || true + docker-compose -f docker-compose.yml rm -f || true +} + +# Handler for errors or other interruptions. +cancel() { + echo "$JOB_NAME: Error: Line $1: $2" + exit 32 +} + +# End-of-job cleanup. +complete() { + ret=$1 + [ "$ret" -eq 0 ] || echo >&2 "$JOB_NAME: aborted ($ret)" +} + +# Abort build step on errors. +trap 'cancel $LINENO $BASH_COMMAND' ERR SIGINT SIGTERM SIGQUIT SIGHUP +# Clean up on program termination. +trap 'complete $?' EXIT + +docker-compose -f docker-compose.yml up -d + + + + + + + + xterm + + + diff --git a/rig-project-create-drupal/env/jenkins/jobs/start-local/config.xml b/rig-project-create-drupal/env/jenkins/jobs/start-local/config.xml new file mode 100644 index 0000000..ffeb158 --- /dev/null +++ b/rig-project-create-drupal/env/jenkins/jobs/start-local/config.xml @@ -0,0 +1,62 @@ + + + + Start the local environment without performing any installation functions. Depends on a previously successfully executed deploy-local job having been done. This job is managed in the project code repository, changes made via UI will be lost. + false + + + false + false + + + + true + false + false + false + + false + /opt/development/projectname/jenkins/env/workspace/deploy-local + + + #!/usr/bin/env bash +export DOCKER_ENV=local +export COMPOSE_PROJECT_NAME=projectname_${DOCKER_ENV:--local} +export COMPOSE_FILE=build.yml +export SITE_DOMAIN=www.projectname.vm + +# Break down the Docker environment and remove generated files. +teardown() { + docker-compose -f docker-compose.yml stop || true + docker-compose -f docker-compose.yml rm -f || true +} + +# Handler for errors or other interruptions. +cancel() { + echo "$JOB_NAME: Error: Line $1: $2" + exit 32 +} + +# End-of-job cleanup. +complete() { + ret=$1 + [ "$ret" -eq 0 ] || echo >&2 "$JOB_NAME: aborted ($ret)" +} + +# Abort build step on errors. +trap 'cancel $LINENO $BASH_COMMAND' ERR SIGINT SIGTERM SIGQUIT SIGHUP +# Clean up on program termination. +trap 'complete $?' EXIT + +docker-compose -f docker-compose.yml up -d + + + + + + + + xterm + + + diff --git a/rig-project-create-drupal/env/jenkins/jobs/start-qa/config.xml b/rig-project-create-drupal/env/jenkins/jobs/start-qa/config.xml new file mode 100644 index 0000000..9045c90 --- /dev/null +++ b/rig-project-create-drupal/env/jenkins/jobs/start-qa/config.xml @@ -0,0 +1,62 @@ + + + + Start the qa environment without performing any installation functions. Depends on a previously successfully executed deploy-qa job having been done. This job is managed in the project code repository, changes made via UI will be lost. + false + + + false + false + + + + true + false + false + false + + false + /opt/development/projectname/jenkins/env/workspace/deploy-qa + + + #!/usr/bin/env bash +export DOCKER_ENV=qa +export COMPOSE_PROJECT_NAME=projectname_${DOCKER_ENV:--local} +export COMPOSE_FILE=build.devcloud.yml +export SITE_DOMAIN=${DOCKER_ENV}-projectname.hosting.example.net + +# Break down the Docker environment and remove generated files. +teardown() { + docker-compose -f docker-compose.yml stop || true + docker-compose -f docker-compose.yml rm -f || true +} + +# Handler for errors or other interruptions. +cancel() { + echo "$JOB_NAME: Error: Line $1: $2" + exit 32 +} + +# End-of-job cleanup. +complete() { + ret=$1 + [ "$ret" -eq 0 ] || echo >&2 "$JOB_NAME: aborted ($ret)" +} + +# Abort build step on errors. +trap 'cancel $LINENO $BASH_COMMAND' ERR SIGINT SIGTERM SIGQUIT SIGHUP +# Clean up on program termination. +trap 'complete $?' EXIT + +docker-compose -f docker-compose.yml up -d + + + + + + + + xterm + + + diff --git a/rig-project-create-drupal/env/jenkins/jobs/start-review/config.xml b/rig-project-create-drupal/env/jenkins/jobs/start-review/config.xml new file mode 100644 index 0000000..4b24fc1 --- /dev/null +++ b/rig-project-create-drupal/env/jenkins/jobs/start-review/config.xml @@ -0,0 +1,62 @@ + + + + Start the review environment without performing any installation functions. Depends on a previously successfully executed deploy-review job having been done. This job is managed in the project code repository, changes made via UI will be lost. + false + + + false + false + + + + true + false + false + false + + false + /opt/development/projectname/jenkins/env/workspace/deploy-review + + + #!/usr/bin/env bash +export DOCKER_ENV=review +export COMPOSE_PROJECT_NAME=projectname_${DOCKER_ENV:--local} +export COMPOSE_FILE=build.devcloud.yml +export SITE_DOMAIN=${DOCKER_ENV}-projectname.hosting.example.net + +# Break down the Docker environment and remove generated files. +teardown() { + docker-compose -f docker-compose.yml stop || true + docker-compose -f docker-compose.yml rm -f || true +} + +# Handler for errors or other interruptions. +cancel() { + echo "$JOB_NAME: Error: Line $1: $2" + exit 32 +} + +# End-of-job cleanup. +complete() { + ret=$1 + [ "$ret" -eq 0 ] || echo >&2 "$JOB_NAME: aborted ($ret)" +} + +# Abort build step on errors. +trap 'cancel $LINENO $BASH_COMMAND' ERR SIGINT SIGTERM SIGQUIT SIGHUP +# Clean up on program termination. +trap 'complete $?' EXIT + +docker-compose -f docker-compose.yml up -d + + + + + + + + xterm + + + diff --git a/rig-project-create-drupal/env/jenkins/jobs/stop-dev/config.xml b/rig-project-create-drupal/env/jenkins/jobs/stop-dev/config.xml new file mode 100644 index 0000000..55dbde0 --- /dev/null +++ b/rig-project-create-drupal/env/jenkins/jobs/stop-dev/config.xml @@ -0,0 +1,62 @@ + + + + Stop the 'dev-projectname.hosting.example.net' environment. This job is managed in the project code repository, changes made via UI will be lost. + false + + + false + false + + + + true + false + false + false + + false + /opt/development/projectname/jenkins/env/workspace/deploy-dev + + + #!/usr/bin/env bash +export DOCKER_ENV=dev +export COMPOSE_PROJECT_NAME=projectname_${DOCKER_ENV:--local} +export COMPOSE_FILE=build.devcloud.yml +export SITE_DOMAIN=${DOCKER_ENV}-projectname.hosting.example.net + +# Break down the Docker environment +teardown() { + docker-compose -f docker-compose.yml stop + docker-compose -f docker-compose.yml rm -f +} + +# Handler for errors or other interruptions. +cancel() { + echo "$JOB_NAME: Error: Line $1: $2" + exit 32 +} + +# End-of-job cleanup. +complete() { + ret=$1 + [ "$ret" -eq 0 ] || echo >&2 "$JOB_NAME: aborted ($ret)" +} + +# Abort build step on errors. +trap 'cancel $LINENO $BASH_COMMAND' ERR SIGINT SIGTERM SIGQUIT SIGHUP +# Clean up on program termination. +trap 'complete $?' EXIT + +teardown + + + + + + + + xterm + + + diff --git a/rig-project-create-drupal/env/jenkins/jobs/stop-local/config.xml b/rig-project-create-drupal/env/jenkins/jobs/stop-local/config.xml new file mode 100644 index 0000000..4431bca --- /dev/null +++ b/rig-project-create-drupal/env/jenkins/jobs/stop-local/config.xml @@ -0,0 +1,62 @@ + + + + Stop the 'www.projectname.vm' environment. This job is managed in the project code repository, changes made via UI will be lost. + false + + + false + false + + + + true + false + false + false + + false + /opt/development/projectname/jenkins/env/workspace/deploy-local + + + #!/usr/bin/env bash +export DOCKER_ENV=local +export COMPOSE_PROJECT_NAME=projectname_${DOCKER_ENV:--local} +export COMPOSE_FILE=build.yml +export SITE_DOMAIN=www.projectname.vm + +# Break down the Docker environment +teardown() { + docker-compose -f docker-compose.yml stop + docker-compose -f docker-compose.yml rm -f +} + +# Handler for errors or other interruptions. +cancel() { + echo "$JOB_NAME: Error: Line $1: $2" + exit 32 +} + +# End-of-job cleanup. +complete() { + ret=$1 + [ "$ret" -eq 0 ] || echo >&2 "$JOB_NAME: aborted ($ret)" +} + +# Abort build step on errors. +trap 'cancel $LINENO $BASH_COMMAND' ERR SIGINT SIGTERM SIGQUIT SIGHUP +# Clean up on program termination. +trap 'complete $?' EXIT + +teardown + + + + + + + + xterm + + + diff --git a/rig-project-create-drupal/env/jenkins/jobs/stop-qa/config.xml b/rig-project-create-drupal/env/jenkins/jobs/stop-qa/config.xml new file mode 100644 index 0000000..2d83ae9 --- /dev/null +++ b/rig-project-create-drupal/env/jenkins/jobs/stop-qa/config.xml @@ -0,0 +1,62 @@ + + + + Stop the 'qa-projectname.hosting.example.net' environment. This job is managed in the project code repository, changes made via UI will be lost. + false + + + false + false + + + + true + false + false + false + + false + /opt/development/projectname/jenkins/env/workspace/deploy-qa + + + #!/usr/bin/env bash +export DOCKER_ENV=qa +export COMPOSE_PROJECT_NAME=projectname_${DOCKER_ENV:--local} +export COMPOSE_FILE=build.devcloud.yml +export SITE_DOMAIN=${DOCKER_ENV}-projectname.hosting.example.net + +# Break down the Docker environment +teardown() { + docker-compose -f docker-compose.yml stop + docker-compose -f docker-compose.yml rm -f +} + +# Handler for errors or other interruptions. +cancel() { + echo "$JOB_NAME: Error: Line $1: $2" + exit 32 +} + +# End-of-job cleanup. +complete() { + ret=$1 + [ "$ret" -eq 0 ] || echo >&2 "$JOB_NAME: aborted ($ret)" +} + +# Abort build step on errors. +trap 'cancel $LINENO $BASH_COMMAND' ERR SIGINT SIGTERM SIGQUIT SIGHUP +# Clean up on program termination. +trap 'complete $?' EXIT + +teardown + + + + + + + + xterm + + + diff --git a/rig-project-create-drupal/env/jenkins/jobs/stop-review/config.xml b/rig-project-create-drupal/env/jenkins/jobs/stop-review/config.xml new file mode 100644 index 0000000..640bdd6 --- /dev/null +++ b/rig-project-create-drupal/env/jenkins/jobs/stop-review/config.xml @@ -0,0 +1,62 @@ + + + + Stop the 'review-projectname.hosting.example.net' environment. This job is managed in the project code repository, changes made via UI will be lost. + false + + + false + false + + + + true + false + false + false + + false + /opt/development/projectname/jenkins/env/workspace/deploy-review + + + #!/usr/bin/env bash +export DOCKER_ENV=review +export COMPOSE_PROJECT_NAME=projectname_${DOCKER_ENV:--local} +export COMPOSE_FILE=build.devcloud.yml +export SITE_DOMAIN=${DOCKER_ENV}-projectname.hosting.example.net + +# Break down the Docker environment +teardown() { + docker-compose -f docker-compose.yml stop + docker-compose -f docker-compose.yml rm -f +} + +# Handler for errors or other interruptions. +cancel() { + echo "$JOB_NAME: Error: Line $1: $2" + exit 32 +} + +# End-of-job cleanup. +complete() { + ret=$1 + [ "$ret" -eq 0 ] || echo >&2 "$JOB_NAME: aborted ($ret)" +} + +# Abort build step on errors. +trap 'cancel $LINENO $BASH_COMMAND' ERR SIGINT SIGTERM SIGQUIT SIGHUP +# Clean up on program termination. +trap 'complete $?' EXIT + +teardown + + + + + + + + xterm + + + diff --git a/rig-project-create-drupal/jenkins.yml b/rig-project-create-drupal/jenkins.yml new file mode 100644 index 0000000..3a34a75 --- /dev/null +++ b/rig-project-create-drupal/jenkins.yml @@ -0,0 +1,26 @@ +# Container for running Jenkins with a local jobs volume +# Run this image via +# - `docker-compose -f jenkins.yml -p projectname run jenkins` +version: '2.1' + +services: + jenkins: + image: outrigger/jenkins-docker:latest + volumes: + # Primary jenkins configuration. Direct file mount prevents writing updates from running instance. + - ./env/jenkins/config.xml:/var/jenkins_home/config.xml + # Mount the local project jobs into Jenkins + - ./env/jenkins/jobs:/var/jenkins_home/jobs + # Mount the docker socket so we can execute from within this container + - /var/run/docker.sock:/var/run/docker.sock + # Mount a stable location for the Jenkins workspace + - /opt/development/projectname/jenkins/env/workspace:/opt/development/projectname/jenkins/env/workspace + # SSH key grants read access to private Git repositories. + - ~/.ssh/${OUTRIGGER_SSH_KEY:-id_rsa}:/root/.ssh/outrigger.key + network_mode: "bridge" + environment: + VIRTUAL_HOST: build.projectname.hosting.example.net + VIRTUAL_PORT: 8080 + labels: + com.dnsdock.name: jenkins + com.dnsdock.image: projectname diff --git a/rig-project-create-drupal/outrigger.yml b/rig-project-create-drupal/outrigger.yml new file mode 100644 index 0000000..1e0b2f8 --- /dev/null +++ b/rig-project-create-drupal/outrigger.yml @@ -0,0 +1,130 @@ +## +# This is an Outrigger configuration file used by rig project commands. +## + +version: 1.0 + +# This is prepended to the $PATH for any commands referenced in the scripts section. +bin: ./bin:./node_modules/.bin:./vendor/bin + +# This is not currently used but we include it in anticipation of great things. +project: projectname + +# Project Scripts +# These can be run via 'rig project run:' +# If you specify an alias, you can run 'rig project ' +scripts: + + run: + alias: run + description: Run one of the build container services such as 'cli' or 'drush'. + run: + - docker-compose -f build.yml run --rm + + up: + alias: up + description: Start up operational docker containers and filesystem sync. + run: + - rig project sync:start + - docker-compose up -d + + stop: + alias: stop + description: Halt operational containers and filesystem sync. + run: + - docker-compose stop + - rig project sync:stop + + build: + alias: build + description: Run the end-to-end build process. + run: + # COMPOSE_FILE is an environment variable provided by docker-compose. + # It is an alternative to the -f flag which selects config files. + # We use different docker-compose configurations for Linux than for macOS + # or Windows, because Linux can run Docker natively while others need + # a Virtual Machine. + # + # Environment variables set in configured scripts this way only last + # until the end of the script execution. + # + # See https://docs.docker.com/compose/reference/envvars/#compose_file + # See https://docs.docker.com/compose/reference/overview/#use--f-to-specify-name-and-path-of-one-or-more-compose-files + - export COMPOSE_FILE=build.yml + - docker-compose run --rm cli "NPM_CONFIG_LOGLEVEL=error npm install" + - docker-compose run --rm grunt --timer + + install: + alias: install + description: Install the Drupal site. + run: + - echo "'grunt install' is defined as a grunt task." + - echo "Drop the --no-db-load to auto-load build/backups/latest.sql.gz if present." + - export COMPOSE_FILE=build.yml + - docker-compose run --rm grunt install --no-db-load + - echo "Visit $(docker-compose run --rm drush sa @projectname --format=list --fields=uri)" + + update: + description: Update the Drupal database to match current code. + run: + - echo "'grunt update' is defined in Gruntconfig.json\n" + - export COMPOSE_FILE=build.yml + - docker-compose run --rm grunt update + - echo "Visit $(docker-compose run --rm drush sa @projectname --format=list --fields=uri)" + + theme: + alias: theme + description: Compile all theme assets, activate watch, and start up pattern-lab. + run: + - docker-compose -f build.yml run --rm theme + + fix-permissions: + alias: fix-perms + description: Fix permissions for Apache to run code and access files. (Automatically run as part of rig project install.) + run: + - docker-compose exec www /var/www/bin/fix-perms.sh + # grunt cache-clear is defined in Gruntconfig.json as an abstraction over drush cc all and drush cr + - docker-compose -f build.yml run --rm grunt cache-clear + + ps: + description: Get a list of all containers associated with this project. Unlike docker-compose ps, this will include all containers even for different configuration files. + run: + - docker ps -a --filter "label=outrigger.project=projectname" + + all-stop: + description: Halt all containers associated with this project. + run: + - rig project run:ps -- -q | xargs docker stop + + logs: + alias: logs + description: Stream the logs produced by your Docker project containers. To limit output add '--tail=20'. + run: + - docker-compose logs -ft + + setup: + alias: setup + description: Run the end-to-end repository initialization and site install script. + run: + - rig project run:welcome + - echo "Continuing with 'rig project setup'..." + - rig project up + - rig project build + - rig project install + - rig project run "grunt seed-users" + - echo "Congratulations, your new projectname instance is fully set up." + - echo "From now on, use 'rig project up' to start your work sessions." + + welcome: + alias: tour + description: Codebase orientation. + run: + - echo 'Welcome to the Project!' + - echo 'Please review the README.md, CONTRIBUTING.md, TODOS.md, and the docs/ folder.' + - echo 'All custom code is under src/' + - echo 'To get started, run "rig project setup"' + +# This controls configuration for the `project sync:start` command. +sync: + # This is the name of the external volume to use. + volume: projectname-sync diff --git a/rig-project-create-drupal/package.json b/rig-project-create-drupal/package.json new file mode 100644 index 0000000..40c9b52 --- /dev/null +++ b/rig-project-create-drupal/package.json @@ -0,0 +1,20 @@ +{ + "name": "projectname", + "description": "Demo of 'rig project create' output with most features enabled.", + "version": "0.1.0", + "engines": { + "node": ">=0.12.0", + "npm": "2.x" + }, + "private": true, + "scripts": { + "start": "grunt --timer", + "stop": "grunt clean:default", + "test": "grunt validate && grunt test" + }, + "dependencies": { + "grunt": "^1.0.0", + "grunt-drupal-tasks": "~1.0.0", + "zombie": "^2.5.1" + } +} diff --git a/rig-project-create-drupal/phpmd.xml b/rig-project-create-drupal/phpmd.xml new file mode 100644 index 0000000..6f8aa93 --- /dev/null +++ b/rig-project-create-drupal/phpmd.xml @@ -0,0 +1,22 @@ + + + + + Ruleset for PHPMD analysis of Drupal projects. Excludes coding issues + handled better by PHPCS and rules which have too many false positives + in a typical Drupal codebase. + + + + + + + + + + + diff --git a/rig-project-create-drupal/src/libraries/.gitkeep b/rig-project-create-drupal/src/libraries/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/rig-project-create-drupal/src/modules/.gitkeep b/rig-project-create-drupal/src/modules/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/rig-project-create-drupal/src/profiles/.gitkeep b/rig-project-create-drupal/src/profiles/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/rig-project-create-drupal/src/sites/default/.gitkeep b/rig-project-create-drupal/src/sites/default/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/rig-project-create-drupal/src/sites/settings.common.php b/rig-project-create-drupal/src/sites/settings.common.php new file mode 100644 index 0000000..0fad8ef --- /dev/null +++ b/rig-project-create-drupal/src/sites/settings.common.php @@ -0,0 +1,36 @@ + 'projectname_drupal', + 'username' => 'admin', + 'password' => 'admin', + 'prefix' => '', + 'host' => 'db', + 'port' => '', + 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', + 'driver' => 'mysql', +); + +// SMTP module settings for connection to the MailHog container. +$conf['smtp_host'] = 'mail'; +$conf['smtp_port'] = '1025'; + + +// Include local settings file as an override. +// settings.local.php should not be committed to the Git repository. +if (file_exists(__DIR__ . '/settings.local.php')) { + include __DIR__ . '/settings.local.php'; +} diff --git a/rig-project-create-drupal/src/static/.gitkeep b/rig-project-create-drupal/src/static/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/rig-project-create-drupal/src/themes/.gitkeep b/rig-project-create-drupal/src/themes/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/rig-project-create-drupal/test/behat.yml b/rig-project-create-drupal/test/behat.yml new file mode 100644 index 0000000..4e5d177 --- /dev/null +++ b/rig-project-create-drupal/test/behat.yml @@ -0,0 +1,26 @@ +default: + suites: + default: + contexts: + - FeatureContext + - Drupal\DrupalExtension\Context\DrupalContext + - Drupal\DrupalExtension\Context\MinkContext + extensions: + Behat\MinkExtension: + goutte: ~ + selenium2: ~ + zombie: ~ + javascript_session: 'zombie' + Drupal\DrupalExtension: + blackbox: ~ + drush: + alias: 'projectname' + drupal: + drupal_root: './build/html' + api_driver: 'drupal' + +ci: + formatter: + name: junit + parameters: + output_path: behat_junit