bazel: add buf as protobuf formatter to //:tidy (#1511)

Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
This commit is contained in:
Paul Meyer 2023-03-23 13:08:49 -04:00 committed by GitHub
parent 55067b12cd
commit e7fc541a57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 190 additions and 114 deletions

View File

@ -236,6 +236,27 @@ sh_template(
template = "golangci.sh.in",
)
alias(
name = "com_github_bufbuild_buf",
actual = select({
"@io_bazel_rules_go//go/platform:darwin_amd64": "@com_github_bufbuild_buf_darwin_amd64//:bin/buf",
"@io_bazel_rules_go//go/platform:darwin_arm64": "@com_github_bufbuild_buf_darwin_arm64//:bin/buf",
"@io_bazel_rules_go//go/platform:linux_amd64": "@com_github_bufbuild_buf_linux_amd64//:bin/buf",
"@io_bazel_rules_go//go/platform:linux_arm64": "@com_github_bufbuild_buf_linux_arm64//:bin/buf",
}),
)
sh_template(
name = "buf_fmt",
data = [
":com_github_bufbuild_buf",
],
substitutions = {
"@@BUF@@": "$(rootpath :com_github_bufbuild_buf)",
},
template = "buf.sh.in",
)
multirun(
name = "tidy",
commands = [
@ -246,6 +267,7 @@ multirun(
":gazelle_generate",
":buildifier_fix",
":terraform_fmt",
":buf_fmt",
],
jobs = 1, # execute sequentially
visibility = ["//visibility:public"],

25
bazel/ci/buf.sh.in Normal file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env bash
lib=$(realpath @@BASE_LIB@@) || exit 1
buf=$(realpath @@BUF@@) || exit 1
# shellcheck source=../sh/lib.bash
if ! source "${lib}"; then
echo "Error: could not find import"
exit 1
fi
cd "${BUILD_WORKSPACE_DIRECTORY}" || exit 1
readarray -t <<< "$(find "$(pwd)" -type f -name "*.proto")"
protos=("${MAPFILE[@]}")
statuscode=0
echo "Formatting the following protobuf files with buf:"
for proto in "${protos[@]}"; do
echo " ${proto}"
${buf} format -w "${proto}" || statuscode=$?
done
exit "${statuscode}"

View File

@ -10,6 +10,7 @@ def ci_deps():
_gofumpt_deps()
_tfsec_deps()
_golangci_lint_deps()
_buf_deps()
def _shellcheck_deps():
http_archive(
@ -213,3 +214,33 @@ def _golangci_lint_deps():
strip_prefix = "golangci-lint-1.51.2-darwin-arm64",
sha256 = "36e69882205a0e42a63ad57ec3015639c11051e03f0beb9cf7949c6451408960",
)
def _buf_deps():
http_archive(
name = "com_github_bufbuild_buf_linux_amd64",
sha256 = "39b58126938e265a7dd60fc4716a4a43931896e62db3d69c704d7dd63d5889dd",
url = "https://github.com/bufbuild/buf/releases/download/v1.15.1/buf-Linux-x86_64.tar.gz",
strip_prefix = "buf",
build_file_content = """exports_files(["bin/buf"], visibility = ["//visibility:public"])""",
)
http_archive(
name = "com_github_bufbuild_buf_linux_aarch64",
sha256 = "6c1e7258b79273c60085df8825a52a5ee306530e7327942c91ec84545cd2d40a",
url = "https://github.com/bufbuild/buf/releases/download/v1.15.1/buf-Linux-aarch64.tar.gz",
strip_prefix = "buf",
build_file_content = """exports_files(["bin/buf"], visibility = ["//visibility:public"])""",
)
http_archive(
name = "com_github_bufbuild_buf_darwin_amd64",
sha256 = "6c1e7258b79273c60085df8825a52a5ee306530e7327942c91ec84545cd2d40a",
url = "https://github.com/bufbuild/buf/releases/download/v1.15.1/buf-Darwin-x86_64.tar.gz",
strip_prefix = "buf",
build_file_content = """exports_files(["bin/buf"], visibility = ["//visibility:public"])""",
)
http_archive(
name = "com_github_bufbuild_buf_darwin_arm64",
sha256 = "6c1e7258b79273c60085df8825a52a5ee306530e7327942c91ec84545cd2d40a",
url = "https://github.com/bufbuild/buf/releases/download/v1.15.1/buf-Darwin-arm64.tar.gz",
strip_prefix = "buf",
build_file_content = """exports_files(["bin/buf"], visibility = ["//visibility:public"])""",
)

View File

@ -1,12 +1,12 @@
syntax = "proto3";
option go_package = "github.com/edgelesssys/constellation/v2/debugd/service";
package debugd;
option go_package = "github.com/edgelesssys/constellation/v2/debugd/service";
service Debugd {
rpc SetInfo (SetInfoRequest) returns (SetInfoResponse) {}
rpc GetInfo (GetInfoRequest) returns (GetInfoResponse) {}
rpc SetInfo(SetInfoRequest) returns (SetInfoResponse) {}
rpc GetInfo(GetInfoRequest) returns (GetInfoResponse) {}
rpc UploadFiles(stream FileTransferMessage) returns (UploadFilesResponse) {}
rpc DownloadFiles(DownloadFilesRequest) returns (stream FileTransferMessage) {}
rpc UploadSystemServiceUnits(UploadSystemdServiceUnitsRequest) returns (UploadSystemdServiceUnitsResponse) {}

View File

@ -11,7 +11,6 @@ service API {
rpc IssueRejoinTicket(IssueRejoinTicketRequest) returns (IssueRejoinTicketResponse);
}
message IssueJoinTicketRequest {
// disk_uuid is the UUID of a node's state disk.
string disk_uuid = 1;
@ -76,4 +75,4 @@ message KubernetesComponent {
string install_path = 3;
// extract indicates whether the component is an archive and needs to be extracted.
bool extract = 4;
}
}

View File

@ -14,5 +14,4 @@ message ExecuteUpdateRequest {
string wanted_kubernetes_version = 3;
}
message ExecuteUpdateResponse {
}
message ExecuteUpdateResponse {}