.circleci/config.yml
defaults: &defaults
working_directory: ~/repo
docker:
- image: circleci/node:12.0
whitelist: &whitelist
paths:
- .git
- .npmignore
- coverage/*
- dist/*
- node_modules/*
- src/*
- package.json
- README.md
- nutriScore.js
- .gitignore
- jest.config.js
- yarn.lock
- tsconfig.json
- tslint.json
version: 2
jobs:
checkout:
<<: *defaults
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
- v1-dependencies-
- run:
name: Install Dependencies
command: yarn install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
- persist_to_workspace:
root: ~/repo
<<: *whitelist
lint:
<<: *defaults
steps:
- attach_workspace:
at: ~/repo
- run:
name: Lint TypeScript code
command: yarn lint
browserify:
<<: *defaults
steps:
- attach_workspace:
at: ~/repo
- run:
name: Install browserify
command: yarn global add browserify
- run:
name: Browserify TypeScript code
command: yarn browserify
test:
<<: *defaults
steps:
- attach_workspace:
at: ~/repo
- 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: Run tests
command: |
./cc-test-reporter before-build
yarn coverage
./cc-test-reporter after-build --exit-code $?
- persist_to_workspace:
root: ~/repo
<<: *whitelist
coveralls:
<<: *defaults
steps:
- attach_workspace:
at: ~/repo
- run:
name: Submit coverage report to Coveralls.io
command: echo "skip coveralls"
build:
<<: *defaults
steps:
- attach_workspace:
at: ~/repo
- run:
name: Build TypeScript code
command: yarn build
- persist_to_workspace:
root: ~/repo
<<: *whitelist
deploy:
<<: *defaults
steps:
- attach_workspace:
at: ~/repo
- run:
name: Write NPM Token to ~/.npmrc
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
- run:
name: Install dot-json package
command: npm install dot-json
- run:
name: Write version to package.json
command: $(yarn bin)/dot-json package.json version ${CIRCLE_TAG:1}
- run:
name: Publish to NPM
command: npm publish --access=public
workflows:
version: 2
build:
jobs:
- checkout
- test:
requires:
- checkout
- browserify:
requires:
- build
- lint:
requires:
- checkout
- build:
requires:
- test
- lint
release:
jobs:
- checkout:
filters:
tags:
only: /v[0-9]+(\.[0-9]+)*/
branches:
ignore: /.*/
- test:
filters:
tags:
only: /v[0-9]+(\.[0-9]+)*/
branches:
ignore: /.*/
requires:
- checkout
- lint:
filters:
tags:
only: /v[0-9]+(\.[0-9]+)*/
branches:
ignore: /.*/
requires:
- checkout
- build:
filters:
tags:
only: /v[0-9]+(\.[0-9]+)*/
branches:
ignore: /.*/
requires:
- test
- lint
- browserify:
requires:
- build
- deploy:
filters:
tags:
only: /v[0-9]+(\.[0-9]+)*/
branches:
ignore: /.*/
requires:
- build
- browserify