|
| 1 | +# Confused about syntax? Read this: |
| 2 | +# >> https://blog.daemonl.com/2016/02/yaml.html |
| 3 | + |
| 4 | +defaults: &defaults |
| 5 | + working_directory: ~/repo |
| 6 | + docker: |
| 7 | + - image: circleci/node:latest |
| 8 | + |
| 9 | +version: 2 |
| 10 | +jobs: |
| 11 | + checkout_code: |
| 12 | + <<: *defaults |
| 13 | + steps: |
| 14 | + - checkout |
| 15 | + - save_cache: |
| 16 | + key: v1-repo-{{ .Environment.CIRCLE_SHA1 }} |
| 17 | + paths: |
| 18 | + - ~/repo |
| 19 | + |
| 20 | + install_dependencies: |
| 21 | + <<: *defaults |
| 22 | + steps: |
| 23 | + - restore_cache: &repo |
| 24 | + key: v1-repo-{{ .Environment.CIRCLE_SHA1 }} |
| 25 | + - run: npm ci |
| 26 | + - persist_to_workspace: |
| 27 | + root: ~/repo |
| 28 | + paths: |
| 29 | + - node_modules |
| 30 | + |
| 31 | + unit_tests: |
| 32 | + docker: |
| 33 | + - image: circleci/node:latest |
| 34 | + environment: |
| 35 | + COVERALLS_SERVICE_NAME: circle-ci |
| 36 | + COVERALLS_REPO_TOKEN: $COVERALLS_REPO_TOKEN |
| 37 | + working_directory: ~/repo |
| 38 | + steps: |
| 39 | + - restore_cache: *repo |
| 40 | + - attach_workspace: |
| 41 | + at: ~/repo |
| 42 | + - run: |
| 43 | + name: Execute Jest unit tests |
| 44 | + command: npm run test-ci:prod |
| 45 | + - run: |
| 46 | + name: Report test coverage to Coveralls |
| 47 | + command: npm run report-coverage |
| 48 | + - store_test_results: |
| 49 | + path: reports |
| 50 | + - store_artifacts: |
| 51 | + path: reports/jest |
| 52 | + |
| 53 | + lint_typescript: |
| 54 | + <<: *defaults |
| 55 | + steps: |
| 56 | + - restore_cache: *repo |
| 57 | + - attach_workspace: |
| 58 | + at: ~/repo |
| 59 | + - run: |
| 60 | + name: Run TSLint against sourcefiles |
| 61 | + command: mkdir reports ; mkdir reports/tslint ; npm run lint-ts-ci |
| 62 | + - store_test_results: |
| 63 | + path: reports |
| 64 | + - store_artifacts: |
| 65 | + path: reports/tslint |
| 66 | + |
| 67 | + build_webpack: |
| 68 | + <<: *defaults |
| 69 | + steps: |
| 70 | + - restore_cache: *repo |
| 71 | + - attach_workspace: |
| 72 | + at: ~/repo |
| 73 | + - run: |
| 74 | + name: Test that the bundle builds correctly |
| 75 | + command: npm run webpack:prod |
| 76 | + |
| 77 | + build_storybook: |
| 78 | + <<: *defaults |
| 79 | + steps: |
| 80 | + - restore_cache: *repo |
| 81 | + - attach_workspace: |
| 82 | + at: ~/repo |
| 83 | + - run: |
| 84 | + name: Test that storybook builds correctly |
| 85 | + command: npm run storybook-publish |
| 86 | + - persist_to_workspace: |
| 87 | + root: ~/repo |
| 88 | + paths: |
| 89 | + - gh-site/storybook |
| 90 | + - gh-site/lib |
| 91 | + |
| 92 | + build_typedoc: |
| 93 | + <<: *defaults |
| 94 | + steps: |
| 95 | + - restore_cache: *repo |
| 96 | + - attach_workspace: |
| 97 | + at: ~/repo |
| 98 | + - run: |
| 99 | + name: Test that typedoc builds correctly |
| 100 | + command: npm run typedoc-publish |
| 101 | + - persist_to_workspace: |
| 102 | + root: ~/repo |
| 103 | + paths: |
| 104 | + - gh-site/tsdoc |
| 105 | + |
| 106 | + deploy_docs: |
| 107 | + docker: |
| 108 | + - image: circleci/node:latest |
| 109 | + environment: |
| 110 | + SOURCE_BRANCH: master |
| 111 | + TARGET_BRANCH: gh-pages |
| 112 | + working_directory: ~/repo |
| 113 | + steps: |
| 114 | + - restore_cache: *repo |
| 115 | + - attach_workspace: |
| 116 | + at: ~/repo |
| 117 | + - run: |
| 118 | + name: Upload docs to GitHub Pages |
| 119 | + command: | |
| 120 | + if [ $CIRCLE_BRANCH == $SOURCE_BRANCH ]; then |
| 121 | + git config --global user.email $GH_EMAIL |
| 122 | + git config --global user.name $GH_NAME |
| 123 | +
|
| 124 | + git clone $CIRCLE_REPOSITORY_URL out |
| 125 | +
|
| 126 | + cd out |
| 127 | + git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH |
| 128 | + git rm -rf . |
| 129 | + cd .. |
| 130 | +
|
| 131 | + cp -a gh-site/. out/. |
| 132 | +
|
| 133 | + mkdir -p out/.circleci && cp -a .circleci/. out/.circleci/. |
| 134 | + cd out |
| 135 | +
|
| 136 | + git add -A |
| 137 | + git commit -m "Automated deployment to GitHub Pages ${CIRCLE_SHA1}" --allow-empty |
| 138 | +
|
| 139 | + git push origin $TARGET_BRANCH |
| 140 | + fi |
| 141 | + |
| 142 | + release_beta: |
| 143 | + <<: *defaults |
| 144 | + steps: |
| 145 | + - restore_cache: *repo |
| 146 | + - attach_workspace: |
| 147 | + at: ~/repo |
| 148 | + - run: |
| 149 | + name: Deploy beta dist-tag to npm |
| 150 | + command: npx semantic-release -b staging |
| 151 | + |
| 152 | + release_latest: |
| 153 | + <<: *defaults |
| 154 | + steps: |
| 155 | + - restore_cache: *repo |
| 156 | + - attach_workspace: |
| 157 | + at: ~/repo |
| 158 | + - run: |
| 159 | + name: Create NPM credential file |
| 160 | + command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc |
| 161 | + - run: |
| 162 | + name: Promote beta tag to latest |
| 163 | + command: npm dist-tag add @osu-cass/sb-components@$(npm dist-tag ls @osu-cass/sb-components | grep 'beta' | grep -Po '\d+\.\d+\.\d+') latest |
| 164 | + |
| 165 | +workflows: |
| 166 | + version: 2 |
| 167 | + build_test_deploy: |
| 168 | + jobs: |
| 169 | + - checkout_code |
| 170 | + - install_dependencies: |
| 171 | + requires: |
| 172 | + - checkout_code |
| 173 | + - unit_tests: |
| 174 | + requires: |
| 175 | + - install_dependencies |
| 176 | + - lint_typescript: |
| 177 | + requires: |
| 178 | + - install_dependencies |
| 179 | + - build_webpack: |
| 180 | + requires: |
| 181 | + - unit_tests |
| 182 | + - build_storybook: |
| 183 | + requires: |
| 184 | + - unit_tests |
| 185 | + - build_typedoc: |
| 186 | + requires: |
| 187 | + - unit_tests |
| 188 | + - deploy_docs: |
| 189 | + requires: |
| 190 | + - build_storybook |
| 191 | + - build_typedoc |
| 192 | + filters: |
| 193 | + branches: |
| 194 | + only: master |
| 195 | + - release_beta: |
| 196 | + requires: |
| 197 | + - build_storybook |
| 198 | + - build_typedoc |
| 199 | + filters: |
| 200 | + branches: |
| 201 | + only: staging |
| 202 | + - release_latest: |
| 203 | + requires: |
| 204 | + - build_storybook |
| 205 | + - build_typedoc |
| 206 | + filters: |
| 207 | + branches: |
| 208 | + only: master |
| 209 | + |
0 commit comments