Skip to content

Commit

Permalink
use buf.build to generate all compiled files (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
sword-jin authored Jul 22, 2024
1 parent e3b6bf1 commit b4a38b8
Show file tree
Hide file tree
Showing 21 changed files with 1,880 additions and 87 deletions.
9 changes: 0 additions & 9 deletions .github/workflows/release-castled.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,22 +117,13 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install packages (Ubuntu)
# Because openssl doesn't work on musl by default, we resort to max-pure. And that won't need any dependency, so we can skip this.continue-on-error
# Once we want to support better zlib performance, we might have to re-add it.
if: matrix.os == 'ubuntu-latest-disabled'
run: |
sudo apt-get update && sudo apt-get install -y --no-install-recommends xz-utils liblz4-tool musl-tools
- name: compile protobuf
run: |
protoc --descriptor_set_out=./proto/message.bin --proto_path=proto message.proto
- name: Install Rust
uses: dtolnay/rust-toolchain@master
Expand Down
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ version = "0.0.1-alpha.1"
edition = "2021"
authors = ["rrylee1994@gmail.com"]
license = "MIT"
build = "build.rs"
repository = "https://github.com/openosaka/castle"
readme = "README.md"
description = "Best tunnel for development and kubernetes"
Expand Down
24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ ifeq ($(ENABLE_TOKIO_CONSOLE), 1)
FEATURES += "debug"
endif

PWD := $(shell pwd)
PROTOC_GEN_GO = $(PWD)/bin/protoc-gen-go
BUF_VERSION = 1.34.0
BUF = $(PWD)/.bin/buf
RUN_BUF = PATH=$(PWD)/.bin:$$PATH $(BUF)
PROTOC_GEN_GO_VERSION := $(shell awk '/google.golang.org\/protobuf/ {print substr($$2, 2)}' go.mod)

EXAMPLES = \
crawler

Expand Down Expand Up @@ -57,6 +64,15 @@ check-version:
echo "Version in Cargo.toml matches expected version ($(NEW_CRATE_VERSION))"; \
fi

.PHONY: update-deps
update-deps: $(BUF)
$(RUN_BUF) mod update
go get -u ./...

.PHONY: generate-proto
generate-proto: $(BUF) $(PROTOC_GEN_GO)
$(RUN_BUF) generate

.PHONY: build-examples
build-examples:
DOCKER_BUILDKIT=1 docker build -t crawler:$(IMAGE_VERSION) -f go.Dockerfile .
Expand All @@ -76,3 +92,11 @@ run-examples:
.PHONY: clean
clean:
rm -rf target

$(BUF):
mkdir -p .bin
GOBIN=$(PWD)/.bin go install github.com/bufbuild/buf/cmd/buf@v$(BUF_VERSION)

$(PROTOC_GEN_GO):
mkdir -p .bin
GOBIN=$(PWD)/.bin go install google.golang.org/protobuf/cmd/protoc-gen-go@v$(PROTOC_GEN_GO_VERSION)
12 changes: 12 additions & 0 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: v2
plugins:
- local: protoc-gen-go
out: sdk/go/pb
opt:
- paths=source_relative
- remote: buf.build/community/neoeinstein-prost
out: src/gen
- remote: buf.build/community/neoeinstein-tonic:v0.4.0
out: src/gen
opt:
- compile_well_known_types
2 changes: 2 additions & 0 deletions buf.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Generated by buf. DO NOT EDIT.
version: v2
17 changes: 17 additions & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: v2
lint:
use:
- BASIC
except:
- ENUM_NO_ALLOW_ALIAS
- ENUM_PASCAL_CASE
- FIELD_NOT_REQUIRED
- PACKAGE_NO_IMPORT_CYCLE
disallow_comment_ignores: true
breaking:
use:
- FILE
except:
- EXTENSION_NO_DELETE
- FIELD_SAME_DEFAULT
ignore_unstable_packages: true
24 changes: 0 additions & 24 deletions build.rs

This file was deleted.

5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ module github.com/openosaka/castled

go 1.22.4

require github.com/spf13/pflag v1.0.5
require (
github.com/spf13/pflag v1.0.5
google.golang.org/protobuf v1.34.2
)
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
2 changes: 2 additions & 0 deletions proto/message.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ syntax = "proto3";

package message;

option go_package = "github.com/castled-dev/castled/proto/message";

service TunnelService {
// the client sends Register to the server to create a tunnel.
// the server returns a stream Control to the client, the following control messages are sent through the stream.
Expand Down
Loading

0 comments on commit b4a38b8

Please sign in to comment.