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

Remove proto/api submodule #5868

Merged
merged 11 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

# Buf proto image
/proto/image.bin
# api+google proto dependencies
/proto/api.binpb

# Goreleaser
/dist
Expand Down
4 changes: 0 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
[submodule "proto/api"]
path = proto/api
url = https://github.com/temporalio/api
branch = master
[submodule "develop/docker-compose/grafana/provisioning/temporalio-dashboards"]
path = develop/docker-compose/grafana/provisioning/temporalio-dashboards
url = https://github.com/temporalio/dashboards
17 changes: 5 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ make stop-dependencies
```

## Working with merged API changes
gRPC / protobuf changes merged to the [api](https://github.com/temporalio/api) repo automatically trigger a commit in [api-go](https://github.com/temporalio/api-go). To bring such changes into your feature branch, use `make update-go-api update-proto`.
gRPC / protobuf changes merged to the [api](https://github.com/temporalio/api) repo automatically trigger a commit in [api-go](https://github.com/temporalio/api-go).
To bring such changes into your feature branch, use `make update-go-api`.

## Working with local API changes
If you need to make changes to the gRPC / protobuf definitions while also working on code in this repo, do the following:
Expand All @@ -142,7 +143,7 @@ If you need to make changes to the gRPC / protobuf definitions while also workin
git submodule update --remote proto/api
```
3. Compile protos: `make proto`
4. In your copy of `sdk-go`:
4. (Optional, if SDK changes are required:) In your copy of `sdk-go`:
1. Point `go.mod` at local `api-go`:
```
replace (
Expand All @@ -151,22 +152,14 @@ If you need to make changes to the gRPC / protobuf definitions while also workin
```
2. Compile & fix errors: `make bins`
5. In this repo:
1. Initialize submodules: `git submodule update --init --recursive`
2. Point api submodule at your branch. If you make more commits to the api repo, run the last command again.
```bash
git submodule set-url proto/api ../api
git submodule set-branch --branch mystuff proto/api
git submodule update --remote proto/api
```
3. Stage the change: `git add -u` (otherwise makefile will blow it away)
4. Point `go.mod` at local `api-go` and `sdk-go`:
1. Point `go.mod` at local `api-go` and `sdk-go`:
```
replace (
go.temporal.io/api => ../api-go
go.temporal.io/sdk => ../sdk-go
)
```
5. Build & fix errors: `make proto && make bins`
2. Build & fix errors: `make proto && make bins`

## Licence headers
This project is Open Source Software, and requires a header at the beginning of
Expand Down
45 changes: 18 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ clean: clean-bins clean-test-results

# Recompile proto files.
proto: clean-proto lint-protos lint-api protoc service-clients goimports-proto proto-mocks copyright-proto

# Update proto submodule from remote and recompile proto files.
update-proto: update-proto-submodule proto gomodtidy
########################################################################

.PHONY: proto proto-mocks protoc install bins ci-build-misc clean
Expand Down Expand Up @@ -73,8 +70,7 @@ TEST_TIMEOUT := 30m
PROTO_ROOT := proto
PROTO_FILES = $(shell find ./$(PROTO_ROOT)/internal -name "*.proto")
PROTO_DIRS = $(sort $(dir $(PROTO_FILES)))
PROTO_IMPORTS = -I=$(PROTO_ROOT)/internal -I=$(PROTO_ROOT)/api -I=$(PROTO_ROOT)/dependencies
PROTO_OPTS = paths=source_relative:$(PROTO_OUT)
API_BINPB := proto/api.binpb
PROTO_OUT := api
PROTO_ENUMS := $(shell grep -R '^enum ' $(PROTO_ROOT) | cut -d ' ' -f2)
PROTO_PATHS = paths=source_relative:$(PROTO_OUT)
Expand Down Expand Up @@ -233,18 +229,12 @@ $(PROTO_OUT):
clean-proto: gomodtidy
@rm -rf $(PROTO_OUT)/*

update-proto-submodule:
@printf $(COLOR) "Update proto submodule from remote..."
git submodule update --force --remote $(PROTO_ROOT)/api

install-proto-submodule:
@printf $(COLOR) "Install proto submodule..."
git submodule update --init $(PROTO_ROOT)/api
$(API_BINPB): go.mod go.sum $(PROTO_FILES)
@./cmd/tools/getproto/run.sh --out $@

protoc: clean-proto $(PROTO_OUT) $(PROTOGEN) $(PROTOC_GEN_GO) $(PROTOC_GEN_GO_GRPC) $(PROTOC_GEN_GO_HELPERS)
protoc: clean-proto $(PROTO_OUT) $(PROTOGEN) $(PROTOC_GEN_GO) $(PROTOC_GEN_GO_GRPC) $(PROTOC_GEN_GO_HELPERS) $(API_BINPB)
@$(PROTOGEN) \
-I=proto/api \
-I=proto/dependencies \
--descriptor_set_in=$(API_BINPB) \
--root=proto/internal \
--rewrite-enum=BuildId_State:BuildId \
-p go-grpc_out=$(PROTO_PATHS) \
Expand Down Expand Up @@ -335,21 +325,22 @@ lint-code: $(GOLANGCI_LINT)
lint: lint-code lint-actions lint-api lint-protos
@printf $(COLOR) "Run linters..."

lint-api: $(API_LINTER)
lint-api: $(API_LINTER) $(API_BINPB)
@printf $(COLOR) "Linting proto API..."
$(call silent_exec, $(API_LINTER) --set-exit-status $(PROTO_IMPORTS) --config=$(PROTO_ROOT)/api-linter.yaml $(PROTO_FILES))
$(call silent_exec, $(API_LINTER) --set-exit-status -I=$(PROTO_ROOT)/internal --descriptor-set-in $(API_BINPB) --config=$(PROTO_ROOT)/api-linter.yaml $(PROTO_FILES))

lint-protos: $(BUF)
lint-protos: $(BUF) $(API_BINPB)
@printf $(COLOR) "Linting proto definitions..."
@(cd $(PROTO_ROOT) && $(ROOT)/$(BUF) lint)

buf-build: $(BUF)
@printf $(COLOR) "Build image.bin with buf..."
@(cd $(PROTO_ROOT) && $(ROOT)/$(BUF) build -o image.bin)

buf-breaking: $(BUF)
@printf $(COLOR) "Run buf breaking changes check against image.bin..."
@(cd $(PROTO_ROOT) && $(ROOT)/$(BUF) check breaking --against image.bin)
@protoc --descriptor_set_in=$(API_BINPB) -I=proto/internal $(PROTO_FILES) -o /dev/stdout | (cd proto/internal && $(ROOT)/$(BUF) lint -)

# TODO: fix this to work with getproto + API_BINPB
# buf-build: $(BUF)
# @printf $(COLOR) "Build image.bin with buf..."
# @(cd $(PROTO_ROOT) && $(ROOT)/$(BUF) build -o image.bin)
#
# buf-breaking: $(BUF)
# @printf $(COLOR) "Run buf breaking changes check against image.bin..."
# @(cd $(PROTO_ROOT) && $(ROOT)/$(BUF) breaking --against image.bin)
dnr marked this conversation as resolved.
Show resolved Hide resolved

shell-check:
@printf $(COLOR) "Run shellcheck for script files..."
Expand Down
Loading
Loading