.circleci/config.yml
version: 2
defaultFilters: &defaultFilters
filters:
branches:
only:
- beta
- 2.x
- 1.x
- master
- gh-pages
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.json" }}
- node-modules-{{ .Branch }}-
- node-modules-
- run:
name: Install Dependencies
command: npm i
- save_cache:
name: Save node_modules cache
key: node-modules-{{ .Branch }}-{{ checksum "package.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.json" }}
- run:
name: Install Local Packages
command: npm i
- 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
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-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:11
<<: *test_steps
test-node-12:
working_directory: ~/status-board
docker:
- image: circleci/node:12
<<: *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
- tslint:
requires:
- npmvet
- test-node-8:
requires:
- tslint
- test-node-10:
requires:
- tslint
- test-node-11:
requires:
- tslint
- test-node-12:
requires:
- tslint
- coverage:
requires:
- test-node-8
- test-node-10
- test-node-11
- test-node-12
- build-typescript:
requires:
- coverage
- semantic-release:
requires:
- build-typescript