Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: run integration tests in sandbox and with RBE #24114

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,18 @@ build:remote --auth_enabled=true
# is provided by the shared dev-infra package and targets k8 remote containers.
build:remote --crosstool_top=@npm//@angular/dev-infra-private/bazel/remote-execution/cpp:cc_toolchain_suite
build:remote --extra_toolchains=@npm//@angular/dev-infra-private/bazel/remote-execution/cpp:cc_toolchain
build:remote --extra_execution_platforms=@npm//@angular/dev-infra-private/bazel/remote-execution:platform
build:remote --host_platform=@npm//@angular/dev-infra-private/bazel/remote-execution:platform
build:remote --platforms=@npm//@angular/dev-infra-private/bazel/remote-execution:platform
build:remote --extra_execution_platforms=@npm//@angular/dev-infra-private/bazel/remote-execution:platform_with_network
build:remote --host_platform=@npm//@angular/dev-infra-private/bazel/remote-execution:platform_with_network
build:remote --platforms=@npm//@angular/dev-infra-private/bazel/remote-execution:platform_with_network

################################
# Sandbox settings #
################################

# By default, network access should be disabled unless explicitly granted for certain targets
# using the `requires-network` tag. https://docs.bazel.build/versions/main/be/common-definitions.html
build --sandbox_default_allow_network=false
test --sandbox_default_allow_network=false

################################
# --config=build-results #
Expand Down
23 changes: 7 additions & 16 deletions integration/ng-add/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ node_integration_test(
"yarn test",
],
npm_packages = npmPackageMappings,
setup_chromium = True,
tags = [
# Chromium cannot run in Sandbox. For this test, sandbox is disabled.
# Additionally, we need to disable RBE as this test relies on internet
# access for installing the NPM packages.
"no-sandbox",
"no-remote-exec",
# This test relies on `yarn` so there needs to be internet access.
"requires-network",
],
)

Expand All @@ -41,21 +39,14 @@ node_integration_test(
# See: https://github.com/yarnpkg/yarn/issues/2165.
# TODO(devversion): determine if a solution/workaround could live in the test runner.
"yarn install --cache-folder .yarn_cache_folder/",
"node --version",
"yarn node --version",
"yarn ng add @angular/material",
"yarn test",
],
node_repository = "node12_host",
npm_packages = npmPackageMappings,
setup_chromium = True,
tags = [
# Chromium cannot run in Sandbox. For this test, sandbox is disabled.
# Additionally, we need to disable RBE as this test relies on internet
# access for installing the NPM packages.
"no-sandbox",
"no-remote-exec",
# This test relies on `yarn` so there needs to be internet access.
"requires-network",
],
tool_mappings = {
"@node12_host//:yarn_bin": "yarn",
"@node12_host//:node_bin": "node",
},
)
15 changes: 9 additions & 6 deletions integration/ng-add/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html

// This code runs within Bazel where the environment does not have access to
// the system Chrome browser. To workaround this we use Puppeteer to provide
// a local version of Chromium that can run within Bazel.
process.env.CHROME_BIN = require('puppeteer').executablePath();

module.exports = function (config) {
config.set({
basePath: '',
Expand Down Expand Up @@ -34,12 +29,20 @@ module.exports = function (config) {
subdir: '.',
reporters: [{type: 'html'}, {type: 'text-summary'}],
},
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: ['--no-sandbox'],
},
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['ChromeHeadless'],
// Chrome cannot run with sandbox enabled as this test already runs within
// the Bazel sandbox environment and the sandboxes would conflict otherwise.
browsers: ['ChromeHeadlessNoSandbox'],
singleRun: false,
restartOnFileChange: true,
});
Expand Down
1 change: 0 additions & 1 deletion integration/ng-add/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "~1.7.0",
"puppeteer": "^10.4.0",
"typescript": "file:../../node_modules/typescript"
}
}
Loading