Skip to content

Commit

Permalink
build: refactor protobuf generation and usage in project (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
blackhorseya authored Jul 26, 2024
2 parents cafec96 + 4994713 commit cf4a6b8
Show file tree
Hide file tree
Showing 15 changed files with 2,002 additions and 27 deletions.
18 changes: 0 additions & 18 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,8 @@ jobs:
go-version: '^1.20'
cache: true

- uses: bazelbuild/setup-bazelisk@v2

- name: Mount bazel cache
id: cache-bazel
uses: actions/cache@v3
with:
path: "/home/runner/.cache/bazel"
key: bazel

- name: Build
run: make build

- name: Test
run: make test

- name: coverage
run: make coverage

- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -498,3 +498,4 @@ $RECYCLE.BIN/
bin

deployments
result.json
24 changes: 19 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,30 @@ gazelle: ## run gazelle with bazel

.PHONY: build
build: ## build go binary
@bazel build //...
@go build ./...

.PHONY: test
test: ## test go binary
@bazel test --verbose_failures //...

.PHONY: coverage
coverage: ## generate coverage report
@go test -json -coverprofile=cover.out ./... >result.json

.PHONY: gen-pb
gen-pb: ## generate protobuf
@echo Starting generate pb
@find ./pb -name '*.proto' | while read -r proto_file; do \
protoc --proto_path=./pb \
--go_out=paths=source_relative:./ \
--go-grpc_out=paths=source_relative,require_unimplemented_servers=false:./ \
--go-grpc-mock_out=paths=source_relative,require_unimplemented_servers=false:./ \
$$proto_file; \
done
@echo Successfully generated proto

@echo Starting inject tags
@find ./pb -name '*.pb.go' | while read -r pb_file; do \
protoc-go-inject-tag -input=$$pb_file; \
done
@echo Successfully injected tags

.PHONY: gen-swagger
gen-swagger: ## generate swagger
@#swag init -q -g impl.go -d ./adapter/restaurant/restful,./entity,./pkg \
Expand Down
Loading

0 comments on commit cf4a6b8

Please sign in to comment.