blob: 33b331812a71f7581add4022cfa6664ad515426c [file] [log] [blame]
# Configuration file for https://circleci.com/gh/bazelbuild/rules_typescript
# Note: YAML anchors allow an object to be re-used, reducing duplication.
# The ampersand declares an alias for an object, then later the `<<: *name`
# syntax dereferences it.
# See http://blog.daemonl.com/2016/02/yaml.html
# To validate changes, use an online parser, eg.
# http://yaml-online-parser.appspot.com/
## IMPORTANT
# If you change the `docker_image` version, also change the `cache_key` suffix
var_1: &docker_image angular/ngcontainer:0.7.0
var_2: &cache_key rules_typescript-{{ checksum "yarn.lock" }}-0.7.0
var_3: &setup-bazel-remote-cache
run:
name: Start up bazel remote cache proxy
command: ~/bazel-remote-proxy -backend circleci://
background: true
# Move node binaries out of the way to enforce that Bazel uses
# only the hermetic ones it downloads
var_4: &hide_node_and_yarn_local_binaries
run:
name: Move node, npm, and yarn binaries
command: |
sudo mv /usr/local/bin/node /usr/local/bin/node_
sudo mv /usr/local/bin/npm /usr/local/bin/npm_
sudo mv /usr/local/bin/yarn /usr/local/bin/yarn_
# Settings common to each job
anchor_1: &job_defaults
working_directory: ~/ts
# Use a docker image with bazel already installed
docker:
- image: *docker_image
# After checkout, rebase on top of master.
# Similar to travis behavior, but not quite the same.
# See https://discuss.circleci.com/t/1662
anchor_2: &post_checkout
post: git pull --ff-only origin "refs/pull/${CI_PULL_REQUEST//*pull\//}/merge"
version: 2
jobs:
build:
<<: *job_defaults
steps:
- checkout:
<<: *post_checkout
- run: .circleci/setup_cache.sh
- run: sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
- *setup-bazel-remote-cache
- *hide_node_and_yarn_local_binaries
- restore_cache:
key: *cache_key
- run: bazel info release
- run: bazel build ...
- run: bazel test ...
- run: bazel build @disable_tsetse_for_external_test//...
# This job tests the same stuff, but without the .bazelrc file.
# It disables worker mode, for example.
build_no_bazelrc:
<<: *job_defaults
steps:
- checkout:
<<: *post_checkout
- run: .circleci/setup_cache.sh
- run: sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
- *setup-bazel-remote-cache
- *hide_node_and_yarn_local_binaries
- restore_cache:
key: *cache_key
- run: bazel --bazelrc=/dev/null info release
# We cherry pick the memory utilization options from .circleci/bazel.rc here.
# Since the default CircleCI container has only 4G, limiting the memory
# is required to keep Bazel from exhausting the memory.
- run: bazel --bazelrc=/dev/null --host_jvm_args=-Xmx3g build ... --local_resources=2560,1.0,1.0
- run: bazel --bazelrc=/dev/null --host_jvm_args=-Xmx3g test ... --local_resources=2560,1.0,1.0
- run: bazel --bazelrc=/dev/null --host_jvm_args=-Xmx3g build @disable_tsetse_for_external_test//... --local_resources=2560,1.0,1.0
- save_cache:
key: *cache_key
paths:
- "node_modules"
# Runs end-to-end browser tests.
test:
<<: *job_defaults
steps:
- checkout:
<<: *post_checkout
- run: .circleci/setup_cache.sh
- run: sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
- *setup-bazel-remote-cache
- *hide_node_and_yarn_local_binaries
- restore_cache:
key: *cache_key
# Build the npm packages which are used in the e2e tests
- run: bazel build //internal:npm_package
- run: bazel build //internal/karma:npm_package
# Run yarn as e2e tests depend on self managed node_modules
- run: bazel run @nodejs//:bin/yarn
# Don't occupy the bazel server, as this test wants to run Bazel itself
- run: bazel run @nodejs//:bin/yarn e2e --script_path=yarn_e2e.sh
- run: xvfb-run -a ./yarn_e2e.sh
lint:
<<: *job_defaults
steps:
- checkout:
<<: *post_checkout
- run: .circleci/setup_cache.sh
- run: sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
- *setup-bazel-remote-cache
- run: yarn skylint
workflows:
version: 2
# Run the two builds in parallel, reporting separate status to github PRs.
default_workflow:
jobs:
- build
- build_no_bazelrc
- test
- lint