Skip to content

Commit

Permalink
Unconditionally set inherited_environment
Browse files Browse the repository at this point in the history
Requires increasing the minimum Bazel version to 5.2.0.
  • Loading branch information
fmeum committed Jan 22, 2023
1 parent 5d4f3d9 commit 93bb4f7
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
tasks:
ubuntu1804_bazel400:
platform: ubuntu1804
bazel: 5.1.0 # test minimum supported version of bazel
bazel: 5.2.0 # test minimum supported version of bazel
shell_commands:
- tests/core/cgo/generate_imported_dylib.sh
build_targets:
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ The Go rules are tested and supported on the following host platforms:
Users have reported success on several other platforms, but the rules are
only tested on those listed above.

Note: Since version v0.35.0, rules_go requires Bazel ≥ 5.1.0 to work.
Note: Since version v0.38.0, rules_go requires Bazel ≥ 5.2.0 to work.

The ``master`` branch is only guaranteed to work with the latest version of Bazel.

Expand Down
2 changes: 1 addition & 1 deletion go/private/common.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def get_versioned_shared_lib_extension(path):
# something like 1.2.3, or so.1.2, or dylib.1.2, or foo.1.2
return ""

MINIMUM_BAZEL_VERSION = "5.1.0"
MINIMUM_BAZEL_VERSION = "5.2.0"

def as_list(v):
"""Returns a list, tuple, or depset as a list."""
Expand Down
14 changes: 0 additions & 14 deletions go/private/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,6 @@ load("//go/private:nogo.bzl", "DEFAULT_NOGO", "go_register_nogo")
load("//proto:gogo.bzl", "gogo_special_proto")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# native.bazel_version is only available in WORKSPACE macros
# https://github.com/bazelbuild/bazel/issues/8305
# Needed for guarding env_inherit support https://github.com/bazelbuild/rules_go/pull/3256 which requires 5.2.0+
def _bazel_version_repository_impl(repository_ctx):
repository_ctx.file("bazel_version.bzl", "bazel_version = \"{}\"".format(native.bazel_version))
repository_ctx.file("BUILD", "exports_files([\"bazel_version.bzl\"])")

_bazel_version_repository = repository_rule(
implementation = _bazel_version_repository_impl,
local = True,
)

def go_rules_dependencies(force = False):
"""Declares workspaces the Go rules depend on. Workspaces that use
rules_go should call this.
Expand All @@ -50,8 +38,6 @@ def go_rules_dependencies(force = False):
if getattr(native, "bazel_version", None):
versions.check(MINIMUM_BAZEL_VERSION, bazel_version = native.bazel_version)

_bazel_version_repository(name = "rules_go_bazel_version")

if force:
wrapper = _always
else:
Expand Down
2 changes: 0 additions & 2 deletions go/private/rules/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,7 @@ bzl_library(
"//go/private:providers",
"//go/private/rules:binary",
"//go/private/rules:transition",
"//go/private/skylib/lib:versions",
"@bazel_skylib//lib:structs",
"@rules_go_bazel_version//:bazel_version.bzl",
],
)

Expand Down
12 changes: 1 addition & 11 deletions go/private/rules/test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ load(
"@bazel_skylib//lib:structs.bzl",
"structs",
)
load("@rules_go_bazel_version//:bazel_version.bzl", "bazel_version")
load(
"//go/private/skylib/lib:versions.bzl",
"versions",
)

def _go_test_impl(ctx):
"""go_test_impl implements go testing.
Expand Down Expand Up @@ -168,12 +163,7 @@ def _go_test_impl(ctx):
for k, v in ctx.attr.env.items():
env[k] = ctx.expand_location(v, ctx.attr.data)

test_environment = testing.TestEnvironment(env)
if ctx.attr.env_inherit:
# inherited_environment is only available in Bazel 5.2.0+
# https://github.com/bazelbuild/rules_go/pull/3256
versions.check("5.2.0", bazel_version = bazel_version)
test_environment = testing.TestEnvironment(env, ctx.attr.env_inherit)
test_environment = testing.TestEnvironment(env, ctx.attr.env_inherit)

# Bazel only looks for coverage data if the test target has an
# InstrumentedFilesProvider. If the provider is found and at least one
Expand Down

0 comments on commit 93bb4f7

Please sign in to comment.