Skip to content

Commit

Permalink
chore: move tool fetches to rules_multitool
Browse files Browse the repository at this point in the history
Prefactoring for removing WORKSPACE
  • Loading branch information
alexeagle committed Jan 25, 2025
1 parent c9d63b9 commit a21e201
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 46 deletions.
3 changes: 0 additions & 3 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ build --incompatible_strict_action_env
build --nolegacy_external_runfiles
common --test_env=DOCKER_HOST --action_env=DOCKER_HOST --repo_env=DOCKER_HOST

# Disable bzlmod lockfile
common --lockfile_mode=off

# On bazel 6.4.0 these are needed to successfully fetch images.
common:needs_credential_helpers --credential_helper=public.ecr.aws=%workspace%/examples/credential_helper/auth.sh
common:needs_credential_helpers --credential_helper=index.docker.io=%workspace%/examples/credential_helper/auth.sh
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ jobs:
# TODO: fix
- folder: e2e/wasm
bzlmodEnabled: true
# Don't test the root module with WORKSPACE at all
- folder: .
bzlmodEnabled: false
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
Expand Down
7 changes: 7 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,10 @@ bazel_dep(name = "gazelle", version = "0.35.0", dev_dependency = True, repo_name
bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.4.1", dev_dependency = True)
bazel_dep(name = "rules_multirun", version = "0.9.0", dev_dependency = True)
bazel_dep(name = "stardoc", version = "0.6.2", dev_dependency = True, repo_name = "io_bazel_stardoc")
bazel_dep(name = "rules_multitool", version = "1.0.0", dev_dependency = True)

# Should be dev_dependency=True
# but that causes ERROR: root_module_direct_deps must be empty if the root module contains no usages with dev_dependency = False
multitool = use_extension("@rules_multitool//multitool:extension.bzl", "multitool")
multitool.hub(lockfile = "//examples:assertion_tools.lock.json")
use_repo(multitool, "multitool")
6 changes: 1 addition & 5 deletions examples/assert.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,7 @@ def assert_oci_config(
"$(location %s)" % expected,
"$(location %s)" % actual,
],
src = select({
"//examples:platform_darwin_arm64": "@jd_darwin_arm64//file",
"//examples:platform_linux_amd64": "@jd_linux_amd64//file",
"//examples:platform_darwin_amd64": "@jd_darwin_amd64//file",
}),
src = "@multitool//tools/jd",
out = name,
)

Expand Down
28 changes: 28 additions & 0 deletions examples/assertion_tools.lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"$schema": "https://raw.githubusercontent.com/theoremlp/rules_multitool/main/lockfile.schema.json",
"jd": {
"binaries": [
{
"kind": "file",
"url": "https://github.com/josephburnett/jd/releases/download/v1.8.1/jd-arm64-darwin",
"sha256": "8b0e51b902650287b7dedc2beee476b96c5d589309d3a7f556334c1baedbec61",
"os": "macos",
"cpu": "arm64"
},
{
"kind": "file",
"url": "https://github.com/josephburnett/jd/releases/download/v1.8.1/jd-amd64-darwin",
"sha256": "c5fb5503d2804b1bf631bf12616d56b89711fd451ab233b688ca922402ff3444",
"os": "macos",
"cpu": "x86_64"
},
{
"kind": "file",
"url": "https://github.com/josephburnett/jd/releases/download/v1.8.1/jd-amd64-linux",
"sha256": "ab918f52130561abd4f88d9c2d3ae95d4d56f1a2dff9762665890349d61c763e",
"os": "linux",
"cpu": "x86_64"
}
]
}
}
31 changes: 2 additions & 29 deletions examples/setup_assertion_repos.bzl
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"Setup for docker testing"

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

def _impl_configure_docker(rctx):
# See if docker_host is set
has_docker = "DOCKER_HOST" in rctx.os.environ

# See if standard docker sock exists
if not has_docker:
r = rctx.execute(["stat", "/var/run/docker.sock"])
Expand All @@ -13,7 +14,6 @@ def _impl_configure_docker(rctx):

compatible_with = "[]" if has_docker else '["@platforms//:incompatible"]'


rctx.file("defs.bzl", """
# Generated by configure_docker.bzl
TARGET_COMPATIBLE_WITH = %s
Expand All @@ -27,33 +27,6 @@ configure_docker = repository_rule(

def setup_assertion_repos():
"creates repos necessary for testing agaisnt docker"
http_file(
name = "jd_darwin_arm64",
urls = [
"https://github.com/josephburnett/jd/releases/download/v1.8.1/jd-arm64-darwin",
],
sha256 = "8b0e51b902650287b7dedc2beee476b96c5d589309d3a7f556334c1baedbec61",
executable = True,
)

http_file(
name = "jd_darwin_amd64",
urls = [
"https://github.com/josephburnett/jd/releases/download/v1.8.1/jd-amd64-darwin",
],
sha256 = "c5fb5503d2804b1bf631bf12616d56b89711fd451ab233b688ca922402ff3444",
executable = True,
)

http_file(
name = "jd_linux_amd64",
urls = [
"https://github.com/josephburnett/jd/releases/download/v1.8.1/jd-amd64-linux",
],
sha256 = "ab918f52130561abd4f88d9c2d3ae95d4d56f1a2dff9762665890349d61c763e",
executable = True,
)

http_archive(
name = "docker_cli_darwin_arm64",
urls = [
Expand Down
9 changes: 0 additions & 9 deletions internal_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@ def http_archive(**kwargs):
def rules_oci_internal_deps():
"Fetch deps needed for local development"

http_archive(
name = "io_bazel_rules_go",
sha256 = "80a98277ad1311dacd837f9b16db62887702e9f1d1c4c9f796d0121a46c8e184",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.46.0/rules_go-v0.46.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.46.0/rules_go-v0.46.0.zip",
],
)

http_archive(
name = "bazel_gazelle",
integrity = "sha256-MpOL2hbmcABjA1R5Bj2dJMYO2o15/Uc5Vj9Q0zHLMgk=",
Expand Down

0 comments on commit a21e201

Please sign in to comment.