Skip to content

Commit

Permalink
Migrate bb-browser to bzlmod
Browse files Browse the repository at this point in the history
  • Loading branch information
EdSchouten committed Mar 30, 2024
1 parent fc78080 commit 8daa911
Show file tree
Hide file tree
Showing 21 changed files with 13,721 additions and 2,044 deletions.
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.4.0
7.1.1
40 changes: 22 additions & 18 deletions .github/workflows/master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@
"name": "Installing Bazel",
"run": "v=$(cat .bazelversion) && curl -L https://github.com/bazelbuild/bazel/releases/download/${v}/bazel-${v}-linux-x86_64 > ~/bazel && chmod +x ~/bazel && echo ~ >> ${GITHUB_PATH}"
},
{
"name": "Bazel mod tidy",
"run": "bazel mod tidy"
},
{
"name": "Gazelle",
"run": "bazel run //:gazelle -- update-repos -from_file=go.mod -to_macro go_dependencies.bzl%go_dependencies -prune && bazel run //:gazelle"
"run": "rm $(find . -name '*.pb.go' | sed -e 's/[^/]*$/BUILD.bazel/') && bazel run //:gazelle"
},
{
"name": "Buildifier",
"run": "sed '/^$/d' go_dependencies.bzl > go_dependencies.bzl.new && mv go_dependencies.bzl.new go_dependencies.bzl && bazel run @com_github_bazelbuild_buildtools//:buildifier"
"run": "bazel run @com_github_bazelbuild_buildtools//:buildifier"
},
{
"name": "Gofmt",
Expand Down Expand Up @@ -49,11 +53,11 @@
},
{
"name": "linux_amd64: build and test",
"run": "bazel test --test_output=errors --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 //..."
"run": "bazel test --test_output=errors --platforms=@rules_go//go/toolchain:linux_amd64 //..."
},
{
"name": "linux_amd64: copy bb_browser",
"run": "rm -f bb_browser && bazel run --run_under cp --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 //cmd/bb_browser $(pwd)/bb_browser"
"run": "rm -f bb_browser && bazel run --run_under cp --platforms=@rules_go//go/toolchain:linux_amd64 //cmd/bb_browser $(pwd)/bb_browser"
},
{
"name": "linux_amd64: upload bb_browser",
Expand All @@ -65,11 +69,11 @@
},
{
"name": "linux_386: build and test",
"run": "bazel test --test_output=errors --platforms=@io_bazel_rules_go//go/toolchain:linux_386 //..."
"run": "bazel test --test_output=errors --platforms=@rules_go//go/toolchain:linux_386 //..."
},
{
"name": "linux_386: copy bb_browser",
"run": "rm -f bb_browser && bazel run --run_under cp --platforms=@io_bazel_rules_go//go/toolchain:linux_386 //cmd/bb_browser $(pwd)/bb_browser"
"run": "rm -f bb_browser && bazel run --run_under cp --platforms=@rules_go//go/toolchain:linux_386 //cmd/bb_browser $(pwd)/bb_browser"
},
{
"name": "linux_386: upload bb_browser",
Expand All @@ -81,11 +85,11 @@
},
{
"name": "linux_arm: build and test",
"run": "bazel build --platforms=@io_bazel_rules_go//go/toolchain:linux_arm //..."
"run": "bazel build --platforms=@rules_go//go/toolchain:linux_arm //..."
},
{
"name": "linux_arm: copy bb_browser",
"run": "rm -f bb_browser && bazel run --run_under cp --platforms=@io_bazel_rules_go//go/toolchain:linux_arm //cmd/bb_browser $(pwd)/bb_browser"
"run": "rm -f bb_browser && bazel run --run_under cp --platforms=@rules_go//go/toolchain:linux_arm //cmd/bb_browser $(pwd)/bb_browser"
},
{
"name": "linux_arm: upload bb_browser",
Expand All @@ -97,11 +101,11 @@
},
{
"name": "linux_arm64: build and test",
"run": "bazel build --platforms=@io_bazel_rules_go//go/toolchain:linux_arm64 //..."
"run": "bazel build --platforms=@rules_go//go/toolchain:linux_arm64 //..."
},
{
"name": "linux_arm64: copy bb_browser",
"run": "rm -f bb_browser && bazel run --run_under cp --platforms=@io_bazel_rules_go//go/toolchain:linux_arm64 //cmd/bb_browser $(pwd)/bb_browser"
"run": "rm -f bb_browser && bazel run --run_under cp --platforms=@rules_go//go/toolchain:linux_arm64 //cmd/bb_browser $(pwd)/bb_browser"
},
{
"name": "linux_arm64: upload bb_browser",
Expand All @@ -113,11 +117,11 @@
},
{
"name": "darwin_amd64: build and test",
"run": "bazel build --platforms=@io_bazel_rules_go//go/toolchain:darwin_amd64 //..."
"run": "bazel build --platforms=@rules_go//go/toolchain:darwin_amd64 //..."
},
{
"name": "darwin_amd64: copy bb_browser",
"run": "rm -f bb_browser && bazel run --run_under cp --platforms=@io_bazel_rules_go//go/toolchain:darwin_amd64 //cmd/bb_browser $(pwd)/bb_browser"
"run": "rm -f bb_browser && bazel run --run_under cp --platforms=@rules_go//go/toolchain:darwin_amd64 //cmd/bb_browser $(pwd)/bb_browser"
},
{
"name": "darwin_amd64: upload bb_browser",
Expand All @@ -129,11 +133,11 @@
},
{
"name": "darwin_arm64: build and test",
"run": "bazel build --platforms=@io_bazel_rules_go//go/toolchain:darwin_arm64 //..."
"run": "bazel build --platforms=@rules_go//go/toolchain:darwin_arm64 //..."
},
{
"name": "darwin_arm64: copy bb_browser",
"run": "rm -f bb_browser && bazel run --run_under cp --platforms=@io_bazel_rules_go//go/toolchain:darwin_arm64 //cmd/bb_browser $(pwd)/bb_browser"
"run": "rm -f bb_browser && bazel run --run_under cp --platforms=@rules_go//go/toolchain:darwin_arm64 //cmd/bb_browser $(pwd)/bb_browser"
},
{
"name": "darwin_arm64: upload bb_browser",
Expand All @@ -145,11 +149,11 @@
},
{
"name": "freebsd_amd64: build and test",
"run": "bazel build --platforms=@io_bazel_rules_go//go/toolchain:freebsd_amd64 //cmd/bb_browser"
"run": "bazel build --platforms=@rules_go//go/toolchain:freebsd_amd64 //cmd/bb_browser"
},
{
"name": "freebsd_amd64: copy bb_browser",
"run": "rm -f bb_browser && bazel run --run_under cp --platforms=@io_bazel_rules_go//go/toolchain:freebsd_amd64 //cmd/bb_browser $(pwd)/bb_browser"
"run": "rm -f bb_browser && bazel run --run_under cp --platforms=@rules_go//go/toolchain:freebsd_amd64 //cmd/bb_browser $(pwd)/bb_browser"
},
{
"name": "freebsd_amd64: upload bb_browser",
Expand All @@ -161,11 +165,11 @@
},
{
"name": "windows_amd64: build and test",
"run": "bazel build --platforms=@io_bazel_rules_go//go/toolchain:windows_amd64 //..."
"run": "bazel build --platforms=@rules_go//go/toolchain:windows_amd64 //..."
},
{
"name": "windows_amd64: copy bb_browser",
"run": "rm -f bb_browser.exe && bazel run --run_under cp --platforms=@io_bazel_rules_go//go/toolchain:windows_amd64 //cmd/bb_browser $(pwd)/bb_browser.exe"
"run": "rm -f bb_browser.exe && bazel run --run_under cp --platforms=@rules_go//go/toolchain:windows_amd64 //cmd/bb_browser $(pwd)/bb_browser.exe"
},
{
"name": "windows_amd64: upload bb_browser",
Expand Down
24 changes: 14 additions & 10 deletions .github/workflows/pull-requests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@
"name": "Installing Bazel",
"run": "v=$(cat .bazelversion) && curl -L https://github.com/bazelbuild/bazel/releases/download/${v}/bazel-${v}-linux-x86_64 > ~/bazel && chmod +x ~/bazel && echo ~ >> ${GITHUB_PATH}"
},
{
"name": "Bazel mod tidy",
"run": "bazel mod tidy"
},
{
"name": "Gazelle",
"run": "bazel run //:gazelle -- update-repos -from_file=go.mod -to_macro go_dependencies.bzl%go_dependencies -prune && bazel run //:gazelle"
"run": "rm $(find . -name '*.pb.go' | sed -e 's/[^/]*$/BUILD.bazel/') && bazel run //:gazelle"
},
{
"name": "Buildifier",
"run": "sed '/^$/d' go_dependencies.bzl > go_dependencies.bzl.new && mv go_dependencies.bzl.new go_dependencies.bzl && bazel run @com_github_bazelbuild_buildtools//:buildifier"
"run": "bazel run @com_github_bazelbuild_buildtools//:buildifier"
},
{
"name": "Gofmt",
Expand Down Expand Up @@ -49,35 +53,35 @@
},
{
"name": "linux_amd64: build and test",
"run": "bazel test --test_output=errors --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 //..."
"run": "bazel test --test_output=errors --platforms=@rules_go//go/toolchain:linux_amd64 //..."
},
{
"name": "linux_386: build and test",
"run": "bazel test --test_output=errors --platforms=@io_bazel_rules_go//go/toolchain:linux_386 //..."
"run": "bazel test --test_output=errors --platforms=@rules_go//go/toolchain:linux_386 //..."
},
{
"name": "linux_arm: build and test",
"run": "bazel build --platforms=@io_bazel_rules_go//go/toolchain:linux_arm //..."
"run": "bazel build --platforms=@rules_go//go/toolchain:linux_arm //..."
},
{
"name": "linux_arm64: build and test",
"run": "bazel build --platforms=@io_bazel_rules_go//go/toolchain:linux_arm64 //..."
"run": "bazel build --platforms=@rules_go//go/toolchain:linux_arm64 //..."
},
{
"name": "darwin_amd64: build and test",
"run": "bazel build --platforms=@io_bazel_rules_go//go/toolchain:darwin_amd64 //..."
"run": "bazel build --platforms=@rules_go//go/toolchain:darwin_amd64 //..."
},
{
"name": "darwin_arm64: build and test",
"run": "bazel build --platforms=@io_bazel_rules_go//go/toolchain:darwin_arm64 //..."
"run": "bazel build --platforms=@rules_go//go/toolchain:darwin_arm64 //..."
},
{
"name": "freebsd_amd64: build and test",
"run": "bazel build --platforms=@io_bazel_rules_go//go/toolchain:freebsd_amd64 //cmd/bb_browser"
"run": "bazel build --platforms=@rules_go//go/toolchain:freebsd_amd64 //cmd/bb_browser"
},
{
"name": "windows_amd64: build and test",
"run": "bazel build --platforms=@io_bazel_rules_go//go/toolchain:windows_amd64 //..."
"run": "bazel build --platforms=@rules_go//go/toolchain:windows_amd64 //..."
}
]
}
Expand Down
8 changes: 7 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
load("@bazel_gazelle//:def.bzl", "gazelle")
load("@com_github_buildbarn_bb_browser_npm//:defs.bzl", "npm_link_all_packages")
load("@gazelle//:def.bzl", "gazelle")

