Skip to content

Commit

Permalink
test: test remaining nested workspaces from root workspace with bazel…
Browse files Browse the repository at this point in the history
…_integration_test
  • Loading branch information
gregmagolan committed Aug 9, 2019
1 parent f5c370c commit 153551c
Show file tree
Hide file tree
Showing 164 changed files with 4,093 additions and 1,181 deletions.
109 changes: 102 additions & 7 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ tasks:
build_targets:
- "//..."
test_flags:
- "--test_tag_filters=-e2e,-fix-bazelci-ubuntu"
- "--test_tag_filters=-e2e,-examples,-fix-bazelci-ubuntu"
test_targets:
- "//..."
ubuntu1604_e2e:
Expand All @@ -44,6 +44,34 @@ tasks:
- "--test_arg=--test_tag_filters=-no-bazelci,-no-bazelci-ubuntu"
test_targets:
- "//..."
ubuntu1604_examples:
name: ubuntu1604_examples
platform: ubuntu1604
# We need to reduce the memory & CPU usage of the top-level
# bazel process for bazel-in-bazel tests 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 use a limited number of cores
shell_commands:
- echo 'startup --host_jvm_args=-Xms256m --host_jvm_args=-Xmx1536m' >> .bazelrc
build_flags:
- "--build_tag_filters=examples"
build_targets:
- "//..."
test_flags:
- "--test_tag_filters=examples"
- "--local_resources=792,1.0,1.0"
# test_args will be passed to the nested bazel process
- "--test_arg=--local_resources=13288,7.0,1.0"
- "--test_arg=--test_tag_filters=-no-bazelci,-no-bazelci-ubuntu"
test_targets:
- "//..."
# The following examples only works on linux as it downloads the linux node distribution
# It is tagged "manual" so we run it explicitly here
# TODO(gregmagolan): make node_repositories acccept different archives for different platforms
- "//examples:examples_vendored_node"
- "//examples:examples_vendored_node_and_yarn"
# ubuntu1604_angular_bazel_example:
# name: ubuntu1604_angular_bazel_example
# platform: ubuntu1604
Expand Down Expand Up @@ -75,7 +103,7 @@ tasks:
# coverage of it to make sure it doesn't break.
- "//docs"
test_flags:
- "--test_tag_filters=-e2e,-fix-bazelci-ubuntu"
- "--test_tag_filters=-e2e,-examples,-fix-bazelci-ubuntu"
test_targets:
- "//..."
ubuntu1804_e2e:
Expand All @@ -101,6 +129,34 @@ tasks:
- "--test_arg=--test_tag_filters=-no-bazelci,-no-bazelci-ubuntu"
test_targets:
- "//..."
ubuntu1804_examples:
name: ubuntu1804_examples
platform: ubuntu1604
# We need to reduce the memory & CPU usage of the top-level
# bazel process for bazel-in-bazel tests 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 use a limited number of cores
shell_commands:
- echo 'startup --host_jvm_args=-Xms256m --host_jvm_args=-Xmx1536m' >> .bazelrc
build_flags:
- "--build_tag_filters=examples"
build_targets:
- "//..."
test_flags:
- "--test_tag_filters=examples"
- "--local_resources=792,1.0,1.0"
# test_args will be passed to the nested bazel process
- "--test_arg=--local_resources=13288,7.0,1.0"
- "--test_arg=--test_tag_filters=-no-bazelci,-no-bazelci-ubuntu"
test_targets:
- "//..."
# The following examples only works on linux as it downloads the linux node distribution
# It is tagged "manual" so we run it explicitly here
# TODO(gregmagolan): make node_repositories acccept different archives for different platforms
- "//examples:examples_vendored_node"
- "//examples:examples_vendored_node_and_yarn"
# ubuntu1804_angular_bazel_example:
# name: ubuntu1804_angular_bazel_example
# platform: ubuntu1804
Expand Down Expand Up @@ -129,7 +185,7 @@ tasks:
build_targets:
- "//..."
test_flags:
- "--test_tag_filters=-e2e"
- "--test_tag_filters=-e2e,-examples"
test_targets:
- "//..."
macos_e2e:
Expand All @@ -152,7 +208,31 @@ tasks:
- "--local_resources=792,1.0,1.0"
# test_args will be passed to the nested bazel process
# TODO(gregmagolan): fix frequent flake with multiple cores in nested bazel (osx buildkite & local)
- "--test_arg=--local_resources=8192,1.0,1.0"
- "--test_arg=--local_resources=13288,1.0,1.0"
- "--test_arg=--test_tag_filters=-no-bazelci,-no-bazelci-mac"
test_targets:
- "//..."
macos_examples:
name: macos_examples
platform: macos
# We need to reduce the memory & CPU usage of the top-level
# bazel process for bazel-in-bazel tests 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 use a limited number of cores
shell_commands:
- echo 'startup --host_jvm_args=-Xms256m --host_jvm_args=-Xmx1536m' >> .bazelrc
build_flags:
- "--build_tag_filters=examples"
build_targets:
- "//..."
test_flags:
- "--test_tag_filters=examples"
- "--local_resources=792,1.0,1.0"
# test_args will be passed to the nested bazel process
# TODO(gregmagolan): fix frequent flake with multiple cores in nested bazel (osx buildkite & local)
- "--test_arg=--local_resources=13288,1.0,1.0"
- "--test_arg=--test_tag_filters=-no-bazelci,-no-bazelci-mac"
test_targets:
- "//..."
Expand Down Expand Up @@ -205,7 +285,7 @@ tasks:
build_targets:
- "//..."
test_flags:
- "--test_tag_filters=-e2e,-fix-windows"
- "--test_tag_filters=-e2e,-examples,-fix-windows"
test_targets:
- "//..."
windows_e2e:
Expand All @@ -219,8 +299,23 @@ tasks:
- "--test_tag_filters=e2e"
- "--local_resources=792,1.0,1.0"
# test_args will be passed to the nested bazel process
- "--test_arg=--test_tag_filters=-no-bazelci,-no-bazelci-windows"
- "--test_arg=--local_resources=8192,1.0,1.0"
- "--test_arg=--test_tag_filters=-no-bazelci,-no-bazelci-windows,-fix-windows"
- "--test_arg=--local_resources=13288,1.0,1.0"
test_targets:
- "//..."
windows_examples:
name: windows_examples
platform: windows
build_flags:
- "--build_tag_filters=examples"
build_targets:
- "//..."
test_flags:
- "--test_tag_filters=examples,-fix-windows,-no-bazelci-windows"
- "--local_resources=792,1.0,1.0"
# test_args will be passed to the nested bazel process
- "--test_arg=--test_tag_filters=-no-bazelci,-no-bazelci-windows,-fix-windows"
- "--test_arg=--local_resources=13288,1.0,1.0"
test_targets:
- "//..."
# windows_angular_bazel_example:
Expand Down
14 changes: 0 additions & 14 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,2 @@
node_modules
internal/npm_install/test/node_modules
dist
release
# Examples are tested by running examples/test_example.sh outside of Bazel
examples/
# A subset of legacy e2e tests are nested workspaces
# TODO(gregmagolan): move these to /e2e
internal/e2e/bazel_workspaces_compat
internal/e2e/fine_grained_deps/npm/node_modules
internal/e2e/fine_grained_deps/yarn/node_modules
internal/e2e/fine_grained_no_bin/node_modules
internal/e2e/fine_grained_symlinks
internal/e2e/node_loader_no_preserve_symlinks
internal/e2e/node_loader_preserve_symlinks
internal/e2e/packages
100 changes: 42 additions & 58 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
## IMPORTANT
# If you change the `default_docker_image` version, also change the `cache_key` version
var_1: &default_docker_image circleci/node:10.16
var_3: &cache_key node-0.16-{{ checksum "yarn.lock" }}-{{ checksum "examples/program/yarn.lock" }}
var_3: &cache_key node-0.16-{{ checksum "yarn.lock" }}

