.circleci/config.yml
version: 2
jobs:
build:
working_directory: ~/code-gov
docker:
- image: circleci/node:6.12.2-stretch
steps:
- checkout
- run:
name: Add Node Module's bin to PATH
command: echo "export PATH=`pwd`/node_modules/.bin:$PATH" >> $BASH_ENV
- restore_cache:
key: code-gov-web-{{ checksum "package.json" }}
- run:
name: Install Dependencies
command: npm install
- save_cache:
key: code-gov-web-{{ checksum "package.json" }}
paths:
- code-gov-web/node_modules
- run:
name: Run Linter
command: npm run lint
test:
working_directory: ~/code-gov
docker:
- image: circleci/node:6.12.2-stretch
steps:
- checkout
- run:
name: download-cc-test-reporter
command: curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- run:
name: make-test-reporter-executable
command: chmod +x ./cc-test-reporter
- run:
name: code-climate-before-build
command: ./cc-test-reporter before-build
- restore_cache:
key: code-gov-web-{{ checksum "package.json" }}
- run:
name: Install Dependencies
command: npm install
- save_cache:
key: code-gov-web-{{ checksum "package.json" }}
paths:
- code-gov-web/node_modules
- run:
name: Run Tests
command: npm test
- run:
name: upload-test-report
command: ./cc-test-reporter after-build -t lcov --exit-code $?
- store_test_results:
path: test-results.xml
- store_artifacts:
path: coverage
prefix: coverage
integration:
working_directory: ~/code-gov
docker:
- image: circleci/node:6.12-stretch-browsers
steps:
- checkout
- restore_cache:
key: code-gov-web-{{ checksum "package.json" }}
- run:
name: Install Dependencies
command: npm install
- save_cache:
key: code-gov-web-{{ checksum "package.json" }}
paths:
- code-gov-web/node_modules
- run:
name: Start Server
command: npm start
background: true
- run:
name: Run Integration Tests
command: npm run e2e
deploy-staging:
working_directory: ~/code-gov
docker:
- image: circleci/node:6.12-stretch
steps:
- checkout
- run:
name: Install Dependencies
command: npm install
- run:
name: set-git-user-info
command: |
git config --global user.name "CodeDotGov"
git config --global user.email "code@gsa.gov"
- run:
name: Deploy to Staging
command: npm run federalist-deploy:stag
deploy-production:
working_directory: ~/code-gov
docker:
- image: circleci/node:6.12-stretch
steps:
- checkout
- run:
name: Install Dependencies
command: npm install
- run:
name: set-git-user-info
command: |
git config --global user.name "CodeDotGov"
git config --global user.email "code@gsa.gov"
- run:
name: Deploy to Production
command: npm run federalist-deploy:prod
workflows:
version: 2
build-test-deploy:
jobs:
- build
- test:
requires:
- build
- integration:
requires:
- test
- hold:
type: approval
requires:
- integration
filters:
branches:
only: master
tags:
only: /^v(\d+\.){2}\d+$/
- deploy-staging:
requires:
- hold
filters:
branches:
only: master
- deploy-production:
requires:
- hold
filters:
tags:
only: /^v(\d+\.){2}\d+$/
branches:
ignore: /.*/