# gazelle:go_naming_convention_external import
# gazelle:prefix github.com/buildbarn/bb-browser
# gazelle:resolve proto build/bazel/remote/execution/v2/remote_execution.proto @com_github_bazelbuild_remote_apis//build/bazel/remote/execution/v2:remote_execution_proto
# gazelle:resolve proto go build/bazel/remote/execution/v2/remote_execution.proto @com_github_bazelbuild_remote_apis//build/bazel/remote/execution/v2:execution
Expand All @@ -14,3 +16,7 @@ load("@bazel_gazelle//:def.bzl", "gazelle")
gazelle(
name = "gazelle",
)

npm_link_all_packages(
name = "node_modules",
)
122 changes: 122 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
module(name = "com_github_buildbarn_bb_browser")

bazel_dep(name = "aspect_rules_js", version = "1.39.1")
bazel_dep(name = "com_github_buildbarn_bb_remote_execution")
bazel_dep(name = "com_github_buildbarn_bb_storage")
bazel_dep(name = "com_github_buildbarn_go_xdr")
bazel_dep(name = "gazelle", version = "0.35.0")
bazel_dep(name = "jsonnet_go", version = "0.20.0", repo_name = "google_jsonnet_go")
bazel_dep(name = "protobuf", version = "23.1")
bazel_dep(name = "rules_go", version = "0.46.0")
bazel_dep(name = "toolchains_llvm", version = "1.0.0")

