.circleci/config.yml
version: 2
docker_defaults: &docker_defaults
docker:
- image: circleci/node:8
working_directory: ~/project/status-board
attach_workspace: &attach_workspace
attach_workspace:
at: ~/project
install_steps: &install_steps
steps:
- checkout
- *attach_workspace
- restore_cache:
name: Restore node_modules cache
keys:
- node-modules-{{ .Branch }}-{{ checksum "package-lock.json" }}
- node-modules-{{ .Branch }}-
- node-modules-
- run:
name: Install Greenkeeper Packages
command: |
sudo npm install -g greenkeeper-lockfile@1
- run:
name: Install Dependencies
command: npm install
- run:
name: Updating Lockfiles
command: |
greenkeeper-lockfile-update
greenkeeper-lockfile-upload
greenkeeper-shrinkwrap-update
greenkeeper-shrinkwrap-upload
- save_cache:
name: Save node_modules cache
key: node-modules-{{ .Branch }}-{{ checksum "package-lock.json" }}
paths:
- node_modules/
- persist_to_workspace:
root: ~/project
paths:
- status-board
test_steps: &test_steps
steps:
- checkout
- restore_cache:
key: node-modules-{{ .Branch }}-{{ checksum "package-lock.json" }}
- run:
name: Install Local Packages
command: npm install
- run:
name: Test Suite
command: npm run test:ci
jobs:
install:
<<: *docker_defaults
<<: *install_steps
npmvet:
<<: *docker_defaults
steps:
- *attach_workspace
- run:
name: NPM Vet
command: |
sudo npm i -g npmvet
npm run verify:npmvet
audit:
<<: *docker_defaults
steps:
- *attach_workspace
- run:
name: NPM Audit Fix
command: npm audit fix
tslint:
<<: *docker_defaults
steps:
- *attach_workspace
- run:
name: Create TSLint report directory
command: mkdir reports && mkdir reports/tslint
- run:
name: TSLint
command: npm run tslint
- store_artifacts:
path: reports/tslint
test-node-6:
working_directory: ~/status-board
docker:
- image: circleci/node:6
<<: *test_steps
test-node-8:
<<: *docker_defaults
<<: *test_steps
test-node-10:
working_directory: ~/status-board
docker:
- image: circleci/node:10
<<: *test_steps
test-node-11:
working_directory: ~/status-board
docker:
- image: circleci/node:10
<<: *test_steps
coverage:
<<: *docker_defaults
steps:
- *attach_workspace
- run:
name: Setup Code Climate test-reporter
command: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
- run:
name: Coverage
environment:
JEST_JUNIT_OUTPUT: reports/jest/jest-test-results.xml
command: |
./cc-test-reporter before-build
npm run test:coverage:ci
./cc-test-reporter after-build --exit-code $?
npm run test:coverage:codecov
- store_artifacts:
path: coverage
- store_artifacts:
path: reports/jest
- store_test_results:
path: reports
build-typescript:
<<: *docker_defaults
steps:
- *attach_workspace
- run:
name: Build JavaScript
command: npm run ts:build
- persist_to_workspace:
root: ~/project
paths:
- status-board
semantic-release:
<<: *docker_defaults
steps:
- *attach_workspace
- run:
name: Avoid hosts unknown for github
command: mkdir ~/.ssh/ && echo -e "Host github.com\n\tStrictHostKeyChecking no\n" > ~/.ssh/config
- run:
name: Semantic Release
command: npm run semantic-release
workflows:
version: 2
install-test-build-and-publish:
jobs:
- install
- npmvet:
requires:
- install
- audit:
requires:
- npmvet
- tslint:
requires:
- audit
- test-node-6:
requires:
- tslint
- test-node-8:
requires:
- tslint
- test-node-10:
requires:
- tslint
- test-node-11:
requires:
- tslint
- coverage:
requires:
- test-node-6
- test-node-8
- test-node-10
- test-node-11
- build-typescript:
requires:
- coverage
- semantic-release:
requires:
- build-typescript