Skip to content

Commit

Permalink
fix(bazel): fix bazel build and add presubmit (#1479)
Browse files Browse the repository at this point in the history
* chore(ci): add bazel build for proto_library

* add missing checkout

* add .bazeliskrc

* fix rules_proto in WORKSPACE

* fix bazel build

* add new line to .bazeliskrc

* add new line to workflow yaml

* update deps

* add rc explanation comment
  • Loading branch information
noahdietz authored Mar 22, 2024
1 parent 4847b10 commit e446229
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .bazeliskrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# See https://github.com/bazelbuild/bazelisk
# Should match https://github.com/googleapis/googleapis/blob/master/.bazeliskrc
USE_BAZEL_VERSION=6.3.0
4 changes: 4 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ build --protocopt=--include_source_info

# Required because showcase protos include proto3_optional fields
build --protocopt=--experimental_allow_proto3_optional

# New boringssl requires C++14
# Copied from googleapis.
build --repo_env=BAZEL_CXXOPTS="-std=c++14"
18 changes: 13 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,6 @@ jobs:
run: go test ./...
- name: Run server coverage
run: go test ./server/... -coverprofile=coverage.txt -covermode=atomic
# Disabled indefinitely.
# - uses: codecov/codecov-action@v1
# with:
# files: ./coverage.txt
# flags: unittests
probes:
needs: regenerate
runs-on: ubuntu-latest
Expand Down Expand Up @@ -217,3 +212,16 @@ jobs:
repo: context.repo.repo,
labels: ['automerge']
})
bazel_build_protos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bazel-contrib/[email protected]
with:
# Avoid downloading Bazel every time.
bazelisk-cache: true
# Store build cache per workflow.
disk-cache: ${{ github.workflow }}
# Share repository cache between workflows.
repository-cache: true
- run: bazelisk build //schema/google/showcase/v1beta1:showcase_proto
26 changes: 18 additions & 8 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,28 @@ http_archive(
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
protobuf_deps()

http_archive(
name = "bazel_features",
sha256 = "06f02b97b6badb3227df2141a4b4622272cdcd2951526f40a888ab5f43897f14",
strip_prefix = "bazel_features-1.9.0",
url = "https://github.com/bazel-contrib/bazel_features/releases/download/v1.9.0/bazel_features-v1.9.0.tar.gz",
)
load("@bazel_features//:deps.bzl", "bazel_features_deps")
bazel_features_deps()

##
# rules_proto for the proto_library rule
#
http_archive(
name = "rules_proto",
sha256 = "6a0b76595cb8bb97cec085c6b45c24337d30615d636f4941225c05f017690b6f",
strip_prefix = "rules_proto-25c8af9d56980df7732b2f8639c5d43ef878a6f7",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/25c8af9d56980df7732b2f8639c5d43ef878a6f7.tar.gz",
"https://github.com/bazelbuild/rules_proto/archive/25c8af9d56980df7732b2f8639c5d43ef878a6f7.tar.gz",
],
name = "rules_proto",
sha256 = "71fdbed00a0709521ad212058c60d13997b922a5d01dbfd997f0d57d689e7b67",
# Using a release candidate because the latest stable release is too old for
# our needs, and we want to stay closer to the latest without pinning to a
# specific commit.
strip_prefix = "rules_proto-6.0.0-rc2",
url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.0-rc2/rules_proto-6.0.0-rc2.tar.gz",
)
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")

load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies","rules_proto_toolchains")
rules_proto_dependencies()
rules_proto_toolchains()
1 change: 1 addition & 0 deletions schema/google/showcase/v1beta1/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ proto_library(
"@com_google_googleapis//google/longrunning:operations_proto",
"@com_google_googleapis//google/rpc:status_proto",
"@com_google_googleapis//google/rpc:error_details_proto",
"@com_google_protobuf//:any_proto",
"@com_google_protobuf//:duration_proto",
"@com_google_protobuf//:empty_proto",
"@com_google_protobuf//:field_mask_proto",
Expand Down

0 comments on commit e446229

Please sign in to comment.