git_override(
module_name = "com_github_buildbarn_bb_remote_execution",
commit = "efa691334b0c8b47c6fedd73c6ad434ba166c647",
remote = "https://github.com/buildbarn/bb-remote-execution.git",
)

git_override(
module_name = "com_github_buildbarn_bb_storage",
commit = "00c3edab9fbee741613670dc3c20404910b9076f",
remote = "https://github.com/buildbarn/bb-storage.git",
)

git_override(
module_name = "com_github_buildbarn_go_xdr",
commit = "9cb8426d3e09e301c2b12c993e54ef795a665a92",
remote = "https://github.com/buildbarn/go-xdr.git",
)

git_override(
module_name = "gazelle",
commit = "f5a5c5dc90b4d6a39f0f47d770eba27c6c1c1877",
patches = ["//:patches/gazelle/googleapis.diff"],
remote = "https://github.com/bazelbuild/bazel-gazelle.git",
)

git_override(
module_name = "rules_antlr",
commit = "89a29cca479363a5aee53e203719510bdc6be6ff",
patches = [
"//:patches/rules_antlr/antlr-4.10.diff",
"//:patches/rules_antlr/bzlmod.diff",
],
remote = "https://github.com/marcohu/rules_antlr.git",
)

go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")
use_repo(
go_deps,
"cc_mvdan_gofumpt",
"com_github_bazelbuild_buildtools",
"com_github_bazelbuild_remote_apis",
"com_github_buildkite_terminal_to_html",
"com_github_dustin_go_humanize",
"com_github_gorilla_mux",
"com_github_jmespath_go_jmespath",
"com_github_kballard_go_shellquote",
"org_golang_google_grpc",
"org_golang_google_protobuf",
"org_golang_x_lint",
"org_gonum_v1_plot",
)

