mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 19:51:50 +00:00
Another step towards https://github.com/sourcegraph/sourcegraph/issues/59155, previously `bazel test //...` would error at analysis time on `//client/web/src/end-to-end:e2e` due to it attempting to perform variable substitution for env vars e.g. `"HEADLESS": "$(E2E_HEADLESS)"`, for values not defined via `--define` (we only set these explicitly in .aspect/bazelrc/ci.sourcegraph.bazelrc and some `sg` targets). By leveraging https://bazel.build/rules/lib/builtins/actions#run.use_default_shell_env, we can allow the test to read values from `--action_env` while _also_ having explicit values set via `env` macro parameter. Previously, setting `env` macro parameter would completely shadow any `--action_env` values. Unfortunately, we cant use `--test_env` for this, as `js_run_binary` is an action not a test (or something like that?). We also cant do env renaming anymore, meaning we have to drop the `E2E_` prefix for some env vars. At least one script needed some reworking to accommodate that `e2e_test.sh`  ## Test plan 👁️ CI once again 👁️
38 lines
1.4 KiB
Diff
38 lines
1.4 KiB
Diff
diff --git a/lib/private/run_binary.bzl b/lib/private/run_binary.bzl
|
|
index 7ba4210..55bd984 100644
|
|
--- a/lib/private/run_binary.bzl
|
|
+++ b/lib/private/run_binary.bzl
|
|
@@ -76,7 +76,7 @@ Possible fixes:
|
|
mnemonic = ctx.attr.mnemonic if ctx.attr.mnemonic else None,
|
|
progress_message = ctx.attr.progress_message if ctx.attr.progress_message else None,
|
|
execution_requirements = ctx.attr.execution_requirements if ctx.attr.execution_requirements else None,
|
|
- use_default_shell_env = False,
|
|
+ use_default_shell_env = True,
|
|
env = dicts.add(ctx.configuration.default_shell_env, envs),
|
|
input_manifests = tool_input_mfs,
|
|
)
|
|
@@ -95,6 +95,7 @@ _run_binary = rule(
|
|
cfg = "exec",
|
|
),
|
|
"env": attr.string_dict(),
|
|
+ "use_default_shell_env": attr.bool(default = False),
|
|
"srcs": attr.label_list(
|
|
allow_files = True,
|
|
),
|
|
@@ -113,6 +114,7 @@ def run_binary(
|
|
srcs = [],
|
|
args = [],
|
|
env = {},
|
|
+ use_default_shell_env = False,
|
|
outs = [],
|
|
out_dirs = [],
|
|
mnemonic = "RunBinary",
|
|
@@ -220,6 +222,7 @@ def run_binary(
|
|
srcs = srcs,
|
|
args = args,
|
|
env = env,
|
|
+ use_default_shell_env = use_default_shell_env,
|
|
outs = outs,
|
|
out_dirs = out_dirs + ([name] if output_dir else []),
|
|
mnemonic = mnemonic,
|