Skip to content

Commit 3c05b34

Browse files
authored
build: run integration tests in sandbox and with RBE (#24114)
Runs the integration tests in sandbox and with RBE. This should improve the stability of the integration tests significantly. i.e. solving the issue/conflicts with a system-global Yarn cache.
1 parent c199aa2 commit 3c05b34

File tree

9 files changed

+2932
-2719
lines changed

9 files changed

+2932
-2719
lines changed

.bazelrc

+12-3
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,18 @@ build:remote --auth_enabled=true
8686
# is provided by the shared dev-infra package and targets k8 remote containers.
8787
build:remote --crosstool_top=@npm//@angular/dev-infra-private/bazel/remote-execution/cpp:cc_toolchain_suite
8888
build:remote --extra_toolchains=@npm//@angular/dev-infra-private/bazel/remote-execution/cpp:cc_toolchain
89-
build:remote --extra_execution_platforms=@npm//@angular/dev-infra-private/bazel/remote-execution:platform
90-
build:remote --host_platform=@npm//@angular/dev-infra-private/bazel/remote-execution:platform
91-
build:remote --platforms=@npm//@angular/dev-infra-private/bazel/remote-execution:platform
89+
build:remote --extra_execution_platforms=@npm//@angular/dev-infra-private/bazel/remote-execution:platform_with_network
90+
build:remote --host_platform=@npm//@angular/dev-infra-private/bazel/remote-execution:platform_with_network
91+
build:remote --platforms=@npm//@angular/dev-infra-private/bazel/remote-execution:platform_with_network
92+
93+
################################
94+
# Sandbox settings #
95+
################################
96+
97+
# By default, network access should be disabled unless explicitly granted for certain targets
98+
# using the `requires-network` tag. https://docs.bazel.build/versions/main/be/common-definitions.html
99+
build --sandbox_default_allow_network=false
100+
test --sandbox_default_allow_network=false
92101

93102
################################
94103
# --config=build-results #

integration/ng-add/BUILD.bazel

+7-16
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@ node_integration_test(
2323
"yarn test",
2424
],
2525
npm_packages = npmPackageMappings,
26+
setup_chromium = True,
2627
tags = [
27-
# Chromium cannot run in Sandbox. For this test, sandbox is disabled.
28-
# Additionally, we need to disable RBE as this test relies on internet
29-
# access for installing the NPM packages.
30-
"no-sandbox",
31-
"no-remote-exec",
28+
# This test relies on `yarn` so there needs to be internet access.
29+
"requires-network",
3230
],
3331
)
3432

@@ -41,21 +39,14 @@ node_integration_test(
4139
# See: https://github.com/yarnpkg/yarn/issues/2165.
4240
# TODO(devversion): determine if a solution/workaround could live in the test runner.
4341
"yarn install --cache-folder .yarn_cache_folder/",
44-
"node --version",
45-
"yarn node --version",
4642
"yarn ng add @angular/material",
4743
"yarn test",
4844
],
45+
node_repository = "node12_host",
4946
npm_packages = npmPackageMappings,
47+
setup_chromium = True,
5048
tags = [
51-
# Chromium cannot run in Sandbox. For this test, sandbox is disabled.
52-
# Additionally, we need to disable RBE as this test relies on internet
53-
# access for installing the NPM packages.
54-
"no-sandbox",
55-
"no-remote-exec",
49+
# This test relies on `yarn` so there needs to be internet access.
50+
"requires-network",
5651
],
57-
tool_mappings = {
58-
"@node12_host//:yarn_bin": "yarn",
59-
"@node12_host//:node_bin": "node",
60-
},
6152
)

integration/ng-add/karma.conf.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
// Karma configuration file, see link for more information
22
// https://karma-runner.github.io/1.0/config/configuration-file.html
33

4-
// This code runs within Bazel where the environment does not have access to
5-
// the system Chrome browser. To workaround this we use Puppeteer to provide
6-
// a local version of Chromium that can run within Bazel.
7-
process.env.CHROME_BIN = require('puppeteer').executablePath();
8-
94
module.exports = function (config) {
105
config.set({
116
basePath: '',
@@ -34,12 +29,20 @@ module.exports = function (config) {
3429
subdir: '.',
3530
reporters: [{type: 'html'}, {type: 'text-summary'}],
3631
},
32+
customLaunchers: {
33+
ChromeHeadlessNoSandbox: {
34+
base: 'ChromeHeadless',
35+
flags: ['--no-sandbox'],
36+
},
37+
},
3738
reporters: ['progress', 'kjhtml'],
3839
port: 9876,
3940
colors: true,
4041
logLevel: config.LOG_INFO,
4142
autoWatch: true,
42-
browsers: ['ChromeHeadless'],
43+
// Chrome cannot run with sandbox enabled as this test already runs within
44+
// the Bazel sandbox environment and the sandboxes would conflict otherwise.
45+
browsers: ['ChromeHeadlessNoSandbox'],
4346
singleRun: false,
4447
restartOnFileChange: true,
4548
});

integration/ng-add/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
"karma-coverage": "~2.0.3",
3838
"karma-jasmine": "~4.0.0",
3939
"karma-jasmine-html-reporter": "~1.7.0",
40-
"puppeteer": "^10.4.0",
4140
"typescript": "file:../../node_modules/typescript"
4241
}
4342
}

0 commit comments

Comments
 (0)