var_4: &init_environment
run:
Expand Down Expand Up @@ -107,14 +107,13 @@ jobs:
- *init_bazel

# Run yarn on all node_repositories
- run: bazel run @nodejs//:yarn
- run: bazel run @nodejs//:bin/yarn

# Save all node_modules to the cache
- save_cache:
key: *cache_key
paths:
- "node_modules"
- "examples/program/node_modules"

# Persist any changes at this point to be reused by further jobs.
- persist_to_workspace:
Expand Down Expand Up @@ -153,7 +152,7 @@ jobs:
- *init_bazel
- *hide_node_and_yarn_local_binaries

- run: bazel test ... --test_tag_filters=-e2e
- run: bazel test ... --test_tag_filters=-e2e,-examples

test_e2e:
<<: *job_defaults
Expand Down Expand Up @@ -188,6 +187,39 @@ jobs:
command: bazel test --test_tag_filters=e2e --local_resources=792,1.0,1.0 --test_arg=--local_resources=13288,7.0,1.0 --test_arg=--test_tag_filters=-no-circleci ...
no_output_timeout: 20m

test_examples:
<<: *job_defaults
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
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

# Split up the build & test as test takes a long time and has very
# little output so running build first makes CI output friendlier.
# The build step can also use up more memory which may be required
# to build the release package with this configuration.
- run: bazel build --build_tag_filters=examples ...
- run:
command: bazel test --test_tag_filters=examples --local_resources=792,1.0,1.0 --test_arg=--local_resources=13288,7.0,1.0 --test_arg=--test_tag_filters=-no-circleci ...
no_output_timeout: 20m
# The following examples only works on linux as it downloads the linux node distribution
# It is tagged "manual" so we run it explicitly here
# TODO(gregmagolan): make node_repositories acccept different archives for different platforms
- run:
command: bazel test --local_resources=792,1.0,1.0 --test_arg=--local_resources=13288,7.0,1.0 //examples:examples_vendored_node //examples:examples_vendored_node_and_yarn
no_output_timeout: 20m

