|
1 |
| -# Javascript Node CircleCI 2.0 configuration file |
2 |
| -# |
3 |
| -# Check https://circleci.com/docs/2.0/language-javascript/ for more details |
4 |
| -# |
| 1 | +# Configuration file for https://circleci.com/gh/angular/flex-layout |
| 2 | +# based on the configuration for https://circleci.com/gh/angular/material2 |
| 3 | +# Credit for file goes to Paul Gschwendtner (@DevVersion) |
| 4 | + |
| 5 | +# Note: YAML anchors allow an object to be re-used, reducing duplication. |
| 6 | +# The ampersand declares an alias for an object, then later the `<<: *name` |
| 7 | +# syntax dereferences it. |
| 8 | +# See http://blog.daemonl.com/2016/02/yaml.html |
| 9 | +# To validate changes, use an online parser, eg. |
| 10 | +# http://yaml-online-parser.appspot.com/ |
| 11 | + |
| 12 | +var_1: &docker_image angular/ngcontainer:0.7.0 |
| 13 | +var_2: &cache_key v2-ng-layout-{{ .Branch }}-{{ checksum "yarn.lock" }}-0.7.0 |
| 14 | + |
| 15 | +# Settings common to each job |
| 16 | +var_3: &job_defaults |
| 17 | + working_directory: ~/ng |
| 18 | + docker: |
| 19 | + - image: *docker_image |
| 20 | + |
| 21 | +# Job step for checking out the source code from GitHub. This also ensures that the source code |
| 22 | +# is rebased on top of master. |
| 23 | +var_4: &checkout_code |
| 24 | + checkout: |
| 25 | + # After checkout, rebase on top of master. By default, PRs are not rebased on top of master, |
| 26 | + # which we want. See https://discuss.circleci.com/t/1662 |
| 27 | + post: git pull --ff-only origin "refs/pull/${CI_PULL_REQUEST//*pull\//}/merge" |
| 28 | + |
| 29 | +# Restores the cache that could be available for the current Yarn lock file. The cache usually |
| 30 | +# includes the node modules and the build cache. |
| 31 | +var_5: &restore_cache |
| 32 | + restore_cache: |
| 33 | + key: *cache_key |
| 34 | + |
| 35 | +# Saves the cache for the current Yarn lock file. We store the node modules and the build |
| 36 | +# cache in order to make subsequent builds faster. |
| 37 | +var_6: &save_cache |
| 38 | + save_cache: |
| 39 | + key: *cache_key |
| 40 | + paths: |
| 41 | + - "node_modules" |
| 42 | + |
| 43 | +# Job step that ensures that the node module dependencies are installed and up-to-date. We use |
| 44 | +# Yarn with the frozen lockfile option in order to make sure that lock file and package.json are |
| 45 | +# in sync. Unlike in Travis, we don't need to manually purge the node modules if stale because |
| 46 | +# CircleCI automatically discards the cache if the checksum of the lock file has changed. |
| 47 | +var_7: &yarn_install |
| 48 | + run: yarn install --frozen-lockfile --non-interactive |
| 49 | + |
| 50 | +# Sets up a different Docker image that includes a moe recent Firefox version which |
| 51 | +# is needed for headless testing. |
| 52 | +var_8: &docker-firefox-image |
| 53 | + # TODO(devversion): Temporarily use a image that includes Firefox 62 because the |
| 54 | + # ngcontainer image does include an old Firefox version that does not support headless. |
| 55 | + # See the PR that fixes this: https://github.com/angular/angular/pull/26435 |
| 56 | + - image: circleci/node:10.12-browsers |
| 57 | + |
| 58 | +# Attaches the release output which has been stored in the workspace to the current job. |
| 59 | +# https://circleci.com/docs/2.0/workflows/#using-workspaces-to-share-data-among-jobs |
| 60 | +var_9: &attach_release_output |
| 61 | + attach_workspace: |
| 62 | + at: dist/releases |
| 63 | + |
| 64 | +# ----------------------------- |
| 65 | +# Container version of CircleCI |
| 66 | +# ----------------------------- |
5 | 67 | version: 2
|
| 68 | + |
| 69 | +# ----------------------------------------------------------------------------------------- |
| 70 | +# Job definitions. Jobs which are defined just here, will not run automatically. Each job |
| 71 | +# must be part of a workflow definition in order to run for PRs and push builds. |
| 72 | +# ----------------------------------------------------------------------------------------- |
6 | 73 | jobs:
|
| 74 | + |
| 75 | + # ----------------------------------- |
| 76 | + # Build job |
| 77 | + # ----------------------------------- |
7 | 78 | build:
|
8 |
| - docker: |
9 |
| - # specify the version you desire here |
10 |
| - - image: circleci/node:8.9 |
| 79 | + <<: *job_defaults |
| 80 | + steps: |
| 81 | + - *checkout_code |
| 82 | + - *restore_cache |
| 83 | + - *yarn_install |
| 84 | + |
| 85 | + - run: yarn gulp :publish:build-releases |
| 86 | + |
| 87 | + # Note: We want to save the cache in this job because the workspace cache also |
| 88 | + # includes the build cache that will be updated in this job. |
| 89 | + - *save_cache |
| 90 | + |
| 91 | + # ------------------------------------------------------------------------------------------ |
| 92 | + # Job that runs the unit tests on locally installed browsers (Chrome and Firefox headless). |
| 93 | + # The available browsers are installed through the angular/ngcontainer Docker image. |
| 94 | + # ------------------------------------------------------------------------------------------ |
| 95 | + tests_local_browsers: |
| 96 | + docker: *docker-firefox-image |
| 97 | + steps: |
| 98 | + - *checkout_code |
| 99 | + - *restore_cache |
| 100 | + - *yarn_install |
| 101 | + |
| 102 | + - run: ./scripts/circleci/run-local-browser-tests.sh |
| 103 | + |
| 104 | + # ---------------------------------------------------------------------------- |
| 105 | + # Job that runs the unit tests on Browserstack. The browsers that will be used |
| 106 | + # to run the unit tests on Browserstack are set in: test/browser-providers.js |
| 107 | + # ---------------------------------------------------------------------------- |
| 108 | + tests_browserstack: |
| 109 | + <<: *job_defaults |
| 110 | + environment: |
| 111 | + BROWSER_STACK_USERNAME: "adamplumer1" |
| 112 | + BROWSER_STACK_ACCESS_KEY: "WgLjxoB2zQ3tqmsznKnz" |
| 113 | + steps: |
| 114 | + - *checkout_code |
| 115 | + - *restore_cache |
| 116 | + - *yarn_install |
| 117 | + |
| 118 | + - run: ./scripts/circleci/run-browserstack-tests.sh |
| 119 | + |
| 120 | + # ---------------------------------------------------------------------------- |
| 121 | + # Job that runs the unit tests on Saucelabs. The browsers that will be used |
| 122 | + # to run the unit tests on Saucelabs are set in: test/browser-providers.js |
| 123 | + # ---------------------------------------------------------------------------- |
| 124 | + tests_saucelabs: |
| 125 | + <<: *job_defaults |
| 126 | + environment: |
| 127 | + SAUCE_USERNAME: "angular-ci" |
| 128 | + SAUCE_ACCESS_KEY: "9b988f434ff8-fbca-8aa4-4ae3-35442987" |
| 129 | + # Note: This number should not be too high because otherwise we might run into |
| 130 | + # a rate limit exception. |
| 131 | + KARMA_PARALLEL_BROWSERS: 2 |
| 132 | + steps: |
| 133 | + - *checkout_code |
| 134 | + - *restore_cache |
| 135 | + - *yarn_install |
| 136 | + |
| 137 | + - run: ./scripts/circleci/run-saucelabs-tests.sh |
11 | 138 |
|
12 |
| - # Specify service dependencies here if necessary |
13 |
| - # CircleCI maintains a library of pre-built images |
14 |
| - # documented at https://circleci.com/docs/2.0/circleci-images/ |
15 |
| - # - image: circleci/mongo:3.4.4 |
| 139 | + # -------------------------------------------------- |
| 140 | + # Job that runs the unit tests on the SSR platform |
| 141 | + # -------------------------------------------------- |
| 142 | + tests_ssr: |
| 143 | + <<: *job_defaults |
| 144 | + steps: |
| 145 | + - *checkout_code |
| 146 | + - *restore_cache |
| 147 | + - *yarn_install |
16 | 148 |
|
17 |
| - working_directory: ~/repo |
| 149 | + - run: yarn gulp ci:ssr |
18 | 150 |
|
| 151 | + # ------------------------------------------------------------------------- |
| 152 | + # Job that pre-render's the universal app with `@angular/platform-server`. |
| 153 | + # This verifies that Angular Layout can be rendered within Node. |
| 154 | + # ------------------------------------------------------------------------- |
| 155 | + prerender_build: |
| 156 | + <<: *job_defaults |
19 | 157 | steps:
|
20 |
| - - checkout |
| 158 | + - *checkout_code |
| 159 | + - *restore_cache |
| 160 | + - *yarn_install |
| 161 | + |
| 162 | + - run: yarn gulp ci:prerender |
21 | 163 |
|
22 |
| - # Download and cache dependencies |
23 |
| - - restore_cache: |
24 |
| - keys: |
25 |
| - - v1-dependencies-{{ checksum "yarn.lock" }} |
26 |
| - # fallback to using the latest cache if no exact match is found |
27 |
| - - v1-dependencies- |
| 164 | + # ------------------------------------------------------------------------- |
| 165 | + # Job that makes sure Angular Layout can be integrated with a basic app |
| 166 | + # ------------------------------------------------------------------------- |
| 167 | + hello_world_build: |
| 168 | + <<: *job_defaults |
| 169 | + steps: |
| 170 | + - *checkout_code |
| 171 | + - *restore_cache |
| 172 | + - *yarn_install |
28 | 173 |
|
29 |
| - - run: yarn install --frozen-lockfile --non-interactive |
| 174 | + - run: yarn gulp ci:hw |
30 | 175 |
|
31 |
| - - save_cache: |
| 176 | + # ------------------------------------------------------------------------- |
| 177 | + # Job that makes sure Angular Layout can be integrated with the demo app |
| 178 | + # ------------------------------------------------------------------------- |
| 179 | + aot_build: |
| 180 | + <<: *job_defaults |
| 181 | + steps: |
| 182 | + - *checkout_code |
| 183 | + - *restore_cache |
| 184 | + - *yarn_install |
| 185 | + |
| 186 | + - run: yarn gulp ci:aot |
| 187 | + |
| 188 | + # ---------------------------------- |
| 189 | + # Lint job. Runs the gulp lint task. |
| 190 | + # ---------------------------------- |
| 191 | + lint: |
| 192 | + <<: *job_defaults |
| 193 | + steps: |
| 194 | + - *checkout_code |
| 195 | + - *restore_cache |
| 196 | + - *yarn_install |
| 197 | + |
| 198 | + - run: yarn gulp ci:lint |
| 199 | + |
| 200 | + # ------------------------------------------------------------------------------------------- |
| 201 | + # Job that builds all release packages with Gulp. The built packages can be then used in the |
| 202 | + # same workflow to publish snapshot builds or test the dev-app with the release packages. |
| 203 | + # ------------------------------------------------------------------------------------------- |
| 204 | + build_release_packages: |
| 205 | + <<: *job_defaults |
| 206 | + steps: |
| 207 | + - *checkout_code |
| 208 | + - *restore_cache |
| 209 | + - *yarn_install |
| 210 | + |
| 211 | + - run: yarn gulp ci:build-release-packages |
| 212 | + |
| 213 | + # Store the release output in the workspace storage. This means that other jobs |
| 214 | + # in the same workflow can attach the release output to their job. |
| 215 | + - persist_to_workspace: |
| 216 | + root: dist/releases |
32 | 217 | paths:
|
33 |
| - - node_modules |
34 |
| - key: v1-dependencies-{{ checksum "yarn.lock" }} |
| 218 | + - "**/*" |
| 219 | + |
| 220 | + # Since there is no UMD bundle that includes everything, we need to move |
| 221 | + # all bundles into a directory. This allows us to store all UMD bundles as job |
| 222 | + # artifacts that can be picked up by the Angular Github bot. |
| 223 | + - run: |
| 224 | + name: Prepare artifacts for publish. |
| 225 | + command: | |
| 226 | + mkdir -p /tmp/layout-umd-minified-bundles |
| 227 | + cp dist/releases/flex-layout/bundles/*.umd.min.js /tmp/layout-umd-minified-bundles |
| 228 | + # Publish bundle artifacts which will be used to calculate the size change. |
| 229 | + # Note: Make sure that the size plugin from the Angular robot fetches the artifacts |
| 230 | + # from this CircleCI job (see .github/angular-robot.yml). Additionally any artifacts need to |
| 231 | + # be stored with the following path format: "{projectName}/{context}/{fileName}" |
| 232 | + # This format is necessary because otherwise the bot is not able to pick up the |
| 233 | + # artifacts from CircleCI. See: |
| 234 | + # https://github.com/angular/github-robot/blob/master/functions/src/plugins/size.ts#L392-L394 |
| 235 | + - store_artifacts: |
| 236 | + path: /tmp/layout-umd-minified-bundles |
| 237 | + destination: /angular_layout/layout_release_output/ |
| 238 | + |
| 239 | + # ---------------------------------------- |
| 240 | + # Job that publishes the build snapshots |
| 241 | + # ---------------------------------------- |
| 242 | + publish_snapshots: |
| 243 | + <<: *job_defaults |
| 244 | + steps: |
| 245 | + # Since CircleCI currently does not have any way to easily restrict jobs to only run |
| 246 | + # for push builds, we need to manually skip publishing if the jobs runs for a PR. |
| 247 | + # https://discuss.circleci.com/t/workflows-pull-request-filter/14396/11 |
| 248 | + - run: |
| 249 | + name: Check whether this job should be skipped. |
| 250 | + command: '[[ -n ${CIRCLE_PR_NUMBER} ]] && circleci step halt || true' |
| 251 | + |
| 252 | + - *checkout_code |
| 253 | + - *restore_cache |
| 254 | + - *yarn_install |
| 255 | + - *attach_release_output |
| 256 | + |
| 257 | + # CircleCI has a config setting to enforce SSH for all github connections. |
| 258 | + # This is not compatible with our mechanism of using a Personal Access Token |
| 259 | + # to publish the build snapshots. In order to fix this, we unset the global option. |
| 260 | + - run: git config --global --unset "url.ssh://git@gh.loli.garden.insteadof" |
| 261 | + |
| 262 | + - run: ./scripts/circleci/publish-snapshots.sh |
| 263 | + |
| 264 | +# ---------------------------------------------------------------------------------------- |
| 265 | +# Workflow definitions. A workflow usually groups multiple jobs together. This is useful if |
| 266 | +# one job depends on another. |
| 267 | +# |
| 268 | +# NOTE: When updating this configuration section, make sure to update GitHub robot |
| 269 | +# config to match the new workflow jobs. |
| 270 | +# ---------------------------------------------------------------------------------------- |
| 271 | +workflows: |
| 272 | + version: 2 |
| 273 | + |
| 274 | + # Build and test workflow. A workflow includes multiple jobs that run in parallel. All jobs |
| 275 | + # that build and test source code should be part of this workflow |
| 276 | + build: |
| 277 | + jobs: |
| 278 | + - build |
| 279 | + |
| 280 | + unit_tests: |
| 281 | + jobs: |
| 282 | + - tests_local_browsers |
| 283 | + - tests_browserstack |
| 284 | + - tests_saucelabs |
| 285 | + - tests_ssr |
| 286 | + |
| 287 | + integration_tests: |
| 288 | + jobs: |
| 289 | + - prerender_build |
| 290 | + - hello_world_build |
| 291 | + - aot_build |
| 292 | + |
| 293 | + release_output: |
| 294 | + jobs: |
| 295 | + - build_release_packages |
| 296 | + - publish_snapshots: |
| 297 | + requires: |
| 298 | + - build_release_packages |
| 299 | + |
| 300 | + # Lint workflow. As we want to lint in one job, this is a workflow with just one job. |
| 301 | + lint: |
| 302 | + jobs: |
| 303 | + - lint |
35 | 304 |
|
36 |
| - # run the build! |
37 |
| - - run: npm run lib:build |
| 305 | +# --------------------------- |
| 306 | +# General setup for CircleCI |
| 307 | +# --------------------------- |
| 308 | +general: |
| 309 | + branches: |
| 310 | + only: |
| 311 | + - master |
| 312 | + # 5.2.x, 6.0.x, etc |
| 313 | + - /\d+\.\d+\.x/ |
| 314 | + # 5.x, 6.x, etc |
| 315 | + - /\d+\.x/ |
0 commit comments