Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Cloud API #157

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "proto/api"]
path = proto/api
url = https://github.com/temporalio/api
[submodule "proto/api-cloud"]
path = proto/api-cloud
url = https://github.com/temporalio/api-cloud
17 changes: 7 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ COLOR := "\e[1;36m%s\e[0m\n"
PINNED_DEPENDENCIES := \

PROTO_ROOT := proto/api
PROTO_FILES = $(shell find $(PROTO_ROOT)/temporal -name "*.proto")
PROTO_DIRS = $(sort $(dir $(PROTO_FILES)))
PROTO_ENUMS := $(shell grep -R '^enum ' $(PROTO_ROOT) | cut -d ' ' -f2)
PROTO_CLOUD_ROOT := proto/api-cloud
PROTO_OUT := .
PROTO_IMPORTS = \
-I=$(PROTO_ROOT)
Expand Down Expand Up @@ -57,10 +55,10 @@ go-grpc: clean .go-helpers-installed $(PROTO_OUT)
printf $(COLOR) "Compile for go-gRPC..."
go run ./cmd/protogen \
--root=$(PROTO_ROOT) \
--root=$(PROTO_CLOUD_ROOT) \
--output=$(PROTO_OUT) \
--exclude=internal \
--exclude=proto/api/google \
-I $(PROTO_ROOT) \
-p go-grpc_out=$(PROTO_PATHS) \
-p grpc-gateway_out=allow_patch_feature=false,$(PROTO_PATHS) \
-p go-helpers_out=$(PROTO_PATHS)
Expand All @@ -80,14 +78,11 @@ copy-helpers:
cp $(PROTO_OUT)/internal/temporalcommonv1/payload_json.go $(PROTO_OUT)/common/v1/
chmod -w $(PROTO_OUT)/common/v1/payload_json.go

# All generated service files pathes relative to PROTO_OUT.
PROTO_GRPC_SERVICES = $(patsubst $(PROTO_OUT)/%,%,$(shell find $(PROTO_OUT) -name "service_grpc.pb.go"))
service_name = $(firstword $(subst /, ,$(1)))
mock_file_name = $(call service_name,$(1))mock/$(subst $(call service_name,$(1))/,,$(1:go=mock.go))

grpc-mock:
printf $(COLOR) "Generate gRPC mocks..."
$(foreach PROTO_GRPC_SERVICE,$(PROTO_GRPC_SERVICES),cd $(PROTO_OUT) && mockgen -package $(call service_name,$(PROTO_GRPC_SERVICE))mock -source $(PROTO_GRPC_SERVICE) -destination $(call mock_file_name,$(PROTO_GRPC_SERVICE))$(NEWLINE) )
mockgen -package operatorservicemock -source operatorservice/v1/service_grpc.pb.go -destination operatorservicemock/v1/service_grpc.pb.mock.go
mockgen -package workflowservicemock -source workflowservice/v1/service_grpc.pb.go -destination workflowservicemock/v1/service_grpc.pb.mock.go
mockgen -package cloudservicemock -source cloud/cloudservice/v1/service_grpc.pb.go -destination cloud/cloudservicemock/v1/service_grpc.pb.mock.go
Comment on lines +83 to +85
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😢

Copy link
Member Author

@cretz cretz Apr 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

? (it was silly to have all these lines of complexity for two lines of mockgen call)


.PHONY: proxy
proxy:
Expand Down Expand Up @@ -146,3 +141,5 @@ clean:
printf $(COLOR) "Deleting generated go files..."
# Delete all directories with *.pb.go and *.mock.go files from $(PROTO_OUT)
find $(PROTO_OUT) \( -name "*.pb.go" -o -name "*.mock.go" -o -name "*.go-helpers.go" \) | xargs -I{} dirname {} | egrep -v 'testprotos' | sort -u | xargs rm -rf
# Delete entire cloud dir
rm -rf cloud
Comment on lines +144 to +145
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't the line above delete this dir?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This came from my last tests with #155 where I believe it only worked one directory deep, but I can test again.

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ _Note that any changes merged to [api](https://github.com/temporalio/api) will a

To install in your project run:
```
go get -u go.temporal.io/api
go get go.temporal.io/api
```

## Rebuild

Run `make` once to install all plugins and tools (`protoc` and `go` must be installed manually).

Run `make update-proto` to update submodule and recompile proto files.
Run `make update-proto` to update the `proto/api` submodule and recompile proto files. The `proto/api-cloud` submodule
must be updated manually.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"manually" because you didn't create a make target for it or is there another reason?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I didn't want this to be with that other make target because that is run automatically via GH workflow, and we don't want to pull in this repo automatically because it may break in here (there are not checks in that repo that match this repo like the api repo has). So updating this submodule is manual, as opposed to a make target auto-run by GH workflow.


## License

Expand Down
Loading
Loading