test_e2e_angular_bazel_example:
<<: *job_defaults
resource_class: xlarge
Expand Down Expand Up @@ -248,48 +280,9 @@ jobs:
# We should also be able to test targets in a different workspace
# TODO(gmagolan): move these tests into `build` job once
# https://github.com/bazelbuild/bazel/issues/6481 is resolved
- run: 'cd examples/program && bazel run @nodejs//:yarn'
- run: bazel test @examples_program//...
- run: bazel test @internal_e2e_packages//...

build_release:
<<: *job_defaults
# Need to compile Go and protocol buffers from source for typescript package
resource_class: xlarge
steps:
- *attach_workspace
- *init_environment
- *init_bazel
- *hide_node_and_yarn_local_binaries
- run: ./scripts/build_release.sh
- run: ./scripts/build_packages_all.sh
- persist_to_workspace:
root: ~/
paths:
- ./rules_nodejs/release

# These e2e tests are in the process of being moved to the test_e2e job
test_e2e_legacy:
<<: *job_defaults
parallelism: 2
steps:
- *attach_workspace
- *init_environment
- *init_bazel
- run: ./scripts/test_legacy_e2e_all.sh ${CIRCLE_NODE_INDEX} ${CIRCLE_NODE_TOTAL}

# This job cannot run on BuildKite (BazelCI) because it requires changing
# directories to test inside nested workspaces.
# See https://github.com/bazelbuild/continuous-integration/issues/225
test_examples:
<<: *job_defaults
resource_class: xlarge
parallelism: 4
steps:
- *attach_workspace
- *init_environment
- *init_bazel
- run: ./scripts/test_examples_all.sh ${CIRCLE_NODE_INDEX} ${CIRCLE_NODE_TOTAL}
- run: 'cd examples/user_managed_deps && bazel run @nodejs//:yarn'
- run: bazel test @examples_user_managed_deps//...
- run: bazel test @e2e_packages//...

workflows:
version: 2
Expand All @@ -305,21 +298,12 @@ workflows:
- test_e2e:
requires:
- setup
- test_e2e_angular_bazel_example:
- test_examples:
requires:
- setup
- runnable_targets:
- test_e2e_angular_bazel_example:
requires:
- setup
- build_release:
- runnable_targets:
requires:
- setup
- test_legacy_runfiles:
requires:
- build_release
- test_e2e_legacy:
requires:
- build_release
- test_examples:
requires:
- build_release
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ bazel-out
/e2e/*/bazel-*
/examples/*/bazel-*
/packages/*/bazel-*
/internal/e2e/*/bazel-*
node_modules
!/internal/npm_install/test/golden/node_modules
examples/vendored_node/node-v10.12.0-linux-x64
examples/vendored_node/node-v10.12.0-linux-x64.tar.xz
examples/vendored_node/yarn-v1.10.0
Expand Down
17 changes: 6 additions & 11 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ We strongly encourage you to review the project's scope described in the `README

## Testing locally

This repository contains nested workspaces with are in the process of being phased out. Some of these nested workspaces are now tested with the bazel-in-bazel bazel_integration_test rule. The integration tests must be run in series as they use up too many resources when run in parallel.
This repository contains nested workspaces which are tested with the bazel-in-bazel bazel_integration_test rule. The integration tests must be run in series as they use up too many resources when run in parallel.

`bazel test ...` includes all these integration tests so if you want to run all tests except the integration tests you can use `bazel test ... --test_tag_filters=-e2e`. A shortcut for this is `yarn test`.
`bazel test ...` includes all these integration tests so if you want to run all tests except the integration tests you can use `bazel test ... --test_tag_filters=-e2e,-examples`. A shortcut for this is `yarn test`.

When running the integration tests, it is recommended to tune the memory usage of Bazel locally. This can be done with `bazel --host_jvm_args=-Xms256m --host_jvm_args=-Xmx1280m test ... --test_tag_filters=e2e --local_resources=792,1.0,1.0 --test_arg=--local_resources=13288,1.0,1.0`. A shortcut for this is `yarn test_e2e`.
When running the e2e tests, it is recommended to tune the memory usage of Bazel locally. This can be done with `bazel --host_jvm_args=-Xms256m --host_jvm_args=-Xmx1280m test ... --test_tag_filters=e2e --local_resources=792,1.0,1.0 --test_arg=--local_resources=13288,1.0,1.0`. A shortcut for this is `yarn test_e2e`.

To test all targets locally in the main workspace and in all nested workspaces (includes those that are not yet tested as integration tests) run:
Similarly, for test examples run `bazel --host_jvm_args=-Xms256m --host_jvm_args=-Xmx1280m test ... --test_tag_filters=examples --local_resources=792,1.0,1.0 --test_arg=--local_resources=13288,1.0,1.0`. A shortcut for this is `yarn test_examples`.

To test all targets locally in the main workspace and in all nested workspaces run:

```
yarn test_all
Expand All @@ -22,13 +24,6 @@ To do a full clean run:
yarn clean_all
```

Other scripts allow you to test all or e2e tests and examples. For example,

```
yarn test_examples_all
yarn test_examples webapp
```

## Releasing

Start from a clean checkout at master/HEAD.
Expand Down
Loading

0 comments on commit 153551c

Please sign in to comment.