Skip to content

Commit

Permalink
Add grpcstar_binary rule (#23)
Browse files Browse the repository at this point in the history
* Add process module to readme
* Add grpcstar_binary macro/rule
* Update to bazel 6.2.1, rules go v0.39.1
* Use makefile variable for bazel
* Avoid nil pointer dereference if certs not given
* Add stage to perform bazel runs
* Remove tls example for now (re-introduce in separate commit)
  • Loading branch information
pcj committed Jun 14, 2023
1 parent 8d58c7b commit 935786e
Show file tree
Hide file tree
Showing 15 changed files with 225 additions and 331 deletions.
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.1.1
6.2.1
11 changes: 11 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,14 @@ jobs:
--bazelrc=.bazelrc
test
...
- name: bazel run
env:
# Bazelisk will download bazel to here, ensure it is cached between runs.
XDG_CACHE_HOME: ~/.cache/bazel-repo
run: >-
bazel
--bazelrc=.github/workflows/ci.bazelrc
--bazelrc=.bazelrc
run
//example/routeguide:server
19 changes: 10 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
BAZEL=bzl

.PHONY: build
build:
bazel build ...
$(BAZEL) build ...

.PHONY: test
test:
bazel test ... --runs_per_test=30
$(BAZEL) test ... --runs_per_test=30

.PHONY: tidy
tidy:
go mod tidy
bazel run update_go_repositories
bazel run gazelle
$(BAZEL) run update_go_repositories
$(BAZEL) run gazelle

golden:
bazel run //cmd/grpcstar:grpcstar_test \
$(BAZEL) run //cmd/grpcstar:grpcstar_test \
--action_env=NOGODEBUG=http2debug=2 \
-- \
--update

.PHONY: serve
serve: build
GODEBUG=http2debug=2 \
bazel-bin/cmd/grpcstar/grpcstar_/grpcstar \
-p bazel-bin/example/routeguide/routeguide_proto_descriptor.pb \
-f cmd/grpcstar/testdata/routeguide.grpc.star

.PHONY: routeguide_proto_descriptor
routeguide_proto_descriptor:
bazel build //example/routeguide:routeguide_proto_descriptor
$(BAZEL) build //example/routeguide:routeguide_proto_descriptor
cp -f bazel-bin/example/routeguide/routeguide_proto_descriptor.pb pkg/starlarkgrpc/
cp -f bazel-bin/example/routeguide/routeguide_proto_descriptor.pb pkg/protodescriptorset/

.PHONY: plugin_proto_descriptor
plugin_proto_descriptor:
bazel build @protoapis//google/protobuf/compiler:plugin_descriptor
$(BAZEL) build @protoapis//google/protobuf/compiler:plugin_descriptor
cp -f bazel-bin/external/protoapis/google/protobuf/compiler/plugin_descriptor.pb cmd/protoc-gen-starlark

1 change: 0 additions & 1 deletion cmd/grpcstar/grpcstar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ func TestGoldens(t *testing.T) {
os.Stderr = stdout
os.Stderr = stderr
}()

if err := run(".", []string{
"-protoset=../../example/routeguide/routeguide_proto_descriptor.pb",
"-file=" + filepath.Join("testdata", pair.file),
Expand Down
298 changes: 0 additions & 298 deletions cmd/grpcstar/testdata/tls.grpc.star

This file was deleted.

6 changes: 0 additions & 6 deletions cmd/grpcstar/testdata/tls.grpc.star.err

This file was deleted.

Empty file.
8 changes: 8 additions & 0 deletions example/routeguide/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@rules_proto//proto:defs.bzl", "proto_descriptor_set", "proto_library")
load("@build_stack_grpc_starlark//rules:grpcstar_binary.bzl", "grpcstar_binary")

proto_library(
name = "routeguide_proto",
Expand All @@ -11,3 +12,10 @@ proto_descriptor_set(
visibility = ["//visibility:public"],
deps = ["routeguide_proto"],
)

grpcstar_binary(
name = "server",
descriptor = ":routeguide_proto_descriptor",
importpath = "github.com/stackb/grpc-starlark/example/routeguide/server",
main = "routeguide.main.star",
)
Loading

0 comments on commit 935786e

Please sign in to comment.