blob: 883705f05a8fce4f10fc782c1b6c3d2f1e6fbddc [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 circleci/node:10.12-browsers
var_2: &cache_key rules_typescript-{{ checksum "yarn.lock" }}-internal/karma:node:{{ checksum "internal/karma/yarn.lock" }}-10.12-browsers
var_3: &setup-bazel-remote-cache
run:
name: Start up bazel remote cache proxy
command: ~/bazel-remote-proxy -backend circleci://
background: true
# 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
- restore_cache:
key: *cache_key
- run: yarn install
- run: yarn bazel info release
- run: yarn bazel build ...
- run: yarn bazel test ...
- run: 'cd internal/karma &&
yarn install &&
yarn bazel build ...'
- run: yarn 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
- restore_cache:
key: *cache_key
- run: yarn install
- run: yarn 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: yarn bazel --bazelrc=/dev/null --host_jvm_args=-Xmx3g build ... --local_resources=2560,1.0,1.0
- run: yarn bazel --bazelrc=/dev/null --host_jvm_args=-Xmx3g test ... --local_resources=2560,1.0,1.0
- run: 'cd internal/karma &&
yarn install &&
yarn bazel --bazelrc=/dev/null --host_jvm_args=-Xmx3g build ... --local_resources=2560,1.0,1.0'
- run: yarn 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"
- "internal/karma/node_modules"
# Runs end-to-end browser tests.
test:
<<: *job_defaults
resource_class: xlarge
environment:
CHROMEDRIVER_VERSION_ARG: --versions.chrome 2.41
steps:
- checkout:
<<: *post_checkout
- run: .circleci/setup_cache.sh
- run: sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
- *setup-bazel-remote-cache
- restore_cache:
key: *cache_key
- run: yarn install
- run: xvfb-run -a yarn e2e
lint:
<<: *job_defaults
steps:
- checkout:
<<: *post_checkout
- run: yarn install
# Run the skylark linter to check our Bazel rules
# Note, this is not yet enforced, because
# - buildifier doesn't exit non-zero in the presence of lint warnings: https://github.com/bazelbuild/buildtools/issues/470
# - false positive for rule docstrings: https://github.com/bazelbuild/buildtools/issues/471
- run: 'yarn bazel:lint ||
(echo -e "\n.bzl files have lint errors. Please run ''yarn bazel:lint-fix''"; exit 1)'
# Enforce that BUILD files are formatted.
- run: 'yarn bazel:format -mode=check ||
(echo "BUILD files not formatted. Please run ''yarn bazel:format''" ; exit 1)'
workflows:
version: 2
# Run the two builds in parallel, reporting separate status to github PRs.
default_workflow:
jobs:
- build
- build_no_bazelrc
- test
- lint