Skip to content

Commit

Permalink
use multiple node versions
Browse files Browse the repository at this point in the history
  • Loading branch information
lujiajing1126 committed Jan 7, 2019
1 parent 483a1ab commit 1110881
Showing 1 changed file with 60 additions and 25 deletions.
85 changes: 60 additions & 25 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,73 @@
#
# 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:11.5

# 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: ~/repo
version: 2.1

commands:
test-nodejs:
steps:
- run:
name: Versions
command: npm version
- checkout

# 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: yarn install

- v{{ .Environment.CIRCLE_CACHE_VERSION }}-{{ arch }}-npm-cache-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}
- v{{ .Environment.CIRCLE_CACHE_VERSION }}-{{ arch }}-npm-cache-master-{{ .Environment.CIRCLE_JOB }}
- run:
name: Install dependencies
command: npm ci
- run:
name: Test
command: npm test
- save-npm-cache
test-nodejs-v6:
steps:
- run:
name: Versions
command: npm version
- checkout
- restore_cache:
keys:
- v{{ .Environment.CIRCLE_CACHE_VERSION }}-{{ arch }}-npm-lock-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package-lock.json" }}
- v{{ .Environment.CIRCLE_CACHE_VERSION }}-{{ arch }}-npm-lock-master-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package-lock.json" }}
- v{{ .Environment.CIRCLE_CACHE_VERSION }}-{{ arch }}-npm-cache-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}
- v{{ .Environment.CIRCLE_CACHE_VERSION }}-{{ arch }}-npm-cache-master-{{ .Environment.CIRCLE_JOB }}
- run:
name: Install dependencies
command: npm install
- run:
name: Test
command: npm test
- save-npm-lock
- save-npm-cache
save-npm-lock:
steps:
- save_cache:
key: v{{ .Environment.CIRCLE_CACHE_VERSION }}-{{ arch }}-npm-lock-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package-lock.json" }}
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}

# run tests!
- run: yarn test
save-npm-cache:
steps:
- save_cache:
key: v{{ .Environment.CIRCLE_CACHE_VERSION }}-{{ arch }}-npm-cache-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package-lock.json" }}
paths:
- ~/.npm/_cacache


jobs:
node-v6:
docker:
- image: node:6
steps:
- test-nodejs-v6
node-v8:
docker:
- image: node:8
steps:
- test-nodejs
node-v10:
docker:
- image: node:10
steps:
- test-nodejs

0 comments on commit 1110881

Please sign in to comment.