|
| 1 | +version: 2.0 |
| 2 | + |
| 3 | +# Inspired by: |
| 4 | +# https://github.com/CircleCI-Public/circleci-demo-workflows/blob/workspace-forwarding/.circleci/config.yml |
| 5 | +# https://circleci.com/docs/2.0/workflows/#using-workspaces-to-share-data-among-jobs |
| 6 | +# |
| 7 | +# For list of official CircleCI node.js images, go to: |
| 8 | +# https://hub.docker.com/r/circleci/node/tags/ |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + docker: |
| 13 | + - image: circleci/node:10.9.0 |
| 14 | + working_directory: ~/react-plotly.js |
| 15 | + steps: |
| 16 | + - checkout |
| 17 | + - restore_cache: |
| 18 | + keys: |
| 19 | + - v{{ .Environment.CIRCLE_CACHE_VERSION }}-deps-{{ .Branch }}-{{ checksum "package-lock.json" }} |
| 20 | + - v{{ .Environment.CIRCLE_CACHE_VERSION }}-deps-master-{{ checksum "package-lock.json" }} |
| 21 | + - run: |
| 22 | + name: Install dependencies |
| 23 | + command: | |
| 24 | + npm install |
| 25 | + - run: |
| 26 | + name: List dependency versions |
| 27 | + command: | |
| 28 | + echo "npm: $(npm --version)" |
| 29 | + echo "node: $(node --version)" |
| 30 | + npm ls || true |
| 31 | + - save_cache: |
| 32 | + paths: |
| 33 | + - node_modules |
| 34 | + key: v{{ .Environment.CIRCLE_CACHE_VERSION }}-deps-{{ .Branch }}-{{ checksum "package.json" }} |
| 35 | + - persist_to_workspace: |
| 36 | + root: . |
| 37 | + paths: |
| 38 | + - node_modules |
| 39 | + |
| 40 | + test: |
| 41 | + docker: |
| 42 | + # need '-browsers' version to test in real (xvfb-wrapped) browsers |
| 43 | + - image: circleci/node:10.9.0 |
| 44 | + working_directory: ~/react-plotly.js |
| 45 | + steps: |
| 46 | + - checkout |
| 47 | + - attach_workspace: |
| 48 | + at: ~/react-plotly.js |
| 49 | + - run: |
| 50 | + name: Run tests |
| 51 | + command: npm run test |
| 52 | + |
| 53 | +workflows: |
| 54 | + version: 2 |
| 55 | + build-and-test: |
| 56 | + jobs: |
| 57 | + - build |
| 58 | + - test: |
| 59 | + requires: |
| 60 | + - build |
0 commit comments