|
| 1 | +version: 2.1 |
| 2 | +aliases: |
| 3 | + - &save_git_cache |
| 4 | + save_cache: |
| 5 | + paths: |
| 6 | + - .git |
| 7 | + key: v1-git-{{ .Revision }} |
| 8 | + - &restore_git_cache |
| 9 | + restore_cache: |
| 10 | + keys: |
| 11 | + - v1-git-{{ .Revision }} |
| 12 | + - v1-git- |
| 13 | + - &save_build_cache |
| 14 | + save_cache: |
| 15 | + paths: |
| 16 | + - build |
| 17 | + key: v1-build-{{ .Revision }} |
| 18 | + - &restore_build_cache |
| 19 | + restore_cache: |
| 20 | + keys: |
| 21 | + - v1-build-{{ .Revision }} |
| 22 | + - &save_dist_cache |
| 23 | + save_cache: |
| 24 | + paths: |
| 25 | + - dist |
| 26 | + key: v1-dist-{{ .Revision }} |
| 27 | + - &restore_dist_cache |
| 28 | + restore_cache: |
| 29 | + keys: |
| 30 | + - v1-dist-{{ .Revision }} |
| 31 | + - &save_npm_cache |
| 32 | + save_cache: |
| 33 | + paths: |
| 34 | + - node_modules |
| 35 | + key: v1-npm-{{ checksum "package-lock.json" }} |
| 36 | + - &restore_npm_cache |
| 37 | + restore_cache: |
| 38 | + keys: |
| 39 | + - v1-npm-{{ checksum "package-lock.json" }} |
| 40 | + - v1-npm- |
| 41 | + - &defaults |
| 42 | + docker: |
| 43 | + - image: circleci/node:8.16-browsers |
| 44 | + working_directory: ~/repo |
| 45 | + |
| 46 | +jobs: |
| 47 | + setup: |
| 48 | + <<: *defaults |
| 49 | + steps: |
| 50 | + - *restore_git_cache |
| 51 | + - checkout |
| 52 | + - *restore_npm_cache |
| 53 | + - run: npm install |
| 54 | + - *save_git_cache |
| 55 | + - *save_npm_cache |
| 56 | + lint: |
| 57 | + <<: *defaults |
| 58 | + steps: |
| 59 | + - *restore_git_cache |
| 60 | + - checkout |
| 61 | + - *restore_npm_cache |
| 62 | + - run: |
| 63 | + name: Lint |
| 64 | + command: npm run test:lint -- --quiet --output-file test-results/eslint/results.xml --format junit |
| 65 | + - store_test_results: |
| 66 | + path: test-results |
| 67 | + unit: |
| 68 | + <<: *defaults |
| 69 | + environment: |
| 70 | + JEST_JUNIT_OUTPUT_NAME: results.xml |
| 71 | + steps: |
| 72 | + - *restore_git_cache |
| 73 | + - checkout |
| 74 | + - *restore_npm_cache |
| 75 | + - run: |
| 76 | + name: Unit |
| 77 | + environment: |
| 78 | + JEST_JUNIT_OUTPUT_DIR: test-results/unit |
| 79 | + command: npm run test:unit -- --reporters="default" --reporters="jest-junit" --coverage --coverageReporters=text --coverageReporters=lcov |
| 80 | + - store_artifacts: |
| 81 | + path: coverage |
| 82 | + - store_test_results: |
| 83 | + path: test-results |
| 84 | + build: |
| 85 | + <<: *defaults |
| 86 | + environment: |
| 87 | + NODE_ENV: production |
| 88 | + NODE_OPTIONS: --max-old-space-size=4000 |
| 89 | + steps: |
| 90 | + - *restore_git_cache |
| 91 | + - checkout |
| 92 | + - *restore_npm_cache |
| 93 | + - run: |
| 94 | + name: Build |
| 95 | + command: npm run build |
| 96 | + - *save_build_cache |
| 97 | + - *save_dist_cache |
| 98 | + store_build: |
| 99 | + <<: *defaults |
| 100 | + steps: |
| 101 | + - *restore_build_cache |
| 102 | + - store_artifacts: |
| 103 | + path: build |
| 104 | + store_dist: |
| 105 | + <<: *defaults |
| 106 | + steps: |
| 107 | + - *restore_dist_cache |
| 108 | + - store_artifacts: |
| 109 | + path: dist |
| 110 | + integration: |
| 111 | + <<: *defaults |
| 112 | + parallelism: 2 |
| 113 | + environment: |
| 114 | + JEST_JUNIT_OUTPUT_NAME: results.txt |
| 115 | + steps: |
| 116 | + - *restore_git_cache |
| 117 | + - checkout |
| 118 | + - *restore_npm_cache |
| 119 | + - *restore_build_cache |
| 120 | + - run: |
| 121 | + name: Integration |
| 122 | + environment: |
| 123 | + JEST_JUNIT_OUTPUT_DIR: test-results/integration |
| 124 | + command: | |
| 125 | + export TESTFILES=$(circleci tests glob "test/integration/*.test.js" | circleci tests split --split-by=timings) |
| 126 | + $(npm bin)/jest ${TESTFILES} --reporters="default" --reporters="jest-junit" |
| 127 | + - store_test_results: |
| 128 | + path: test-results |
| 129 | + |
| 130 | + deploy-npm: |
| 131 | + <<: *defaults |
| 132 | + environment: |
| 133 | + NODE_OPTIONS: --max-old-space-size=4000 |
| 134 | + steps: |
| 135 | + - *restore_git_cache |
| 136 | + - *restore_dist_cache |
| 137 | + - checkout |
| 138 | + - run: | |
| 139 | + echo export RELEASE_VERSION="0.1.0-prerelease.$(date +'%Y%m%d%H%M%S')" >> $BASH_ENV |
| 140 | + echo export NPM_TAG=circlelatest >> $BASH_ENV |
| 141 | + if [ "$CIRCLE_BRANCH" == "master" ] |
| 142 | + then echo export NPM_TAG=circlestable >> $BASH_ENV |
| 143 | + fi |
| 144 | + if [[ "$CIRCLE_BRANCH" == hotfix/* ]] # double brackets are important for matching the wildcard |
| 145 | + then echo export NPM_TAG=circlehotfix >> $BASH_ENV |
| 146 | + fi |
| 147 | + - run: npm version --no-git-tag-version $RELEASE_VERSION |
| 148 | + - run: | |
| 149 | + npm set //registry.npmjs.org/:_authToken=$NPM_TOKEN |
| 150 | + npm publish --tag $NPM_TAG |
| 151 | + - run: git tag $RELEASE_VERSION |
| 152 | + - run: git push $CIRCLE_REPOSITORY_URL $RELEASE_VERSION |
| 153 | + |
| 154 | + deploy-gh-pages: |
| 155 | + <<: *defaults |
| 156 | + steps: |
| 157 | + - *restore_git_cache |
| 158 | + - checkout |
| 159 | + - *restore_npm_cache |
| 160 | + - *restore_build_cache |
| 161 | + - run: | |
| 162 | + git config --global user.email $(git log --pretty=format:"%ae" -n1) |
| 163 | + git config --global user.name $(git log --pretty=format:"%an" -n1) |
| 164 | + - run: npm run deploy -- -e $CIRCLE_BRANCH |
| 165 | + |
| 166 | +workflows: |
| 167 | + version: 2 |
| 168 | + build-test-deploy: |
| 169 | + jobs: |
| 170 | + - setup |
| 171 | + - lint: |
| 172 | + requires: |
| 173 | + - setup |
| 174 | + - unit: |
| 175 | + requires: |
| 176 | + - setup |
| 177 | + - build: |
| 178 | + requires: |
| 179 | + - setup |
| 180 | + - integration: |
| 181 | + requires: |
| 182 | + - build |
| 183 | + - store_build: |
| 184 | + requires: |
| 185 | + - build |
| 186 | + - store_dist: |
| 187 | + requires: |
| 188 | + - build |
| 189 | + # Disable deployment while running in parallel with Travis |
| 190 | + # - deploy-npm: |
| 191 | + # requires: |
| 192 | + # - lint |
| 193 | + # - unit |
| 194 | + # - integration |
| 195 | + # - build |
| 196 | + # filters: |
| 197 | + # branches: |
| 198 | + # only: |
| 199 | + # - master |
| 200 | + # - develop |
| 201 | + # - /^hotfix\/.*/ |
| 202 | + # - deploy-gh-pages: |
| 203 | + # requires: |
| 204 | + # - lint |
| 205 | + # - unit |
| 206 | + # - integration |
| 207 | + # - build |
0 commit comments