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

test: move e2e/ts_auto_deps assertion from circleci to bazelci #1042

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
1 change: 0 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ jobs:
# Additional e2e assertions that can only be done with `yarn test`
- run: cd e2e/symlinked_node_modules_npm && yarn test && bazel clean
- run: cd e2e/symlinked_node_modules_yarn && yarn test && bazel clean
- run: cd e2e/ts_auto_deps && yarn test && bazel clean

- *hide_node_and_yarn_local_binaries

Expand Down
37 changes: 34 additions & 3 deletions e2e/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ E2E_TESTS = {
"e2e_symlinked_node_modules_yarn": {
"//packages/hide-bazel-files:npm_package": "@bazel/hide-bazel-files",
},
"e2e_ts_auto_deps": {
"//packages/typescript:npm_package": "@bazel/typescript",
},
"e2e_ts_devserver": {
"//packages/hide-bazel-files:npm_package": "@bazel/hide-bazel-files",
"//packages/protractor:npm_package": "@bazel/protractor",
Expand Down Expand Up @@ -142,6 +139,40 @@ E2E_TESTS = {
"3.5.x",
]]

bazel_integration_test(
name = "e2e_ts_auto_deps",
bazel_commands = [
"run @nodejs//:yarn",
"run @nodejs//:bin/yarn -- generate_build_file",
"build //simple:simple",
],
# some bazelrc imports are outside of the nested workspace so
# the test runner will handle these as special cases
bazelrc_imports = {
"//:common.bazelrc": "import %workspace%/../../common.bazelrc",
},
check_npm_packages = NPM_PACKAGES,
# package.json will be updated with `file:` links to the absolute paths
# of the generated npm packages in runfiles
npm_packages = {
"//packages/typescript:npm_package": "@bazel/typescript",
},
# replace the following repositories with the generated archives
repositories = {
"//:release": "build_bazel_rules_nodejs",
},
tags = [
"e2e",
# exclusive keyword will force the test to be run in the "exclusive" mode,
# ensuring that no other tests are running at the same time. Such tests
# will be executed in serial fashion after all build activity and non-exclusive
# tests have been completed. Remote execution is disabled for such tests
# because Bazel doesn't have control over what's running on a remote machine.
"exclusive",
],
workspace_files = "@e2e_ts_auto_deps//:all_files",
)

bazel_integration_test(
name = "e2e_angular_bazel_example",
size = "enormous",
Expand Down
6 changes: 0 additions & 6 deletions e2e/ts_auto_deps/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,3 @@ filegroup(
),
visibility = ["//visibility:public"],
)

# Just a dummy test so that we have a test target for //... with bazel_integration_test
sh_test(
name = "dummy_test",
srcs = ["dummy_test.sh"],
)
2 changes: 0 additions & 2 deletions e2e/ts_auto_deps/dummy_test.sh

This file was deleted.

3 changes: 2 additions & 1 deletion e2e/ts_auto_deps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
},
"scripts": {
"pretest": "bazel run @nodejs//:yarn",
"test": "cd simple && ts_auto_deps && bazel build simple"
"generate_build_file": "cd simple && ts_auto_deps",
"test": "yarn generate_build_file && bazel build simple"
}
}
6 changes: 0 additions & 6 deletions e2e/ts_auto_deps/simple/BUILD

This file was deleted.

5 changes: 4 additions & 1 deletion internal/bazel_integration_test/bazel_integration_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ It is assumed by the test runner that the bazel binary is found at label_workspa
),
"bazel_commands": attr.string_list(
default = ["test ..."],
doc = """The list of bazel commands to run. Defaults to `["test ..."]`.""",
doc = """The list of bazel commands to run. Defaults to `["test ..."]`.

Note that if a command contains a bare `--` argument, the --test_arg passed to Bazel will appear before it.
""",
),
"bazelrc_append": attr.string(
doc = """String to append to the .bazelrc file in the workspace-under-test.
Expand Down
14 changes: 11 additions & 3 deletions internal/bazel_integration_test/test_runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ const tmp = require('tmp');
const config = require(process.argv[2]);
if (DEBUG) console.log(`config: ${JSON.stringify(config, null, 2)}`);

const args = process.argv.slice(3);
if (DEBUG) console.log(`args: ${JSON.stringify(args, null, 2)}`);
const testArgs = process.argv.slice(3);
if (DEBUG) console.log(`testArgs: ${JSON.stringify(testArgs, null, 2)}`);

/**
* Helper function to log out the contents of a file.
Expand Down Expand Up @@ -277,7 +277,15 @@ if (DEBUG) {
}

for (const bazelCommand of config.bazelCommands) {
const bazelArgs = bazelCommand.split(' ').concat(args);
const bazelArgs = bazelCommand.split(' ');
// look for `--` argument and insert testArgs before it
// if it exists, otherwise push to end of arguments
const doubleHyphenPos = bazelArgs.indexOf('--');
if (doubleHyphenPos !== -1) {
bazelArgs.splice(doubleHyphenPos, 0, ...testArgs);
} else {
bazelArgs.push(...testArgs);
}
console.log(`\n\nRunning 'bazel ${bazelArgs.join(' ')}'`);
spawnedProcess = spawnSync(bazelBinary, bazelArgs, {cwd: workspaceRoot, stdio: 'inherit'});
if (spawnedProcess.status) {
Expand Down