|
| 1 | +# Configuration file for https://circleci.com/gh/angular/flex-layout |
| 2 | + |
| 3 | +# Note: YAML anchors allow an object to be re-used, reducing duplication. |
| 4 | +# The ampersand declares an alias for an object, then later the `<<: *name` |
| 5 | +# syntax dereferences it. |
| 6 | +# See http://blog.daemonl.com/2016/02/yaml.html |
| 7 | +# To validate changes, use an online parser, eg. |
| 8 | +# http://yaml-online-parser.appspot.com/ |
| 9 | + |
| 10 | +## IMPORTANT |
| 11 | +# If you change the `docker_image` version, also change the `cache_key` suffix and the version of |
| 12 | +# `com_github_bazelbuild_buildtools` in the `/WORKSPACE` file. |
| 13 | +var_1: &docker_image angular/ngcontainer:0.3.0 |
| 14 | +var_2: &cache_key v2-preboot-{{ .Branch }}-{{ checksum "npm-shrinkwrap.json" }}-0.3.0 |
| 15 | + |
| 16 | +# Define common ENV vars |
| 17 | +var_3: &define_env_vars |
| 18 | + run: echo "export PROJECT_ROOT=$(pwd)" >> $BASH_ENV |
| 19 | + |
| 20 | +# See remote cache documentation in /docs/BAZEL.md |
| 21 | +var_4: &setup-bazel-remote-cache |
| 22 | + run: |
| 23 | + name: Start up bazel remote cache proxy |
| 24 | + command: ~/bazel-remote-proxy -backend circleci:// |
| 25 | + background: true |
| 26 | + |
| 27 | +# Settings common to each job |
| 28 | +anchor_1: &job_defaults |
| 29 | + working_directory: ~/ng |
| 30 | + docker: |
| 31 | + - image: *docker_image |
| 32 | + |
| 33 | +# After checkout, rebase on top of master. |
| 34 | +# Similar to travis behavior, but not quite the same. |
| 35 | +# By default, PRs are not rebased on top of master, which we want. |
| 36 | +# See https://discuss.circleci.com/t/1662 |
| 37 | +anchor_2: &post_checkout |
| 38 | + post: git pull --ff-only origin "refs/pull/${CI_PULL_REQUEST//*pull\//}/merge" |
| 39 | + |
| 40 | +version: 2 |
| 41 | +jobs: |
| 42 | + lint: |
| 43 | + <<: *job_defaults |
| 44 | + steps: |
| 45 | + - checkout: |
| 46 | + <<: *post_checkout |
| 47 | + |
| 48 | + # Enforce that BUILD files are formatted. Note that this uses the version of buildifier |
| 49 | + # from the docker image above - take care that you use the same version when you run |
| 50 | + # buildifier locally on your change. |
| 51 | + - run: 'buildifier -mode=check $(find . -type f \( -name BUILD.bazel -or -name BUILD \)) || |
| 52 | + (echo "BUILD files not formatted. Please run ''npm run buildifier''" ; exit 1)' |
| 53 | + |
| 54 | + # Run the skylark linter to check our Bazel rules |
| 55 | + - run: 'find . -type f -name "*.bzl" | |
| 56 | + xargs java -jar /usr/local/bin/Skylint_deploy.jar || |
| 57 | + (echo -e "\n.bzl files have lint errors. Please run ''npm run skylint''"; exit 1)' |
| 58 | + |
| 59 | + - restore_cache: |
| 60 | + key: *cache_key |
| 61 | + |
| 62 | + - run: npm install --frozen-lockfile --non-interactive |
| 63 | + - run: npm run lint |
| 64 | + |
| 65 | + build: |
| 66 | + <<: *job_defaults |
| 67 | + resource_class: large |
| 68 | + steps: |
| 69 | + - checkout: |
| 70 | + <<: *post_checkout |
| 71 | + # See remote cache documentation in /docs/BAZEL.md |
| 72 | + - run: .circleci/setup_cache.sh |
| 73 | + - run: sudo cp .circleci/bazel.rc /etc/bazel.bazelrc |
| 74 | + - *setup-bazel-remote-cache |
| 75 | + - restore_cache: |
| 76 | + key: *cache_key |
| 77 | + |
| 78 | + - run: bazel info release |
| 79 | + - run: bazel run @nodejs//:npm install |
| 80 | + # For some reason, circleci needs the postinstall to be run explicitly. |
| 81 | + # This may be unnecessary once rules_nodejs uses nodejs 8 |
| 82 | + - run: bazel run @nodejs//:npm run postinstall |
| 83 | + # Use bazel query so that we explicitly ask for all buildable targets to be built as well |
| 84 | + # This avoids waiting for the slowest build target to finish before running the first test |
| 85 | + # See https://github.com/bazelbuild/bazel/issues/4257 |
| 86 | + # NOTE: Angular developers should typically just bazel build //... or bazel test //... |
| 87 | + - run: bazel query --output=label //... | xargs bazel test |
| 88 | + |
| 89 | + # Save the npm packages from //packages/... for other workflow jobs to read |
| 90 | + # https://circleci.com/docs/2.0/workflows/#using-workspaces-to-share-data-among-jobs |
| 91 | + # - persist_to_workspace: |
| 92 | + # root: dist |
| 93 | + # paths: |
| 94 | + # - dist |
| 95 | + |
| 96 | + - save_cache: |
| 97 | + key: *cache_key |
| 98 | + paths: |
| 99 | + - "node_modules" |
| 100 | + |
| 101 | + # Save the npm packages from //packages/... for other workflow jobs to read |
| 102 | + # https://circleci.com/docs/2.0/workflows/#using-workspaces-to-share-data-among-jobs |
| 103 | + - persist_to_workspace: |
| 104 | + root: dist |
| 105 | + paths: |
| 106 | + - bazel/**/* |
| 107 | + |
| 108 | + # We run the integration tests outside of Bazel for now. |
| 109 | + # They are a separate workflow job so that they can be easily re-run. |
| 110 | + # When the tests are ported to bazel test targets, they should move to the "test" |
| 111 | + # job above, as part of the bazel test command. That has flaky_test_attempts so the |
| 112 | + # need to re-run manually should be alleviated. |
| 113 | + integration_test: |
| 114 | + <<: *job_defaults |
| 115 | + steps: |
| 116 | + - *define_env_vars |
| 117 | + - checkout: |
| 118 | + <<: *post_checkout |
| 119 | + - attach_workspace: |
| 120 | + at: dist |
| 121 | + - run: npm install --frozen-lockfile --non-interactive |
| 122 | + - run: npm run e2e |
| 123 | + |
| 124 | +workflows: |
| 125 | + version: 2 |
| 126 | + default_workflow: |
| 127 | + jobs: |
| 128 | + - lint |
| 129 | + - build |
| 130 | + - integration_test: |
| 131 | + requires: |
| 132 | + - build |
| 133 | + |
| 134 | +general: |
| 135 | + branches: |
| 136 | + only: |
| 137 | + - master |
0 commit comments