Skip to content

Commit

Permalink
Merge pull request #25 from TheThingsIndustries/feature/buf
Browse files Browse the repository at this point in the history
Build with Buf and push to BSR
  • Loading branch information
johanstokking committed Aug 8, 2023
2 parents de799f9 + 6f0dbb8 commit f26ecdd
Show file tree
Hide file tree
Showing 26 changed files with 421 additions and 328 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/bsr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Buf Schema Registry

on:
push:
tags:
- "v*"

jobs:
push:
name: Push
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Install Buf
uses: bufbuild/buf-setup-action@v1
with:
version: "1.25.1"
- name: Push
uses: bufbuild/buf-push-action@v1
with:
input: api
buf_token: ${{ secrets.BUF_TOKEN }}
21 changes: 21 additions & 0 deletions .github/workflows/buf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Buf

on:
- push
- pull_request

jobs:
lint:
name: Lint and Format
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Install Buf
uses: bufbuild/buf-setup-action@v1
with:
version: "1.25.1"
- name: Buf lint
uses: bufbuild/buf-lint-action@v1
- name: Buf format
run: buf format --exit-code
17 changes: 10 additions & 7 deletions .github/workflows/go-code.yml → .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
name: Go Code
name: Go

on:
- push
- pull_request

jobs:
test:
name: Go Test
runs-on: ubuntu-22.04
timeout-minutes: 10
name: Test
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "~1.19"
- name: Clean Build
go-version: "~1.20"
- name: Install Buf
uses: bufbuild/buf-setup-action@v1
with:
version: "1.25.1"
- name: Clean and Build
run: make clean build
- name: Go Test
- name: Test
run: make test
4 changes: 1 addition & 3 deletions .github/workflows/issue-triage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ name: Triage New Issues
on:
issues:
types: [opened]
pull_request_target:
types: [opened]

jobs:
triage:
name: Triage New Issues
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Add "needs/triage" label
Expand Down
37 changes: 7 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@ clean:
rm -f ./annotations/*.pb.go
rm -f ./test/*/*.pb.go

.dev/protoc-gen-go-flags/annotations.proto: annotations.proto
mkdir -p $(shell dirname $@)
cp $< $@
.bin/protoc-gen-go: go.mod
GOBIN=$(PWD)/.bin go install google.golang.org/protobuf/cmd/protoc-gen-go

annotations/annotations.pb.go: .dev/protoc-gen-go-flags/annotations.proto .dev/golangproto/bin/protoc .dev/golangproto/bin/protoc-gen-go
PATH="$$PWD/.bin:$$PWD/.dev/golangproto/bin:$$PATH" protoc -I .dev --go_opt=module=github.com/TheThingsIndustries/protoc-gen-go-flags --go_out=./ $<

internal/flagsplugin/annotations.pb.go: internal/flagsplugin/annotations.proto
protoc -I . --go_opt=paths=source_relative --go_out=./ ./internal/flagsplugin/annotations.proto
annotations/annotations.pb.go: api/thethings/flags/annotations.proto .bin/protoc-gen-go
buf generate api

BINARY_DEPS = annotations/annotations.pb.go $(wildcard cmd/protoc-gen-go-flags/*.go) $(wildcard internal/gen/*.go)

Expand All @@ -43,31 +39,12 @@ build: .bin/protoc-gen-go-flags .bin/protoc-gen-go-flags-linux-amd64 .bin/protoc
.PHONY: watch

watch:
ls annotations.proto cmd/protoc-gen-go-flags/*.go internal/gen/*.go test/*.proto | entr make build test

OS :=
ifeq ($(shell uname),Linux)
OS = linux
endif
ifeq ($(shell uname),Darwin)
OS = osx
endif

.dev/golangproto/bin/protoc:
mkdir -p .dev/golangproto/bin
curl -sSL -o .dev/golangproto/protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v3.20.1/protoc-3.20.1-$(OS)-x86_64.zip
unzip -o .dev/golangproto/protoc.zip -d .dev/golangproto/

.dev/golangproto/bin/protoc-gen-go:
go build -o $@ google.golang.org/protobuf/cmd/protoc-gen-go
ls api/thethings/flags/annotations.proto cmd/protoc-gen-go-flags/*.go internal/gen/*.go test/*.proto | entr make build test

.PHONY: testprotos

testprotos: build .dev/golangproto/bin/protoc .dev/golangproto/bin/protoc-gen-go
PATH="$$PWD/.bin:$$PWD/.dev/golangproto/bin:$$PATH" protoc -I ./test -I . \
--go_opt=paths=source_relative --go_out=./test/golang \
--go-flags_opt=paths=source_relative --go-flags_out=./test/golang \
./test/*.proto
testprotos: build .bin/protoc-gen-go
buf generate --template buf.gen.test.yaml test

.PHONY: test

Expand Down

0 comments on commit f26ecdd

Please sign in to comment.