Skip to content

Commit

Permalink
bazel: Cleanup workspace/dependencies (#4)
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Northey <[email protected]>
  • Loading branch information
phlax authored Aug 15, 2024
1 parent eb15e67 commit 5780108
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 103 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/aptly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- run: |
bazel run --config=ci @com_github_aptly_dev_aptly//:aptly publish list
bazel run --config=ci @aptly publish list
15 changes: 2 additions & 13 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ gazelle(name = "gazelle")

genrule(
name = "go.mod",
srcs = ["@com_github_aptly_dev_aptly//:go.mod"],
srcs = ["@aptly//:go.mod"],
outs = ["go.mod.txt"],
cmd = "cat $(location @com_github_aptly_dev_aptly//:go.mod) > $@",
cmd = "cat $(location @aptly//:go.mod) > $@",
)

gazelle(
Expand All @@ -21,14 +21,3 @@ gazelle(
command = "update-repos",
data = [":go.mod"],
)

go_library(
name = "aptly_lib",
srcs = ["@com_github_aptly_dev_aptly//:main.go"],
importpath = "github.com/aptly-dev/aptly",
visibility = ["//visibility:private"],
deps = [
"@com_github_aptly_dev_aptly//aptly",
"@com_github_aptly_dev_aptly//cmd",
],
)
52 changes: 10 additions & 42 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,51 +1,19 @@
workspace(name = "aptly")
workspace(name = "envoy_apt")

load("//:deps.bzl", "dependencies")
load("//:versions.bzl", "VERSIONS")
load(":archives.bzl", "archives")
archives(VERSIONS)

load("//:deps.bzl", "dependencies")
dependencies()

load("//:deps-go.bzl", "aptly_dependencies", "go_dependencies")

go_dependencies()


load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")

py_repositories()

python_register_toolchains(
name = "python_3_11",
# Available versions are listed in @rules_python//python:versions.bzl.
# We recommend using the same version your team is already standardized on.
python_version = "3.11",
)

load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies")

rules_proto_dependencies()

load("@rules_proto//proto:setup.bzl", "rules_proto_setup")
load("//:setup.bzl", "setup")
setup()

rules_proto_setup()

load("@rules_proto//proto:toolchains.bzl", "rules_proto_toolchains")

rules_proto_toolchains()

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()
load("//:toolchains.bzl", "toolchains")
toolchains()

load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")

go_rules_dependencies()

go_register_toolchains(version = "1.22.4")

gazelle_dependencies(go_repository_default_config = "//:WORKSPACE")

# gazelle:repo bazel_gazelle
# gazelle:repository_macro deps-go.bzl%go_dependencies
aptly_dependencies()
go_dependencies()
gazelle_dependencies(go_repository_default_config = "//:WORKSPACE")
24 changes: 24 additions & 0 deletions archives.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

def load_github_archives(versions):
for k, v in versions.items():
if type(v) == type("") or v.get("type") != "github_archive":
continue
kwargs = dict(name = k, **v)
http_archive(
**{
k: (
(v.format(**kwargs) if not k.startswith("patch") else v)
if type(v) == "string"
else [
_v.format(**kwargs) if not k.startswith("patch") else _v
for _v in v
]
)
for k, v in kwargs.items()
if k not in ["repo", "type", "version"]
}
)

def archives(versions):
load_github_archives(versions)
2 changes: 1 addition & 1 deletion deps-go.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ load("@bazel_gazelle//:deps.bzl", "go_repository")

def aptly_dependencies():
go_repository(
name = "com_github_aptly_dev_aptly",
name = "aptly",
importpath = "github.com/aptly-dev/aptly",
sha256 = "07e18ce606feb8c86a1f79f7f5dd724079ac27196faa61a2cefa5b599bbb5bb1",
strip_prefix = "aptly-1.5.0",
Expand Down
55 changes: 9 additions & 46 deletions deps.bzl
Original file line number Diff line number Diff line change
@@ -1,49 +1,12 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies")
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
load("//:deps-go.bzl", "aptly_dependencies", "go_dependencies")

def dependencies():
http_archive(
name = "io_bazel_rules_go",
integrity = "sha256-M6zErg9wUC20uJPJ/B3Xqb+ZjCPn/yxFF3QdQEmpdvg=",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.48.0/rules_go-v0.48.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.48.0/rules_go-v0.48.0.zip",
],
)
http_archive(
name = "bazel_gazelle",
sha256 = "d76bf7a60fd8b050444090dfa2837a4eaf9829e1165618ee35dceca5cbdf58d5",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.37.0/bazel-gazelle-v0.37.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.37.0/bazel-gazelle-v0.37.0.tar.gz",
],
)
http_archive(
name = "rules_proto",
sha256 = "6fb6767d1bef535310547e03247f7518b03487740c11b6c6adb7952033fe1295",
urls = ["https://github.com/bazelbuild/rules_proto/archive/refs/tags/6.0.2.tar.gz"],
strip_prefix = "rules_proto-6.0.2",
)
http_archive(
name = "rules_pkg",
sha256 = "23005750a27aabfd5975a3d5aeac9542371cbfa24d3ad74e47f80b84547754da",
urls = ["https://github.com/bazelbuild/rules_pkg/archive/refs/tags/1.0.1.tar.gz"],
strip_prefix = "rules_pkg-1.0.1",
)
http_archive(
name = "rules_python",
sha256 = "778aaeab3e6cfd56d681c89f5c10d7ad6bf8d2f1a72de9de55b23081b2d31618",
urls = ["https://github.com/bazelbuild/rules_python/archive/refs/tags/0.34.0.tar.gz"],
strip_prefix = "rules_python-0.34.0",
)
http_archive(
name = "com_google_absl",
sha256 = "987ce98f02eefbaf930d6e38ab16aa05737234d7afbab2d5c4ea7adbe50c28ed",
strip_prefix = "abseil-cpp-20230802.1",
urls = ["https://github.com/abseil/abseil-cpp/archive/20230802.1.tar.gz"],
)
http_archive(
name = "com_google_protobuf",
sha256 = "4fc5ff1b2c339fb86cd3a25f0b5311478ab081e65ad258c6789359cd84d421f8",
strip_prefix = "protobuf-26.1",
urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v26.1/protobuf-26.1.tar.gz"],
)
protobuf_deps()
rules_proto_dependencies()
aptly_dependencies()
go_dependencies()
go_rules_dependencies()
6 changes: 6 additions & 0 deletions setup.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
load("@rules_proto//proto:setup.bzl", "rules_proto_setup")
load("@rules_python//python:repositories.bzl", "py_repositories")

def setup():
py_repositories()
rules_proto_setup()
13 changes: 13 additions & 0 deletions toolchains.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains")
load("@rules_proto//proto:toolchains.bzl", "rules_proto_toolchains")
load("@rules_python//python:repositories.bzl", "python_register_toolchains")

def toolchains():
python_register_toolchains(
name = "python3_12",
# Available versions are listed in @rules_python//python:versions.bzl.
# We recommend using the same version your team is already standardized on.
python_version = "3.12",
)
rules_proto_toolchains()
go_register_toolchains(version = "1.22.4")
88 changes: 88 additions & 0 deletions versions.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@

VERSIONS = {
"python": "3.12",
"aspect_bazel_lib": {
"type": "github_archive",
"repo": "aspect-build/bazel-lib",
"version": "2.7.9",
"sha256": "ccb66940aff9dfded4b03b929c83803f386807ef5ea4960404dfa8a7715cb74f",
"urls": ["https://github.com/{repo}/archive/v{version}.tar.gz"],
"strip_prefix": "bazel-lib-{version}",
},
"bazel_gazelle": {
"type": "github_archive",
"repo": "bazelbuild/bazel-gazelle",
"version": "0.37.0",
"sha256": "d76bf7a60fd8b050444090dfa2837a4eaf9829e1165618ee35dceca5cbdf58d5",
"urls": [
"https://mirror.bazel.build/github.com/{repo}/releases/download/v{version}/bazel-gazelle-v{version}.tar.gz",
"https://github.com/{repo}/releases/download/v{version}/bazel-gazelle-v{version}.tar.gz",
],
},
"com_google_absl": {
"type": "github_archive",
"repo": "abseil/abseil-cpp",
"version": "20230802.1",
"sha256": "4fc5ff1b2c339fb86cd3a25f0b5311478ab081e65ad258c6789359cd84d421f8",
"urls": ["https://github.com/{repo}/archive/{version}.tar.gz"],
"strip_prefix": "abseil-cpp-{version}",
},
"com_google_protobuf": {
"type": "github_archive",
"repo": "protocolbuffers/protobuf",
"version": "26.1",
"sha256": "4fc5ff1b2c339fb86cd3a25f0b5311478ab081e65ad258c6789359cd84d421f8",
"urls": ["https://github.com/{repo}/releases/download/v{version}/protobuf-{version}.tar.gz"],
"strip_prefix": "protobuf-{version}",
},
"envoy": {
"type": "github_archive",
"repo": "envoyproxy/envoy",
"version": "fea66c359069991e88bdfa4e0f2883c90cc39aef",
"sha256": "96294f4b491c676b650ddeb07c7986ec7e48b5ae5a75c4adebbb9a58741a2fb1",
"urls": ["https://github.com/{repo}/archive/{version}.tar.gz"],
"strip_prefix": "envoy-{version}",
},
"envoy_toolshed": {
"type": "github_archive",
"repo": "envoyproxy/toolshed",
"version": "0.1.4",
"sha256": "7ddfd251a89518b97c4eb8064a7d37454bbd998bf29e4cd3ad8f44227b5ca7b3",
"urls": ["https://github.com/{repo}/archive/bazel-v{version}.tar.gz"],
"strip_prefix": "toolshed-bazel-v{version}/bazel",
},
"io_bazel_rules_go": {
"type": "github_archive",
"repo": "bazelbuild/rules_go",
"version": "0.48.0",
"sha256": "33acc4ae0f70502db4b893c9fc1dd7a9bf998c23e7ff2c4517741d4049a976f8",
"urls": [
"https://mirror.bazel.build/github.com/{repo}/releases/download/v{version}/rules_go-v{version}.zip",
"https://github.com/{repo}/releases/download/v{version}/rules_go-v{version}.zip",
],
},
"rules_pkg": {
"type": "github_archive",
"repo": "bazelbuild/rules_pkg",
"version": "1.0.1",
"sha256": "6fb6767d1bef535310547e03247f7518b03487740c11b6c6adb7952033fe1295",
"urls": ["https://github.com/{repo}/archive/refs/tags/{version}.tar.gz"],
"strip_prefix": "rules_pkg-{version}",
},
"rules_proto": {
"type": "github_archive",
"repo": "bazelbuild/rules_proto",
"version": "6.0.2",
"sha256": "6fb6767d1bef535310547e03247f7518b03487740c11b6c6adb7952033fe1295",
"urls": ["https://github.com/{repo}/archive/refs/tags/{version}.tar.gz"],
"strip_prefix": "rules_proto-{version}",
},
"rules_python": {
"type": "github_archive",
"repo": "bazelbuild/rules_python",
"version": "0.32.2",
"sha256": "4912ced70dc1a2a8e4b86cec233b192ca053e82bc72d877b98e126156e8f228d",
"urls": ["https://github.com/{repo}/archive/{version}.tar.gz"],
"strip_prefix": "rules_python-{version}",
},
}

0 comments on commit 5780108

Please sign in to comment.