|
| 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 | +jobs: |
| 8 | + build: |
| 9 | + docker: |
| 10 | + - image: circleci/node:6.10.3 |
| 11 | + working_directory: ~/repo |
| 12 | + steps: |
| 13 | + - checkout |
| 14 | + - restore_cache: |
| 15 | + keys: |
| 16 | + - v{{ .Environment.CIRCLE_CACHE_VERSION }}-deps-{{ .Branch }}-{{ checksum "package.json" }} |
| 17 | + - v{{ .Environment.CIRCLE_CACHE_VERSION }}-deps-master-{{ checksum "package.json" }} |
| 18 | + - run: |
| 19 | + name: Install dependencies |
| 20 | + command: | |
| 21 | + npm install |
| 22 | + npm dedupe |
| 23 | + npm prune |
| 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 | + - run: |
| 32 | + name: Pretest |
| 33 | + command: | |
| 34 | + npm run pretest |
| 35 | + npm run cibuild |
| 36 | + - save_cache: |
| 37 | + paths: |
| 38 | + - node_modules |
| 39 | + key: v{{ .Environment.CIRCLE_CACHE_VERSION }}-deps-{{ .Branch }}-{{ checksum "package.json" }} |
| 40 | + - persist_to_workspace: |
| 41 | + root: . |
| 42 | + paths: |
| 43 | + - node_modules |
| 44 | + - build |
| 45 | + - dist |
| 46 | + |
| 47 | + test-jasmine: |
| 48 | + docker: |
| 49 | + # need '-browsers' version to test in real (xvfb-wrapped) browsers |
| 50 | + - image: circleci/node:6.10.3-browsers |
| 51 | + working_directory: ~/repo |
| 52 | + steps: |
| 53 | + - checkout |
| 54 | + - attach_workspace: |
| 55 | + at: ~/repo |
| 56 | + - run: |
| 57 | + name: Set timezone to Alaska time (arbitrary timezone to test date logic) |
| 58 | + command: | |
| 59 | + sudo cp /usr/share/zoneinfo/America/Anchorage /etc/localtime |
| 60 | + - run: |
| 61 | + name: Run jasmine tests |
| 62 | + command: ./.circleci/test.sh jasmine |
| 63 | + |
| 64 | + test-image: |
| 65 | + docker: |
| 66 | + - image: circleci/node:6.10.3 |
| 67 | + - image: plotly/testbed:latest |
| 68 | + working_directory: ~/repo |
| 69 | + steps: |
| 70 | + - checkout |
| 71 | + - attach_workspace: |
| 72 | + at: ~/repo |
| 73 | + # https://circleci.com/docs/2.0/building-docker-images/ |
| 74 | + - setup_remote_docker |
| 75 | + - run: |
| 76 | + name: Run and setup container |
| 77 | + command: | |
| 78 | + npm run docker -- run |
| 79 | + npm run docker -- setup |
| 80 | + - run: |
| 81 | + name: Run image tests |
| 82 | + command: ./.circleci/test.sh image |
| 83 | + - store_artifacts: |
| 84 | + path: build |
| 85 | + |
| 86 | + test-syntax: |
| 87 | + docker: |
| 88 | + - image: circleci/node:6.10.3 |
| 89 | + working_directory: ~/repo |
| 90 | + steps: |
| 91 | + - checkout |
| 92 | + - attach_workspace: |
| 93 | + at: ~/repo |
| 94 | + - run: |
| 95 | + name: Run syntax tests |
| 96 | + command: ./.circleci/test.sh syntax |
| 97 | + |
| 98 | +workflows: |
| 99 | + version: 2 |
| 100 | + build-and-test: |
| 101 | + jobs: |
| 102 | + - build |
| 103 | + - test-jasmine: |
| 104 | + requires: |
| 105 | + - build |
| 106 | + - test-image: |
| 107 | + requires: |
| 108 | + - build |
| 109 | + - test-syntax: |
| 110 | + requires: |
| 111 | + - build |
0 commit comments