Skip to content

Instantly share code, notes, and snippets.

@purdy
Created April 22, 2019 12:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save purdy/b4c5874b3921ed740794284a2a999da3 to your computer and use it in GitHub Desktop.
Save purdy/b4c5874b3921ed740794284a2a999da3 to your computer and use it in GitHub Desktop.
This is our circleci config.yml file
# This is Journalistic's A&O CI workflow. Whenever we push code to github
# that's not the master branch, it needs to download the branch, push it up to
# Pantheon, create a CI environment, run the visual regression testing, and
# then run the cypress testing.
defaults: &defaults
docker:
- image: quay.io/pantheon-public/build-tools-ci:4.x
working_directory: ~/app
environment:
TZ: "/usr/share/zoneinfo/America/New_York"
ADMIN_USERNAME: admin
TERM: dumb
NOTIFY: 'scripts/github/add-commit-comment {project} {sha} "Created multidev environment [{site}#{env}]({dashboard-url})." {site-url}'
version: 2
jobs:
build:
<<: *defaults
steps:
- checkout
- run:
# Set TERMINUS_ENV and related environment variables.
# https://github.com/pantheon-systems/docker-build-tools-ci/blob/1.x/scripts/set-environment
name: dependencies
command: /build-tools-ci/scripts/set-environment
- run:
name: Global vars
# Override of https://github.com/stevector/docker-build-tools-ci/blob/master/dockerfiles/pantheon-ci-testing/scripts/set-up-global-vars.sh
command: ./.circleci/set-up-global-vars.sh
- run:
name: login, delete other ci environments
command: ./.circleci/scripts/pantheon/01-prepare
- add_ssh_keys:
fingerprints:
- "[ssh key fingerprint]"
- run:
name: prepare database for site-under test
command: ./.circleci/scripts/pantheon/02-init-site
- run:
name: Set TERMINUS_ENV for Backstop
command: |
mkdir globals
echo $TERMINUS_ENV > globals/TERMINUS_ENV
- persist_to_workspace:
root: .
paths:
- globals
backstop:
docker:
- image: quay.io/stevector/ci-backstop:latest
working_directory: ~/app
steps:
- checkout
- attach_workspace:
at: /tmp
- run:
name: Global vars
# Override of https://github.com/stevector/docker-build-tools-ci/blob/master/dockerfiles/pantheon-ci-testing/scripts/set-up-global-vars.sh
command: ./.circleci/set-up-global-vars.sh
- run:
name: run-backstop
command: cd backstop && ./run-backstop.sh
- store_artifacts:
path: /tmp/artifacts
destination: artifact
cypress:
docker:
- image: cypress/browsers:chrome67
working_directory: ~/app
steps:
- checkout
- attach_workspace:
at: /tmp
- run:
name: Global vars
# Override of https://github.com/stevector/docker-build-tools-ci/blob/master/dockerfiles/pantheon-ci-testing/scripts/set-up-global-vars.sh
command: ./.circleci/set-up-global-vars.sh
# find compatible cache from previous build,
# it should have same dependencies installed from package.json checksum
- restore_cache:
keys:
- cache-{{ .Branch }}-{{ checksum "package.json" }}
- run:
name: Install dependencies
command: npm ci
# run verify and then save cache.
# this ensures that the Cypress verified status is cached too
- run: npm run cy:verify
# save new cache folder if needed
- save_cache:
key: cache-{{ .Branch }}-{{ checksum "package.json" }}
paths:
- ~/.npm
- ~/.cache
- run:
name: Run tests
command: npm run e2e:record
# - run: npm run types
# - run: npm run stop-only
# all other test jobs will run AFTER this build job finishes
# to avoid reinstalling dependencies, we persist the source folder "app"
# and the Cypress binary to workspace, which is the fastest way
# for Circle jobs to pass files
- persist_to_workspace:
root: ~/
paths:
- app
- .cache/Cypress
workflows:
version: 2
build_and_test:
jobs:
- build
- backstop:
requires:
- build
- cypress:
requires:
- build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment