Skip to content

Commit

Permalink
Update workspace_bazel_binaries to take the version values.
Browse files Browse the repository at this point in the history
  • Loading branch information
cgrindel committed Mar 16, 2023
1 parent 12910ac commit c229a18
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
9 changes: 8 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,23 @@ buildifier_prebuilt_register_toolchains()

# MARK: - Integration Tests

load(
"//:bazel_versions.bzl",
"CURRENT_BAZEL_VERSION",
"OTHER_BAZEL_VERSIONS",
"SUPPORTED_BAZEL_VERSIONS",
)
load("//bazel_integration_test/bzlmod:workspace_bazel_binaries.bzl", "workspace_bazel_binaries")

# This is only necessary while rules_bazel_integration_test switches back and
# forth between WORKSPACE repositories and bzlmod repositories.
workspace_bazel_binaries(
name = "bazel_binaries",
current_version = CURRENT_BAZEL_VERSION,
other_versions = OTHER_BAZEL_VERSIONS,
rbt_repo_name = "",
)

load("//:bazel_versions.bzl", "SUPPORTED_BAZEL_VERSIONS")
load("//bazel_integration_test:defs.bzl", "bazel_binaries")

bazel_binaries(versions = SUPPORTED_BAZEL_VERSIONS)
22 changes: 22 additions & 0 deletions bazel_integration_test/bzlmod/workspace_bazel_binaries.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,43 @@

_BAZEL_BINARIES_HELPER_DEFS_BZL = """load("@{rbt_repo_name}//bazel_integration_test/private:integration_test_utils.bzl", "integration_test_utils")
_versions = struct(
current = "{current_version}",
other = {other_versions},
all = {all_versions}
)
bazel_binaries = struct(
label = integration_test_utils.bazel_binary_label,
versions = _versions,
)
"""

def _workspace_bazel_binaries_impl(repository_ctx):
current_version = repository_ctx.attr.current_version
if current_version == "":
fail("A current version must be specified.")
other_versions = repository_ctx.attr.other_versions
all_versions = sorted([current_version] + other_versions)
repository_ctx.file("defs.bzl", _BAZEL_BINARIES_HELPER_DEFS_BZL.format(
rbt_repo_name = repository_ctx.attr.rbt_repo_name,
current_version = current_version,
other_versions = other_versions,
all_versions = all_versions,
))
repository_ctx.file("WORKSPACE")
repository_ctx.file("BUILD.bazel")

workspace_bazel_binaries = repository_rule(
implementation = _workspace_bazel_binaries_impl,
attrs = {
"current_version": attr.string(
doc = "The current version.",
mandatory = True,
),
"other_versions": attr.string_list(
doc = "The other versions",
),
"rbt_repo_name": attr.string(
doc = "The name of the rules_bazel_integration_test repo.",
default = "rules_bazel_integration_test",
Expand Down
4 changes: 2 additions & 2 deletions doc/rules_and_macros_overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ default test runner is provided by the `default_test_runner` macro.
| <a id="bazel_integration_test-env"></a>env | Optional. A dictionary of <code>strings</code>. Specifies additional environment variables to be passed to the test. | <code>{}</code> |
| <a id="bazel_integration_test-env_inherit"></a>env_inherit | Optional. Override the env_inherit values passed to the test. Only do this if you understand what needs to be passed along. Most folks will want to use <code>additional_env_inherit</code> to pass additional env_inherit values. | <code>["SUDO_ASKPASS", "HOME", "CC"]</code> |
| <a id="bazel_integration_test-additional_env_inherit"></a>additional_env_inherit | Optional. Specify additional <code>env_inherit</code> values that should be passed to the test. | <code>[]</code> |
| <a id="bazel_integration_test-bazel_binaries"></a>bazel_binaries | <p align="center"> - </p> | <code>None</code> |
| <a id="bazel_integration_test-bazel_binaries"></a>bazel_binaries | Optional for WORKSPACE loaded repositories. Required for repositories that enable bzlmod. The value for this parameter is loaded by adding <code>load("@bazel_binaries//:defs.bzl", "bazel_binaries")</code> to your build file. | <code>None</code> |
| <a id="bazel_integration_test-kwargs"></a>kwargs | additional attributes like timeout and visibility | none |


Expand Down Expand Up @@ -78,7 +78,7 @@ Macro that defines a set Bazel integration tests each executed with a different
| <a id="bazel_integration_tests-timeout"></a>timeout | A valid Bazel timeout value. https://docs.bazel.build/versions/main/test-encyclopedia.html#role-of-the-test-runner | <code>"long"</code> |
| <a id="bazel_integration_tests-env_inherit"></a>env_inherit | Optional. Override the env_inherit values passed to the test. Only do this if you understand what needs to be passed along. Most folks will want to use <code>additional_env_inherit</code> to pass additional env_inherit values. | <code>["SUDO_ASKPASS", "HOME", "CC"]</code> |
| <a id="bazel_integration_tests-additional_env_inherit"></a>additional_env_inherit | Optional. Specify additional <code>env_inherit</code> values that should be passed to the test. | <code>[]</code> |
| <a id="bazel_integration_tests-bazel_binaries"></a>bazel_binaries | <p align="center"> - </p> | <code>None</code> |
| <a id="bazel_integration_tests-bazel_binaries"></a>bazel_binaries | Optional for WORKSPACE loaded repositories. Required for repositories that enable bzlmod. The value for this parameter is loaded by adding <code>load("@bazel_binaries//:defs.bzl", "bazel_binaries")</code> to your build file. | <code>None</code> |
| <a id="bazel_integration_tests-kwargs"></a>kwargs | additional attributes like timeout and visibility | none |


Expand Down

0 comments on commit c229a18

Please sign in to comment.