Skip to content

Instantly share code, notes, and snippets.

@chrisroane
Created November 22, 2017 22:08
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save chrisroane/90d416a0db6b3669a47c3df18960e55b to your computer and use it in GitHub Desktop.
# Set defaults to use for each job.
# https://circleci.com/docs/2.0/workflows/#using-workspaces-to-share-data-among-jobs
# To update the docker image, change the docker file in this repo: https://github.com/chrisroane/frontlinedocker
# Here is the docker hub repo: https://hub.docker.com/r/chrisroane/frontlinedocker/
defaults: &defaults
docker:
- image: chrisroane/frontlinedocker:latest
working_directory: ~/medstat
environment:
TZ: "/usr/share/zoneinfo/America/New_York"
version: 2
jobs:
build:
<<: *defaults
parallelism: 2
steps:
- checkout
# If the cache was already created, use that.
- restore_cache:
key: v2-dependency-cache-{{ checksum "package.json" }}
# Install the necessary dependencies.
- run:
name: Install Dependencies
command: |
chmod +x ~/medstat/.circleci/build.sh
bash ~/medstat/.circleci/build.sh
# Save the cache directories.
- save_cache:
key: v2-dependency-cache-{{ checksum "package.json" }}
paths:
- $HOME/.composer/cache
- ~/medstat/vendor
- ~/medstat/.aquifer
- ~/.drush
- ~/solr
- ~/medstat/node_modules
- ~/.terminus
- ~/terminus
# Make sure the PHP + JS code passes validation.
- run:
name: Linting
command: case $CIRCLE_NODE_INDEX in 0) gulp phpcs --exit ;; 1) gulp eslint ;; esac
# Run aquifer build.
- run:
name: Aquifer Build
command: aquifer build
# Install Registry rebuild module.
- run:
name: Install Registry Rebuild Module
command: drush @medstat.local dl registry_rebuild-7.x-2.3 -n
# Update hosts file.
- run:
name: Update Host File and Restart Apache
command: |
echo 127.0.0.1 medstat.local | tee -a /etc/hosts
sudo service apache2 restart
# Start Selenium.
- run:
name: Start Selenium
command: xvfb-run java -Dwebdriver.chrome.driver=/usr/local/bin/chromedriver -jar ~/selenium-server-standalone-3.3.1.jar
background: true
# Start Solr.
- run:
name: Start Solr
command: cd $HOME/solr/example/; java -jar start.jar >> $HOME/solr.log
background: true
# Restore the db cache.
- restore_cache:
keys:
- v1-db-cache
# Get the fresh database.
- run:
name: Copy Fresh DB Backup
no_output_timeout: 720
command: aquifer run fresh-ci
# Run updates, cache clears, etc.
- run:
name: Final Aquifer Command - Clear drupal caches
command: aquifer run local
# Prevent issues with the files directory.
- run:
name: Update Directory Permissions
command: |
sudo chown -R www-data:www-data ~/medstat/files
sudo chmod -R 777 ~/medstat/files
# Save the db cache directory.
- save_cache:
key: v1-db-cache
paths:
- db
# Create error screenshots directory.
- run:
name: Create Error Screenshots Directory
command: |
mkdir /tmp/behat_screenshots
chmod 777 /tmp/behat_screenshots
# Run Behat Tests in parallel.
- run:
name: Run Behat Tests
command: case $CIRCLE_NODE_INDEX in 0) behat -c behat.local.yml --tags "@node-0&&~@wip" ;; 1) behat -c behat.local.yml --tags "@node-1&&~@wip" ;; esac
# Store the artifacts.
- store_artifacts:
path: /tmp/behat_screenshots
# This is meant to push the code from github master to the Pantheon dev environment.
push_to_pantheon_dev:
<<: *defaults
steps:
- checkout
# Restore cache.
- restore_cache:
keys:
- v2-dependency-cache-{{ checksum "package.json" }}
- v1-db-cache
# Setup paths to installed software.
- run:
name: Setup Paths
command: |
chmod +x ~/medstat/.circleci/deploy.sh
bash ~/medstat/.circleci/deploy.sh
# Run aquifer build.
- run:
name: Aquifer Build
command: aquifer build
# Deploy to the master branch on Pantheon.
- run:
name: Deploy Code to Dev Pantheon
command: |
git config --global user.email "devs@fourkitchens.com"
git config --global user.name "Deploy Bot"
aquifer deploy-git -m "Automated deployment at $CIRCLE_SHA1" -b "master" -n "Deploy Bot" -a "devs@fourkitchens.com"
# Refresh the dev environment against the new codebase.
- run:
name: Final Aquifer Command - Clear drupal caches on Pantheon Dev
command: aquifer run dev
workflows:
version: 2
build_and_test:
jobs:
# Install the dev dependencies, import database and run the behat tests.
- build
# Push to the Pantheon Dev environment.
- push_to_pantheon_dev:
requires:
- build
filters:
branches:
only: master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment