Skip to content

Commit f46d860

Browse files
Deprecate --incompatible_repo_env_ignores_action_env
1 parent 1224c0b commit f46d860

File tree

5 files changed

+11
-116
lines changed

5 files changed

+11
-116
lines changed

src/main/java/com/google/devtools/build/lib/analysis/config/CoreOptions.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -463,9 +463,6 @@ If specified, the value of the cpu constraint (`@platforms//cpu:cpu`) of
463463
`=name`, which unsets the variable of that name. This option can be used
464464
multiple times; for options given for the same variable, the latest wins,
465465
options for different variables accumulate.
466-
467-
Note that unless `--incompatible_repo_env_ignores_action_env` is true, all `name=value`
468-
pairs will be available to repository rules.
469466
""")
470467
public List<Converters.EnvVar> actionEnvironment;
471468

src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRulesModule.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,16 @@ public static final class AllCommandGraveyardOptions extends OptionsBase {
965965
effectTags = {OptionEffectTag.NO_OP},
966966
help = "No-op.")
967967
public boolean legacyLocalFallback;
968+
969+
@Deprecated
970+
@Option(
971+
name = "incompatible_repo_env_ignores_action_env",
972+
defaultValue = "true",
973+
documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
974+
effectTags = {OptionEffectTag.NO_OP},
975+
metadataTags = {OptionMetadataTag.DEPRECATED},
976+
help = "No-op.")
977+
public boolean repoEnvIgnoresActionEnv;
968978
}
969979

970980
@Override

src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -345,18 +345,12 @@ public void exit(AbruptExitException exception) {
345345
switch (envVar) {
346346
case Converters.EnvVar.Set(String name, String value) -> {
347347
visibleActionEnv.remove(name);
348-
if (!options.getOptions(CommonCommandOptions.class).repoEnvIgnoresActionEnv) {
349-
repoEnv.put(name, value);
350-
}
351348
}
352349
case Converters.EnvVar.Inherit(String name) -> {
353350
visibleActionEnv.add(name);
354351
}
355352
case Converters.EnvVar.Unset(String name) -> {
356353
visibleActionEnv.remove(name);
357-
if (!options.getOptions(CommonCommandOptions.class).repoEnvIgnoresActionEnv) {
358-
repoEnv.remove(name);
359-
}
360354
}
361355
}
362356
}
@@ -972,9 +966,7 @@ public String determineOutputFileSystem() {
972966
}
973967

974968
/**
975-
* Returns the repository environment created from the client environment, {@code --repo_env}, and
976-
* {@code --action_env=NAME=VALUE} (when {@code
977-
* --incompatible_repo_env_ignores_action_env=false}).
969+
* Returns the repository environment created from the client environment and {@code --repo_env}.
978970
*/
979971
public Map<String, String> getRepoEnv() {
980972
return Collections.unmodifiableMap(repoEnv);

src/main/java/com/google/devtools/build/lib/runtime/CommonCommandOptions.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -621,19 +621,6 @@ public String getTypeDescription() {
621621
""")
622622
public List<Converters.EnvVar> repositoryEnvironment;
623623

624-
@Option(
625-
name = "incompatible_repo_env_ignores_action_env",
626-
defaultValue = "true",
627-
documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
628-
effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS},
629-
metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE},
630-
help =
631-
"""
632-
If true, <code>--action_env=NAME=VALUE</code> will no longer affect repository rule \
633-
and module extension environments.
634-
""")
635-
public boolean repoEnvIgnoresActionEnv;
636-
637624
@Option(
638625
name = "heuristically_drop_nodes",
639626
oldName = "experimental_heuristically_drop_nodes",

src/test/shell/bazel/starlark_repository_test.sh

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -582,37 +582,6 @@ function environ_invalidation_test_template() {
582582
assert_equals 6 $(cat "${execution_file}")
583583
}
584584

585-
function environ_invalidation_action_env_test_template() {
586-
local startup_flag="${1-}"
587-
local command_flag="--noincompatible_repo_env_ignores_action_env"
588-
setup_starlark_repository
589-
590-
# We use a counter to avoid other invalidation to hide repository
591-
# invalidation (e.g., --action_env=K=V will cause all repositories to re-run).
592-
local execution_file="$(setup_invalidation_test)"
593-
594-
# Set to FOO=BAZ BAR=FOO
595-
FOO=BAZ BAR=FOO bazel ${startup_flag} build "${command_flag}" @foo//:bar >& $TEST_log \
596-
|| fail "Failed to build"
597-
expect_log "<1> FOO=BAZ BAR=FOO BAZ=undefined"
598-
assert_equals 1 $(cat "${execution_file}")
599-
600-
# Test with changing using --action_env
601-
bazel ${startup_flag} build "${command_flag}" \
602-
--action_env FOO=BAZ --action_env BAR=FOO --action_env BEZ=BAR \
603-
@foo//:bar >& $TEST_log || fail "Failed to build"
604-
assert_equals 1 $(cat "${execution_file}")
605-
bazel ${startup_flag} build "${command_flag}" \
606-
--action_env FOO=BAZ --action_env BAR=FOO --action_env BAZ=BAR \
607-
@foo//:bar >& $TEST_log || fail "Failed to build"
608-
assert_equals 1 $(cat "${execution_file}")
609-
bazel ${startup_flag} build "${command_flag}" \
610-
--action_env FOO=BAR --action_env BAR=FOO --action_env BAZ=BAR \
611-
@foo//:bar >& $TEST_log || fail "Failed to build"
612-
expect_log "<2> FOO=BAR BAR=FOO BAZ=BAR"
613-
assert_equals 2 $(cat "${execution_file}")
614-
}
615-
616585
function test_starlark_repository_environ_invalidation() {
617586
environ_invalidation_test_template
618587
}
@@ -622,14 +591,6 @@ function test_starlark_repository_environ_invalidation_batch() {
622591
environ_invalidation_test_template --batch
623592
}
624593

625-
function test_starlark_repository_environ_invalidation_action_env() {
626-
environ_invalidation_action_env_test_template
627-
}
628-
629-
function test_starlark_repository_environ_invalidation_action_env_batch() {
630-
environ_invalidation_action_env_test_template --batch
631-
}
632-
633594
# Test invalidation based on change to the bzl files
634595
function bzl_invalidation_test_template() {
635596
local startup_flag="${1-}"
@@ -3016,58 +2977,6 @@ EOF
30162977
@repo//... &> $TEST_log || fail "expected Bazel to succeed"
30172978
}
30182979

3019-
function test_execute_environment_repo_env_ignores_action_env_off() {
3020-
cat >> $(setup_module_dot_bazel) <<'EOF'
3021-
my_repo = use_repo_rule("//:repo.bzl", "my_repo")
3022-
my_repo(name="repo")
3023-
EOF
3024-
touch BUILD
3025-
cat > repo.bzl <<'EOF'
3026-
def _impl(ctx):
3027-
st = ctx.execute(
3028-
["env"],
3029-
)
3030-
if st.return_code:
3031-
fail("Command did not succeed")
3032-
vars = {line.partition("=")[0]: line.partition("=")[-1] for line in st.stdout.strip().split("\n")}
3033-
if vars.get("ACTION_ENV_PRESENT") != "value1":
3034-
fail("ACTION_ENV_PRESENT has wrong value: " + vars.get("ACTION_ENV_PRESENT"))
3035-
ctx.file("BUILD", "exports_files(['data.txt'])")
3036-
my_repo = repository_rule(_impl)
3037-
EOF
3038-
3039-
bazel build \
3040-
--noincompatible_repo_env_ignores_action_env \
3041-
--action_env=ACTION_ENV_PRESENT=value1 \
3042-
@repo//... &> $TEST_log || fail "expected Bazel to succeed"
3043-
}
3044-
3045-
function test_execute_environment_repo_env_ignores_action_env_on() {
3046-
cat >> $(setup_module_dot_bazel) <<'EOF'
3047-
my_repo = use_repo_rule("//:repo.bzl", "my_repo")
3048-
my_repo(name="repo")
3049-
EOF
3050-
touch BUILD
3051-
cat > repo.bzl <<'EOF'
3052-
def _impl(ctx):
3053-
st = ctx.execute(
3054-
["env"],
3055-
)
3056-
if st.return_code:
3057-
fail("Command did not succeed")
3058-
vars = {line.partition("=")[0]: line.partition("=")[-1] for line in st.stdout.strip().split("\n")}
3059-
if "ACTION_ENV_REMOVED" in vars:
3060-
fail("ACTION_ENV_REMOVED should not be in the environment")
3061-
ctx.file("BUILD", "exports_files(['data.txt'])")
3062-
my_repo = repository_rule(_impl)
3063-
EOF
3064-
3065-
bazel build \
3066-
--incompatible_repo_env_ignores_action_env \
3067-
--action_env=ACTION_ENV_REMOVED=value1 \
3068-
@repo//... &> $TEST_log || fail "expected Bazel to succeed"
3069-
}
3070-
30712980
function test_dependency_on_repo_with_invalid_name() {
30722981
cat >> $(setup_module_dot_bazel) <<'EOF'
30732982
my_repo = use_repo_rule("//:repo.bzl", "my_repo")

0 commit comments

Comments
 (0)