Skip to content

Commit

Permalink
Update WORKSPACE versions to match MODULE (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
srikrsna-buf authored Nov 20, 2023
1 parent 906e911 commit ade38fc
Show file tree
Hide file tree
Showing 15 changed files with 126 additions and 149 deletions.
4 changes: 2 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

"Bazel module definition for bzlmod"

module(
name = "rules_buf",
version = "0.0.0", # Replaced when publishing
Expand All @@ -25,7 +26,6 @@ bazel_dep(name = "platforms", version = "0.0.4")
# TODO: remove in the future
bazel_dep(name = "protobuf", version = "21.7", repo_name = "com_google_protobuf")
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")

bazel_dep(name = "rules_go", version = "0.42.0", repo_name = "io_bazel_rules_go")
bazel_dep(name = "bazel_skylib", version = "1.5.0")

Expand All @@ -34,7 +34,6 @@ bazel_dep(name = "gazelle", version = "0.34.0", repo_name = "bazel_gazelle")

go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")

use_repo(
go_deps,
"com_github_bazelbuild_buildtools",
Expand All @@ -48,4 +47,5 @@ use_repo(non_module_deps, "bazel_gazelle_go_repository_tools")

ext = use_extension("//buf:extensions.bzl", "buf")
use_repo(ext, "rules_buf_toolchains")

register_toolchains("@rules_buf_toolchains//:all")
25 changes: 14 additions & 11 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ load("//buf:repositories.bzl", "rules_buf_dependencies", "rules_buf_toolchains")

rules_buf_dependencies()

rules_buf_toolchains(version = "v1.0.0-rc12")
rules_buf_toolchains(
sha256 = "05dfb45d2330559d258e1230f5a25e154f0a328afda2a434348b5ba4c124ece7",
version = "v1.28.1",
)

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

Expand Down Expand Up @@ -52,19 +55,19 @@ stardoc_repositories()

http_archive(
name = "io_bazel_rules_go",
sha256 = "685052b498b6ddfe562ca7a97736741d87916fe536623afb7da2824c0211c369",
sha256 = "91585017debb61982f7054c9688857a2ad1fd823fc3f9cb05048b0025c47d023",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.33.0/rules_go-v0.33.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.33.0/rules_go-v0.33.0.zip",
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.42.0/rules_go-v0.42.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.42.0/rules_go-v0.42.0.zip",
],
)

http_archive(
name = "bazel_gazelle",
sha256 = "5982e5463f171da99e3bdaeff8c0f48283a7a5f396ec5282910b9e8a49c0dd7e",
sha256 = "b7387f72efb59f876e4daae42f1d3912d0d45563eac7cb23d1de0b094ab588cf",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.25.0/bazel-gazelle-v0.25.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.25.0/bazel-gazelle-v0.25.0.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.34.0/bazel-gazelle-v0.34.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.34.0/bazel-gazelle-v0.34.0.tar.gz",
],
)

Expand All @@ -77,15 +80,15 @@ go_repositories()

go_rules_dependencies()

go_register_toolchains(version = "1.18.3")
go_register_toolchains(version = "1.21.1")

gazelle_dependencies()

http_archive(
name = "com_github_bazelbuild_buildtools",
sha256 = "ae34c344514e08c23e90da0e2d6cb700fcd28e80c02e23e4d5715dddcb42f7b3",
strip_prefix = "buildtools-4.2.2",
sha256 = "05c3c3602d25aeda1e9dbc91d3b66e624c1f9fdadf273e5480b489e744ca7269",
strip_prefix = "buildtools-6.4.0",
urls = [
"https://github.com/bazelbuild/buildtools/archive/refs/tags/4.2.2.tar.gz",
"https://github.com/bazelbuild/buildtools/archive/refs/tags/v6.4.0.tar.gz",
],
)
3 changes: 1 addition & 2 deletions buf/extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ See https://bazel.build/docs/bzlmod#extension-definition
load("//buf/internal:toolchain.bzl", "buf_download_releases")
load("//buf/internal:repo.bzl", "buf_dependencies")

# NB: this should be updated periodically
_DEFAULT_VERSION = "v1.27.0"
_DEFAULT_VERSION = "v1.28.1"
_DEFAULT_TOOLCHAIN_NAME = "rules_buf_toolchains"
_DEFAULT_DEPS = "buf_deps"

Expand Down
12 changes: 6 additions & 6 deletions buf/internal/dependencies.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

bazel_dependencies = {
"bazel_skylib": {
"sha256": "f7be3474d42aae265405a592bb7da8e171919d74c16f082a5457840f06054728",
"sha256": "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94",
"urls": [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.2.1/bazel-skylib-1.2.1.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.2.1/bazel-skylib-1.2.1.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz",
],
},
"rules_proto": {
"sha256": "e017528fd1c91c5a33f15493e3a398181a9e821a804eb7ff5acdd1d2d6c2b18d",
"strip_prefix": "rules_proto-4.0.0-3.20.0",
"sha256": "dc3fb206a2cb3441b485eb1e423165b231235a1ea9b031b4433cf7bc1fa460dd",
"strip_prefix": "rules_proto-5.3.0-21.7",
"urls": [
"https://github.com/bazelbuild/rules_proto/archive/refs/tags/4.0.0-3.20.0.tar.gz",
"https://github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.7.tar.gz",
],
},
}
Expand Down
6 changes: 5 additions & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Examples on how to use `rules_buf` in various scenarios. For more info refer to

## Scenarios

### [bzlmod](bzlmod)

This demonstrates using this repo with [bzlmod](https://docs.bazel.build/versions/5.0.0/bzlmod.html).

### [Version](version)

This demonstrates basic setup and pinning a `buf` cli version. This also demonstrates using the `buf` cli as a bazel toolchain.
Expand All @@ -18,4 +22,4 @@ This demonstrates setting up lint and breaking tests in a project with a `buf.ya

### [Workspaces](workspace)

This demonstrates setting up lint and breaking tests in a [buf workspace](https://docs.buf.build/reference/workspaces) project.
This demonstrates setting up lint and breaking tests in a [buf workspace](https://docs.buf.build/reference/workspaces) project.
5 changes: 3 additions & 2 deletions examples/bzlmod/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
# limitations under the License.

"Bazel dependencies"
bazel_dep(name = "rules_buf", dev_dependency = True, version = "0.0.0")
bazel_dep(name = "gazelle", dev_dependency = True, version = "0.34.0")

bazel_dep(name = "rules_buf", version = "0.0.0", dev_dependency = True)
bazel_dep(name = "gazelle", version = "0.34.0", dev_dependency = True)

local_path_override(
module_name = "rules_buf",
Expand Down
2 changes: 1 addition & 1 deletion examples/gazelle/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ gazelle(
)

gazelle(
name = "gazelle-update-repos",
name = "gazelle_update_repos",
args = [
# This can also be `buf.yaml` and `buf.lock`
"--from_file=buf.work.yaml",
Expand Down
30 changes: 12 additions & 18 deletions examples/gazelle/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ load("@rules_buf//buf:repositories.bzl", "rules_buf_dependencies", "rules_buf_to

rules_buf_dependencies()

rules_buf_toolchains(version = "v1.5.0")
rules_buf_toolchains(
sha256 = "05dfb45d2330559d258e1230f5a25e154f0a328afda2a434348b5ba4c124ece7",
version = "v1.28.1",
)

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

Expand All @@ -21,37 +24,28 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "io_bazel_rules_go",
sha256 = "685052b498b6ddfe562ca7a97736741d87916fe536623afb7da2824c0211c369",
sha256 = "91585017debb61982f7054c9688857a2ad1fd823fc3f9cb05048b0025c47d023",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.33.0/rules_go-v0.33.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.33.0/rules_go-v0.33.0.zip",
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.42.0/rules_go-v0.42.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.42.0/rules_go-v0.42.0.zip",
],
)

http_archive(
name = "bazel_gazelle",
sha256 = "5982e5463f171da99e3bdaeff8c0f48283a7a5f396ec5282910b9e8a49c0dd7e",
sha256 = "b7387f72efb59f876e4daae42f1d3912d0d45563eac7cb23d1de0b094ab588cf",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.25.0/bazel-gazelle-v0.25.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.25.0/bazel-gazelle-v0.25.0.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.34.0/bazel-gazelle-v0.34.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.34.0/bazel-gazelle-v0.34.0.tar.gz",
],
)

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

# Tempory fix for gazelle 0.25.0: https://github.com/bazelbuild/bazel-gazelle/issues/1217#issuecomment-1121223764
go_repository(
name = "org_golang_x_mod",
build_external = "external",
importpath = "golang.org/x/mod",
sum = "h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o=",
version = "v0.6.0-dev.0.20220106191415-9b9b3d81d5e3",
)
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")

go_rules_dependencies()

go_register_toolchains(version = "1.18.3")
go_register_toolchains(version = "1.21.1")

gazelle_dependencies()

Expand Down
5 changes: 4 additions & 1 deletion examples/single_module/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ load("@rules_buf//buf:repositories.bzl", "rules_buf_dependencies", "rules_buf_to

rules_buf_dependencies()

rules_buf_toolchains(version = "v1.5.0")
rules_buf_toolchains(
sha256 = "05dfb45d2330559d258e1230f5a25e154f0a328afda2a434348b5ba4c124ece7",
version = "v1.28.1",
)

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

Expand Down
2 changes: 1 addition & 1 deletion examples/single_module/bar/v1/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ proto_library(
buf_lint_test(
name = "bar_proto_lint",
config = "//:buf.yaml",
targets = [":bar_proto"],
error_format = "config-ignore-yaml",
targets = [":bar_proto"],
)
5 changes: 4 additions & 1 deletion examples/version/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ load("@rules_buf//buf:repositories.bzl", "rules_buf_dependencies", "rules_buf_to
rules_buf_dependencies()

# Set the desired buf version
rules_buf_toolchains(version = "v1.5.0")
rules_buf_toolchains(
sha256 = "05dfb45d2330559d258e1230f5a25e154f0a328afda2a434348b5ba4c124ece7",
version = "v1.28.1",
)

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

Expand Down
5 changes: 4 additions & 1 deletion examples/workspace/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ load("@rules_buf//buf:repositories.bzl", "rules_buf_dependencies", "rules_buf_to

rules_buf_dependencies()

rules_buf_toolchains(version = "v1.5.0")
rules_buf_toolchains(
sha256 = "05dfb45d2330559d258e1230f5a25e154f0a328afda2a434348b5ba4c124ece7",
version = "v1.28.1",
)

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

Expand Down
19 changes: 11 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
module github.com/bufbuild/rules_buf

go 1.17
go 1.21

toolchain go1.21.1

require (
github.com/bazelbuild/bazel-gazelle v0.25.0
github.com/bazelbuild/buildtools v0.0.0-20220531122519-a43aed7014c8
github.com/bazelbuild/rules_go v0.33.0
github.com/stretchr/testify v1.7.2
github.com/bazelbuild/bazel-gazelle v0.34.0
github.com/bazelbuild/buildtools v0.0.0-20231115204819-d4c9dccdfbb1
github.com/bazelbuild/rules_go v0.42.0
github.com/stretchr/testify v1.8.4
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/google/go-cmp v0.5.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d // indirect
golang.org/x/tools v0.1.11 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/tools/go/vcs v0.1.0-deprecated // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
)
Loading

0 comments on commit ade38fc

Please sign in to comment.