.circleci/config.yml
version: 2 # use CircleCI 2.0
jobs: # a collection of steps
build: # runs not using Workflows must have a `build` job as entry point
working_directory: ~/template-generator # directory where steps will run
docker: # run the steps with Docker
- image: circleci/node:carbon # ...with this image as the primary container; this is where all `steps` will run
steps: # a collection of executable commands
- checkout # special step to check out source code to working directory
- run:
name: Install project dependencies
command: sudo npm install -g npm@latest && npm install
- restore_cache: # special step to restore the dependency cache
# Read about caching dependencies: https://circleci.com/docs/2.0/caching/
key: dependency-cache-{{ checksum "package.json" }}
- save_cache: # special step to save the dependency cache
key: dependency-cache-{{ checksum "package.json" }}
paths:
- ./node_modules
- run: # run coverage report
name: Install 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 # https://github.com/codeclimate/test-reporter/issues/260#issuecomment-369783913
npm test --coverage
./cc-test-reporter after-build $CC_TEST_REPORTER_ID --exit-code $?
- store_artifacts: # special step to save test results as as artifact
# Upload test summary for display in Artifacts: https://circleci.com/docs/2.0/artifacts/
path: test-results.xml
prefix: tests
- store_artifacts: # for display in Artifacts: https://circleci.com/docs/2.0/artifacts/
path: coverage
prefix: coverage
- store_test_results: # for display in Test Summary: https://circleci.com/docs/2.0/collect-test-data/
path: test-results.xml