go_deps_dev = use_extension("@gazelle//:extensions.bzl", "go_deps", dev_dependency = True)
go_deps_dev.gazelle_override(
build_file_generation = "on",
directives = [
"gazelle:resolve proto go build/bazel/semver/semver.proto //build/bazel/semver",
"gazelle:resolve proto go google/api/annotations.proto @org_golang_google_genproto_googleapis_api//annotations",
"gazelle:resolve proto go google/longrunning/operations.proto @com_google_cloud_go_longrunning//autogen/longrunningpb",
"gazelle:resolve proto go google/rpc/status.proto @org_golang_google_genproto_googleapis_rpc//status",
"gazelle:resolve proto google/api/annotations.proto @googleapis//google/api:annotations_proto",
"gazelle:resolve proto google/longrunning/operations.proto @googleapis//google/longrunning:operations_proto",
"gazelle:resolve proto google/rpc/status.proto @googleapis//google/rpc:status_proto",
],
path = "github.com/bazelbuild/remote-apis",
)
go_deps_dev.module_override(
patches = ["//:patches/com_github_buildkite_terminal_to_html/assets.diff"],
path = "github.com/buildkite/terminal-to-html",
)
go_deps_dev.module_override(
patches = ["@com_github_buildbarn_bb_storage//:patches/com_github_golang_protobuf/service-registrar.diff"],
path = "github.com/golang/protobuf",
)
go_deps_dev.module_override(
patches = ["@com_github_buildbarn_bb_storage//:patches/com_github_grpc_ecosystem_go_grpc_prometheus/client-metrics-prevent-handled-twice.diff"],
path = "github.com/grpc-ecosystem/go-grpc-prometheus",
)

http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "com_github_twbs_bootstrap",
build_file_content = """exports_files(["css/bootstrap.min.css", "js/bootstrap.min.js"])""",
sha256 = "395342b2974e3350560e65752d36aab6573652b11cc6cb5ef79a2e5e83ad64b1",
strip_prefix = "bootstrap-5.1.0-dist",
urls = ["https://github.com/twbs/bootstrap/releases/download/v5.1.0/bootstrap-5.1.0-dist.zip"],
)

http_archive(
name = "io_bazel_rules_jsonnet",
sha256 = "c51ba0dba41d667fa5c64e56e252ba54be093e5ae764af6470dabca901f373eb",
strip_prefix = "rules_jsonnet-0.5.0",
urls = ["https://github.com/bazelbuild/rules_jsonnet/archive/0.5.0.tar.gz"],
)

llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm", dev_dependency = True)
llvm.toolchain(
llvm_version = "14.0.0",
)
use_repo(llvm, "llvm_toolchain_llvm")

npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm")
npm.npm_translate_lock(
name = "com_github_buildbarn_bb_browser_npm",
link_workspace = "com_github_buildbarn_bb_browser",
pnpm_lock = "//:pnpm-lock.yaml",
)
use_repo(npm, "com_github_buildbarn_bb_browser_npm")
Loading

0 comments on commit 8daa911

Please sign in to comment.