.circleci/config.yml
# Javascript Node CircleCI 2.0 configuration file
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
version: 2
jobs:
js_build:
docker:
- image: circleci/node:11
working_directory: ~/repo
steps:
- checkout
- type: cache-restore
name: Restore yarn cache
key: rails-demo-yarn-{{ checksum "yarn.lock" }}
- run: yarn install
- type: cache-save
name: Store yarn cache
key: rails-demo-yarn-{{ checksum "yarn.lock" }}
paths:
- ~/.yarn-cache
- run: yarn run test:react:coverage
- run: yarn run build
- persist_to_workspace:
root: ~/repo
paths:
- public/
ruby_build:
docker:
- image: circleci/ruby:2.6.7-node
environment:
PGHOST: 127.0.0.1
PGUSER: dashboard_test_user
RAILS_ENV: test
- image: circleci/postgres:9.5-alpine
environment:
POSTGRES_USER: dashboard_test_user
POSTGRES_DB: dashboard_test
POSTGRES_PASSWORD: ""
working_directory: ~/repo
steps:
- checkout
- attach_workspace:
at: ~/repo
- run:
name: Configure Bundler
command: |
echo 'export BUNDLER_VERSION=$(cat Gemfile.lock | tail -1 | tr -d " ")' >> $BASH_ENV
source $BASH_ENV
gem install bundler -v 2.1.4
- type: cache-restore
name: Restore bundle cache
key: perfdash-ruby-deps-{{ checksum "Gemfile.lock" }}
- run: bundle install --path vendor/bundle
- type: cache-save
name: Store bundle cache
key: perfdash-ruby-deps-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
- run: bundle exec rspec
deploy_staging:
docker:
- image: circleci/ruby:2.6.7-node
working_directory: ~/repo
steps:
- checkout
- attach_workspace:
at: ~/repo
- run: ls ~/repo/public
- run: curl -v -L -o cf-cli_amd64.deb 'https://cli.run.pivotal.io/stable?release=debian64&version=6.32.0&source=github-rel'
- run: sudo dpkg -i cf-cli_amd64.deb
- run: cf install-plugin https://github.com/govau/autopilot/releases/download/0.0.5-venapp/autopilot-linux -f
- run: cf login -a $CF_API_STAGING -u $CF_USERNAME -p $CF_PASSWORD_STAGING -o $CF_ORG -s $CF_SPACE
- run: cf zero-downtime-push dashboard-staging -f manifest-staging.yml -p .
deploy_production:
docker:
- image: circleci/ruby:2.6.7-node
working_directory: ~/repo
steps:
- checkout
- attach_workspace:
at: ~/repo
- run: ls ~/repo/public
- run: curl -F access_token=$ROLLBAR_ACCESS_TOKEN_SERVER -F environment=production -F revision=$CIRCLE_SHA1 -F rollbar_username=jonalport -F local_username=$CIRCLE_USERNAME -F comment='Circle deployed Performance Dashboard to prod' 'https://api.rollbar.com/api/1/deploy/'
- run: curl -v -L -o cf-cli_amd64.deb 'https://cli.run.pivotal.io/stable?release=debian64&version=6.32.0&source=github-rel'
- run: sudo dpkg -i cf-cli_amd64.deb
- run: cf install-plugin https://github.com/govau/autopilot/releases/download/0.0.5-venapp/autopilot-linux -f
- run: cf login -a $CF_API_PROD -u $CF_USERNAME -p $CF_PASSWORD_PROD -o $CF_ORG -s $CF_SPACE
- run: cf zero-downtime-push dashboard -f manifest-production.yml -p .
workflows:
version: 2
build_test_deploy:
jobs:
- js_build:
filters:
tags:
only: /.*/ # i.e. always build for all tags & branches
- ruby_build:
requires:
- js_build
filters:
tags:
only: /.*/ # i.e. always build for all tags & branches
- deploy_staging:
requires:
- ruby_build
filters:
branches:
only: /^master$/
- deploy_production:
requires:
- ruby_build
filters:
branches:
ignore:
/.*/
tags:
only: /release-.*/