|
1 | 1 | # Configuration file for https://circleci.com/gh/angular/material2
|
2 | 2 |
|
| 3 | +# |
3 | 4 | # Note: YAML anchors allow an object to be re-used, reducing duplication.
|
4 | 5 | # The ampersand declares an alias for an object, then later the `<<: *name`
|
5 | 6 | # syntax dereferences it.
|
|
10 | 11 | var_1: &docker_image angular/ngcontainer:0.6.0
|
11 | 12 | var_2: &cache_key v2-ng-mat-{{ .Branch }}-{{ checksum "yarn.lock" }}-0.6.0
|
12 | 13 |
|
13 |
| -# Define common ENV vars |
14 |
| -var_3: &define_env_vars |
15 |
| - run: echo "export PROJECT_ROOT=$(pwd)" >> $BASH_ENV |
16 |
| - |
17 |
| -# See remote cache documentation in /docs/BAZEL.md |
18 |
| -var_4: &setup-bazel-remote-cache |
19 |
| - run: |
20 |
| - name: Start up bazel remote cache proxy |
21 |
| - command: ~/bazel-remote-proxy -backend circleci:// |
22 |
| - background: true |
23 |
| - |
24 | 14 | # Settings common to each job
|
25 |
| -anchor_1: &job_defaults |
| 15 | +var_3: &job_defaults |
26 | 16 | working_directory: ~/ng
|
27 | 17 | docker:
|
28 | 18 | - image: *docker_image
|
29 | 19 |
|
30 |
| -# After checkout, rebase on top of master. |
31 |
| -# Similar to travis behavior, but not quite the same. |
32 |
| -# By default, PRs are not rebased on top of master, which we want. |
33 |
| -# See https://discuss.circleci.com/t/1662 |
34 |
| -anchor_2: &post_checkout |
35 |
| - post: git pull --ff-only origin "refs/pull/${CI_PULL_REQUEST//*pull\//}/merge" |
| 20 | +# Job step for checking out the source code from GitHub. This also ensures that the source code |
| 21 | +# is rebased on top of master. |
| 22 | +var_4: &checkout_code |
| 23 | + checkout: |
| 24 | + # After checkout, rebase on top of master. By default, PRs are not rebased on top of master, |
| 25 | + # which we want. See https://discuss.circleci.com/t/1662 |
| 26 | + post: git pull --ff-only origin "refs/pull/${CI_PULL_REQUEST//*pull\//}/merge" |
| 27 | + |
| 28 | +# Restores the cache that could be available for the current Yarn lock file. The cache usually |
| 29 | +# includes the node modules and the Bazel repository cache. |
| 30 | +var_5: &restore_cache |
| 31 | + restore_cache: |
| 32 | + key: *cache_key |
| 33 | + |
| 34 | +# Saves the cache for the current Yarn lock file. We store the node modules and the Bazel |
| 35 | +# repository cache in order to make subsequent builds faster. |
| 36 | +var_6: &save_cache |
| 37 | + save_cache: |
| 38 | + key: *cache_key |
| 39 | + paths: |
| 40 | + - "node_modules" |
| 41 | + - "~/bazel_repository_cache" |
36 | 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 | +# Copies the Bazel config which is specifically for CircleCI to a location where Bazel picks it |
| 51 | +# up and merges it with the project-wide bazel configuration (tools/bazel.rc) |
| 52 | +var_8: ©_bazel_config |
| 53 | + # Set up the CircleCI specific bazel configuration. |
| 54 | + run: sudo cp ./.circleci/bazel.rc /etc/bazel.bazelrc |
| 55 | + |
| 56 | +# ----------------------------- |
| 57 | +# Container version of CircleCI |
| 58 | +# ----------------------------- |
37 | 59 | version: 2
|
| 60 | + |
| 61 | +# ----------------------------------------------------------------------------------------- |
| 62 | +# Job definitions. Jobs which are defined just here, will not run automatically. Each job |
| 63 | +# must be part of a workflow definition in order to run for PRs and push builds. |
| 64 | +# ----------------------------------------------------------------------------------------- |
38 | 65 | jobs:
|
39 |
| - build: |
| 66 | + |
| 67 | + # ----------------------------------- |
| 68 | + # Build and test job that uses Bazel. |
| 69 | + # ----------------------------------- |
| 70 | + bazel_build_test: |
40 | 71 | <<: *job_defaults
|
41 | 72 | resource_class: xlarge
|
42 | 73 | steps:
|
43 |
| - - checkout: |
44 |
| - <<: *post_checkout |
45 |
| - - restore_cache: |
46 |
| - key: *cache_key |
47 |
| - # Set up the CircleCI specific bazel configuration. |
48 |
| - - run: sudo cp ./.circleci/bazel.rc /etc/bazel.bazelrc |
| 74 | + - *checkout_code |
| 75 | + - *restore_cache |
| 76 | + - *copy_bazel_config |
49 | 77 |
|
50 | 78 | # TODO(jelbourn): Update this command to run all tests if the Bazel issues have been fixed.
|
51 | 79 | - run: bazel build src/cdk:npm_package
|
52 | 80 | - run: bazel test src/{cdk,lib}/schematics:unit_tests
|
53 | 81 |
|
54 |
| - - save_cache: |
55 |
| - key: *cache_key |
56 |
| - paths: |
57 |
| - - "node_modules" |
58 |
| - - "~/bazel_repository_cache" |
| 82 | + - *save_cache |
59 | 83 |
|
| 84 | + # ---------------------------------- |
| 85 | + # Lint job. Runs the gulp lint task. |
| 86 | + # ---------------------------------- |
| 87 | + lint: |
| 88 | + <<: *job_defaults |
| 89 | + steps: |
| 90 | + - *checkout_code |
| 91 | + - *restore_cache |
| 92 | + - *yarn_install |
| 93 | + |
| 94 | + - run: yarn ci:lint |
| 95 | + |
| 96 | + - *save_cache |
| 97 | + |
| 98 | +# ---------------------------------------------------------------------------------------- |
| 99 | +# Workflow definitions. A workflow usually groups multiple jobs together. This is useful if |
| 100 | +# one job depends on another. |
| 101 | +# ---------------------------------------------------------------------------------------- |
60 | 102 | workflows:
|
61 | 103 | version: 2
|
62 |
| - default_workflow: |
| 104 | + |
| 105 | + # Build and test workflow. A workflow includes multiple jobs that run in parallel. All jobs |
| 106 | + # that build and test source code should be part of this workflow |
| 107 | + build_and_test: |
| 108 | + jobs: |
| 109 | + - bazel_build_test |
| 110 | + |
| 111 | + # Lint workflow. As we want to lint in one job, this is a workflow with just one job. |
| 112 | + lint: |
63 | 113 | jobs:
|
64 |
| - - build |
| 114 | + - lint |
65 | 115 |
|
| 116 | +# --------------------------- |
| 117 | +# General setup for CircleCI |
| 118 | +# --------------------------- |
66 | 119 | general:
|
67 | 120 | branches:
|
68 | 121 | only:
|
|
0 commit comments