Skip to content

Commit 935786e

Browse files
authored
Add grpcstar_binary rule (#23)
* 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)
1 parent 8d58c7b commit 935786e

File tree

15 files changed

+225
-331
lines changed

15 files changed

+225
-331
lines changed

.bazelversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.1.1
1+
6.2.1

.github/workflows/ci.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,14 @@ jobs:
4646
--bazelrc=.bazelrc
4747
test
4848
...
49+
50+
- name: bazel run
51+
env:
52+
# Bazelisk will download bazel to here, ensure it is cached between runs.
53+
XDG_CACHE_HOME: ~/.cache/bazel-repo
54+
run: >-
55+
bazel
56+
--bazelrc=.github/workflows/ci.bazelrc
57+
--bazelrc=.bazelrc
58+
run
59+
//example/routeguide:server

Makefile

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,38 @@
1+
BAZEL=bzl
2+
13
.PHONY: build
24
build:
3-
bazel build ...
5+
$(BAZEL) build ...
46

57
.PHONY: test
68
test:
7-
bazel test ... --runs_per_test=30
9+
$(BAZEL) test ... --runs_per_test=30
810

911
.PHONY: tidy
1012
tidy:
1113
go mod tidy
12-
bazel run update_go_repositories
13-
bazel run gazelle
14+
$(BAZEL) run update_go_repositories
15+
$(BAZEL) run gazelle
1416

1517
golden:
16-
bazel run //cmd/grpcstar:grpcstar_test \
18+
$(BAZEL) run //cmd/grpcstar:grpcstar_test \
19+
--action_env=NOGODEBUG=http2debug=2 \
1720
-- \
1821
--update
1922

2023
.PHONY: serve
2124
serve: build
22-
GODEBUG=http2debug=2 \
2325
bazel-bin/cmd/grpcstar/grpcstar_/grpcstar \
2426
-p bazel-bin/example/routeguide/routeguide_proto_descriptor.pb \
2527
-f cmd/grpcstar/testdata/routeguide.grpc.star
2628

2729
.PHONY: routeguide_proto_descriptor
2830
routeguide_proto_descriptor:
29-
bazel build //example/routeguide:routeguide_proto_descriptor
31+
$(BAZEL) build //example/routeguide:routeguide_proto_descriptor
3032
cp -f bazel-bin/example/routeguide/routeguide_proto_descriptor.pb pkg/starlarkgrpc/
3133
cp -f bazel-bin/example/routeguide/routeguide_proto_descriptor.pb pkg/protodescriptorset/
3234

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

cmd/grpcstar/grpcstar_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ func TestGoldens(t *testing.T) {
7575
os.Stderr = stdout
7676
os.Stderr = stderr
7777
}()
78-
7978
if err := run(".", []string{
8079
"-protoset=../../example/routeguide/routeguide_proto_descriptor.pb",
8180
"-file=" + filepath.Join("testdata", pair.file),

cmd/grpcstar/testdata/tls.grpc.star

Lines changed: 0 additions & 298 deletions
This file was deleted.

cmd/grpcstar/testdata/tls.grpc.star.err

Lines changed: 0 additions & 6 deletions
This file was deleted.

cmd/grpcstar/testdata/tls.grpc.star.out

Whitespace-only changes.

example/routeguide/BUILD.bazel

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
load("@rules_proto//proto:defs.bzl", "proto_descriptor_set", "proto_library")
2+
load("@build_stack_grpc_starlark//rules:grpcstar_binary.bzl", "grpcstar_binary")
23

34
proto_library(
45
name = "routeguide_proto",
@@ -11,3 +12,10 @@ proto_descriptor_set(
1112
visibility = ["//visibility:public"],
1213
deps = ["routeguide_proto"],
1314
)
15+
16+
grpcstar_binary(
17+
name = "server",
18+
descriptor = ":routeguide_proto_descriptor",
19+
importpath = "github.com/stackb/grpc-starlark/example/routeguide/server",
20+
main = "routeguide.main.star",
21+
)

0 commit comments

Comments
 (0)