104 lines
3.2 KiB
YAML
104 lines
3.2 KiB
YAML
# Javascript Node CircleCI 2.0 configuration file
|
|
#
|
|
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
|
|
#
|
|
version: 2
|
|
jobs:
|
|
build:
|
|
docker:
|
|
# specify the version you desire here
|
|
- image: circleci/node:lts-browsers
|
|
|
|
# Specify service dependencies here if necessary
|
|
# CircleCI maintains a library of pre-built images
|
|
# documented at https://circleci.com/docs/2.0/circleci-images/
|
|
# - image: circleci/mongo:3.4.4
|
|
|
|
working_directory: ~/scorm-again
|
|
|
|
steps:
|
|
- checkout
|
|
|
|
# Update npm
|
|
- run:
|
|
name: update-npm
|
|
command: 'sudo npm install -g npm@latest'
|
|
|
|
# Download and cache dependencies
|
|
- restore_cache:
|
|
keys:
|
|
- v1-dependencies-{{ checksum "package.json" }}
|
|
# fallback to using the latest cache if no exact match is found
|
|
- v1-dependencies-
|
|
|
|
- run: npm install
|
|
|
|
- save_cache:
|
|
paths:
|
|
- node_modules
|
|
key: v1-dependencies-{{ checksum "package.json" }}
|
|
|
|
- run: mkdir reports dist docs
|
|
|
|
# Run mocha
|
|
- run:
|
|
name: npm test
|
|
command: ./node_modules/.bin/nyc ./node_modules/.bin/mocha --require @babel/register --recursive --timeout=10000 --exit --reporter mocha-junit-reporter --reporter-options mochaFile=reports/mocha/test-results.xml
|
|
when: always
|
|
|
|
# Run eslint
|
|
- run:
|
|
name: eslint
|
|
command: |
|
|
./node_modules/.bin/eslint ./ --format junit --output-file ./reports/eslint/eslint.xml
|
|
when: always
|
|
|
|
# Run coverage report for Code Climate
|
|
- run:
|
|
name: Setup Code Climate test-reporter
|
|
command: |
|
|
# download test reporter as a static binary
|
|
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
|
chmod +x ./cc-test-reporter
|
|
./cc-test-reporter before-build
|
|
when: always
|
|
|
|
- run:
|
|
name: code-coverage
|
|
command: |
|
|
mkdir coverage
|
|
# nyc report requires that nyc has already been run,
|
|
# which creates the .nyc_output folder containing necessary data
|
|
./node_modules/.bin/nyc report --reporter=text-lcov > coverage/lcov.info
|
|
./cc-test-reporter after-build -t lcov
|
|
when: always
|
|
|
|
# compile documentation
|
|
- run: ./node_modules/.bin/jsdoc -c .jsdoc.json -d ./docs ./src/
|
|
|
|
# run babel compile
|
|
- run: git config user.email "jputney@noverant.com" && git config user.name "Jonathan Putney"
|
|
- run: ./node_modules/.bin/grunt
|
|
- run: git add --all dist/
|
|
|
|
# run jsdoc
|
|
# - run: ./node_modules/.bin/jsdoc -c .jsdoc.json -d ./docs ./src/
|
|
# - run: git add --all docs/
|
|
|
|
# git commit and push dist and docs
|
|
- run: git commit -m "[skip ci] - Updating Dist and Docs" && git push origin master
|
|
|
|
# Upload results
|
|
|
|
- store_test_results:
|
|
path: reports
|
|
|
|
- store_artifacts:
|
|
path: ./reports/mocha/test-results.xml
|
|
|
|
- store_artifacts:
|
|
path: ./reports/eslint/eslint.xml
|
|
|
|
- store_artifacts: # upload test coverage as artifact
|
|
path: ./coverage/lcov.info
|
|
prefix: tests |