|
|
|
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: ~/mern-starter # directory where steps will run
|
|
|
|
docker: # run the steps with Docker
|
|
|
|
- image: circleci/node:10 # ...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: update-npm
|
|
|
|
command: 'sudo npm install -g npm@latest'
|
|
|
|
- restore_cache: # special step to restore the dependency cache
|
|
|
|
key: dependency-cache-{{ checksum "package.json" }}
|
|
|
|
- run:
|
|
|
|
name: install-npm-wee
|
|
|
|
command: npm install
|
|
|
|
- save_cache: # special step to save the dependency cache
|
|
|
|
key: dependency-cache-{{ checksum "package.json" }}
|
|
|
|
paths:
|
|
|
|
- ./node_modules
|
|
|
|
- run: # run tests
|
|
|
|
name: Start server in background
|
|
|
|
command: node server.js --port=8880
|
|
|
|
background: true
|
|
|
|
- run:
|
|
|
|
name: Valid HTTP Request to server
|
|
|
|
command: wget --retry-connrefused --waitretry=1 --timeout=15 -t 10 http://localhost:8880
|
|
|
|
- run:
|
|
|
|
name: Bad HTTP Request to server
|
|
|
|
command: 'wget --retry-connrefused --waitretry=1 --timeout=15 -t 10 http://localhost:8880/invalid || :'
|
|
|
|
- run:
|
|
|
|
name: Run server without request
|
|
|
|
command: node server.js --test --port=8888
|
|
|
|
- store_artifacts: # special step to save test results as as artifact
|
|
|
|
path: test-results.xml
|
|
|
|
prefix: tests
|
|
|
|
- store_artifacts:
|
|
|
|
path: coverage
|
|
|
|
prefix: coverage
|
|
|
|
- store_test_results: # special step to upload test results for display in Test Summary
|
|
|
|
path: test-results.xml
|
|
|
|
# See https://circleci.com/docs/2.0/deployment-integrations/ for deploy examples
|