blob: 02f164fc8eafa92388035f0be63c8b0d2be30e75 [file] [log] [blame] [edit]
# Configuration file for https://circleci.com/gh/bazelbuild/rules_nodejs
# 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 `default_docker_image` version, also change the `cache_key` version
var_1: &default_docker_image circleci/node:12.18.3
var_2: &browsers_docker_image circleci/node:12.18.3-browsers
var_3: &cache_key node-12.18.3-{{ checksum "yarn.lock" }}
var_4: &init_environment
run:
name: Initializing environment (setting up variables, overwriting Yarn)
command: |
# Setup circleci environment
./.circleci/env.sh
sudo apt-get update
# Install GTK+ graphical user interface (libgtk-3-0), advanced linux sound architecture (libasound2)
# and network security service libraries (libnss3) & X11 Screen Saver extension library (libssx1)
# which are dependendies of chrome & needed for karma & protractor headless chrome tests.
# This is a very small install with the whole init_environment step taking less than 8 seconds.
# TODO(gregmagolan): switch rules_webtesting to use a chrome headless_shell binary which does
# not depend on any dynamically linked libs
sudo apt-get -y install libgtk-3-0 libasound2 libnss3 libxss1
# Also install libraries required for firefox
sudo apt-get -y install libdbus-glib-1-2
# Overwrite the yarn installed in the docker container with our own version.
pathToYarn=$(realpath ./third_party/github.com/yarnpkg/yarn/releases/download/v1.13.0/bin/yarn.js)
sudo chmod a+x $pathToYarn
sudo ln -fs $pathToYarn /usr/local/bin/yarn
echo "Yarn version: $(yarn --version)"
# Add GitHub to known hosts.
mkdir -p ~/.ssh
echo 'github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==' >> ~/.ssh/known_hosts
# Use git+ssh instead of https
git config --global url."ssh://git@github.com".insteadOf "https://github.com" || true
git config --global gc.auto 0 || true
# Setup /etc/bazel.bazelrc
sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
var_5: &yarn_install
run:
name: Run yarn install
command: yarn install
var_6: &init_bazel
run:
name: Initializing Bazel
command: |
# Symlink fetched bazelisk to /usr/local/bin/bazel
pathToBazel=$(realpath ./node_modules/@bazel/bazelisk/bazelisk-linux_amd64)
sudo ln -fs $pathToBazel /usr/local/bin/bazel
echo "Bazel version:"
bazel version
var_7: &hide_node_and_yarn_local_binaries
run:
name: Hide node, npm, and yarn binaries
command: |
# Hide node binaries to enforce that Bazel uses only the hermetic ones it downloads
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_
var_9: &job_defaults
working_directory: ~/rules_nodejs
docker:
- image: *default_docker_image
var_10: &restore_cache
restore_cache:
keys:
- *cache_key
var_11: &attach_workspace
attach_workspace:
at: ~/
# Opt-in to the new goodness
version: 2
# These jobs will run in parallel, and report separate statuses to GitHub PRs
jobs:
setup:
<<: *job_defaults
steps:
- checkout
- *restore_cache
- *init_environment
- *yarn_install
- *init_bazel
# Run yarn
- run: bazel run @nodejs//:yarn
# Save all node_modules to the cache
- save_cache:
key: *cache_key
paths:
- "node_modules"
# Persist any changes at this point to be reused by further jobs.
- persist_to_workspace:
root: ~/
paths:
- ./rules_nodejs
# Overlaps with testing we do on BuildKite. This is still here because:
# - BuildKite doesn't have a public results UI; failures here let contributors fix their changes
# - We hide the node,yarn,npm binaries here which we don't do on BuildKite
# TODO: port these assertions to BuildKite
test:
<<: *job_defaults
resource_class: xlarge
steps:
- *attach_workspace
- *init_environment
- *init_bazel
- *hide_node_and_yarn_local_binaries
- run: bazel test --test_tag_filters=-e2e,-examples,-manual ...
- store_artifacts:
path: dist/bin/release.tar.gz
destination: release.tar.gz
test_integration:
<<: *job_defaults
docker:
# Needed because some tests such as examples/angular_bazel_architect
# require local chrome
- image: *browsers_docker_image
resource_class: xlarge
# We need to reduce the memory & CPU usage of the top-level
# bazel process for this large bazel-in-bazel test to not
# deplete the system memory completely.
# - startup JVM memory reduced
# - top-level bazel process should use as little memory as possible and only 1 core
# - nested bazel process should have its memory & core optimally capped as well
parallelism: 8
steps:
- *attach_workspace
- *init_environment
- run:
name: Tune top-level bazel JVM memory usage
command: echo 'startup --host_jvm_args=-Xms256m --host_jvm_args=-Xmx1280m' >> .bazelrc
- *init_bazel
- *hide_node_and_yarn_local_binaries
- run:
command: ./.circleci/run_integration_tests.sh ${CIRCLE_NODE_INDEX} ${CIRCLE_NODE_TOTAL}
no_output_timeout: 30m
test_integration_manual:
<<: *job_defaults
steps:
- *attach_workspace
- *init_environment
- *init_bazel
# Additional integration assertions that can only be done manually
- run: cd e2e/symlinked_node_modules_npm && yarn test && bazel clean
- run: cd e2e/symlinked_node_modules_yarn && yarn test && bazel clean
- run: cd examples/user_managed_deps && yarn install && bazel test ...
- run: cd examples/from_source && bazel test //...
workflows:
version: 2
default_workflow:
jobs:
- setup
- test:
requires:
- setup
- test_integration:
requires:
- setup
- test_integration_manual:
requires:
- setup