build: switch from protoc to buf to build protobuf

This commit is contained in:
Vincent Bernat
2025-07-12 23:15:18 +02:00
parent 18fad44f25
commit f4c879e525
9 changed files with 19 additions and 20 deletions

View File

@@ -48,7 +48,7 @@ jobs:
- name: Setup - name: Setup
uses: ./.github/actions/setup uses: ./.github/actions/setup
- name: Install dependencies - name: Install dependencies
run: sudo apt-get install -qqy shared-mime-info curl protobuf-compiler run: sudo apt-get install -qqy shared-mime-info curl
# Build and test # Build and test
- name: Build - name: Build
@@ -93,8 +93,6 @@ jobs:
persist-credentials: false persist-credentials: false
- name: Setup - name: Setup
uses: ./.github/actions/setup uses: ./.github/actions/setup
- name: Install dependencies
run: brew install protobuf
# Build and test # Build and test
- name: Build - name: Build
@@ -157,8 +155,6 @@ jobs:
uses: ./.github/actions/setup uses: ./.github/actions/setup
with: with:
go-version: ${{ matrix.go-version }} go-version: ${{ matrix.go-version }}
- name: Install dependencies
run: sudo apt-get install -qqy protobuf-compiler
- name: Build - name: Build
run: make && ./bin/akvorado version run: make && ./bin/akvorado version
- uses: actions/cache/save@v4 - uses: actions/cache/save@v4

View File

@@ -23,7 +23,7 @@ run tests:
# past but this is a slight burden to maintain in addition to GitHub CI. # past but this is a slight burden to maintain in addition to GitHub CI.
# Check commit ceaa6ebf8ef6 for the last version supporting functional # Check commit ceaa6ebf8ef6 for the last version supporting functional
# tests. # tests.
- time apk add --no-cache git make gcc musl-dev shared-mime-info npm curl protoc - time apk add --no-cache git make gcc musl-dev shared-mime-info npm curl
- export GOMODCACHE=$PWD/.go-cache - export GOMODCACHE=$PWD/.go-cache
- npm config --user set cache $PWD/.npm-cache - npm config --user set cache $PWD/.npm-cache
- time go mod download - time go mod download

View File

@@ -59,17 +59,16 @@ GOIMPORTS = go tool goimports
GOTESTSUM = go tool gotestsum GOTESTSUM = go tool gotestsum
MOCKGEN = go tool mockgen MOCKGEN = go tool mockgen
PIGEON = go tool pigeon PIGEON = go tool pigeon
PROTOC = protoc
PROTOC_GEN_GO = bin/protoc-gen-go
REVIVE = go tool revive REVIVE = go tool revive
WWHRD = go tool wwhrd WWHRD = go tool wwhrd
BUF = go run github.com/bufbuild/buf/cmd/buf@v1.55.1
# Generated files # Generated files
.DELETE_ON_ERROR: .DELETE_ON_ERROR:
common/pb/rawflow.pb.go: common/pb/rawflow.proto ; $(info $(M) compiling protocol buffers definition) common/pb/rawflow.pb.go: %.pb.go: buf.gen.yaml %.proto ; $(info $(M) compiling protocol buffers definition)
$Q $(PROTOC) -I=. --plugin=$(PROTOC_GEN_GO) --go_out=. --go_opt=module=$(MODULE) $< $Q $(BUF) generate --path $(@:.pb.go=.proto)
common/clickhousedb/mocks/mock_driver.go: go.mod ; $(info $(M) generate mocks for ClickHouse driver) common/clickhousedb/mocks/mock_driver.go: go.mod ; $(info $(M) generate mocks for ClickHouse driver)
$Q $(MOCKGEN) -package mocks -build_constraint "!release" -destination $@ \ $Q $(MOCKGEN) -package mocks -build_constraint "!release" -destination $@ \

View File

@@ -1,2 +0,0 @@
#!/bin/sh
go tool protoc-gen-go "$@"

7
buf.gen.yaml Normal file
View File

@@ -0,0 +1,7 @@
---
version: v2
plugins:
- local: [ "go", "tool", "protoc-gen-go" ]
out: .
opt:
- paths=source_relative

View File

@@ -31,12 +31,12 @@ Currently, only a pre-built binary for Linux x86-64 is provided.
## Compilation from source ## Compilation from source
You need a proper installation of [Go](https://go.dev/doc/install) (1.24+) and You need a proper installation of [Go](https://go.dev/doc/install) (1.24+), and
[NodeJS](https://nodejs.org/en/download/) (20+) with NPM (6+). For example, on [NodeJS](https://nodejs.org/en/download/) (20+) with NPM (6+). For example, on
Debian: Debian:
```console ```console
# apt install golang nodejs npm protobuf-compiler # apt install golang nodejs npm
# go version # go version
go version go1.24.1 linux/amd64 go version go1.24.1 linux/amd64
# node --version # node --version

View File

@@ -55,7 +55,7 @@
find . -print0 | xargs -0 touch -d @0 find . -print0 | xargs -0 touch -d @0
make all \ make all \
PROTOC=${pkgs.protobuf}/bin/protoc \ BUF=${pkgs.buf}/bin/buf \
ASNS_URL=${asn2org}/asns.csv \ ASNS_URL=${asn2org}/asns.csv \
SERVICES_URL=${ianaServiceNames} SERVICES_URL=${ianaServiceNames}
''; '';
@@ -111,7 +111,6 @@
nodejs nodejs
pkgs.git pkgs.git
pkgs.curl pkgs.curl
pkgs.protobuf
]; ];
}; };
}); });

6
go.mod
View File

@@ -3,6 +3,7 @@ module akvorado
go 1.24 go 1.24
require ( require (
github.com/ClickHouse/ch-go v0.66.1
github.com/ClickHouse/clickhouse-go/v2 v2.37.2 github.com/ClickHouse/clickhouse-go/v2 v2.37.2
github.com/IBM/sarama v1.45.2 github.com/IBM/sarama v1.45.2
github.com/alecthomas/chroma v0.10.0 github.com/alecthomas/chroma v0.10.0
@@ -26,7 +27,6 @@ require (
github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.1 github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.1
github.com/hashicorp/go-version v1.7.0 github.com/hashicorp/go-version v1.7.0
github.com/itchyny/gojq v0.12.17 github.com/itchyny/gojq v0.12.17
github.com/jhump/protoreflect v1.17.0
github.com/kentik/patricia v1.2.1 github.com/kentik/patricia v1.2.1
github.com/kylelemons/godebug v1.1.0 github.com/kylelemons/godebug v1.1.0
github.com/mattn/go-isatty v0.0.20 github.com/mattn/go-isatty v0.0.20
@@ -50,7 +50,6 @@ require (
golang.org/x/oauth2 v0.30.0 golang.org/x/oauth2 v0.30.0
golang.org/x/sys v0.33.0 golang.org/x/sys v0.33.0
golang.org/x/text v0.26.0 golang.org/x/text v0.26.0
golang.org/x/time v0.12.0
google.golang.org/grpc v1.72.2 google.golang.org/grpc v1.72.2
google.golang.org/protobuf v1.36.6 google.golang.org/protobuf v1.36.6
gopkg.in/tomb.v2 v2.0.0-20161208151619-d5d1b5820637 gopkg.in/tomb.v2 v2.0.0-20161208151619-d5d1b5820637
@@ -66,7 +65,6 @@ require (
github.com/AlekSi/gocov-xml v1.1.0 // indirect github.com/AlekSi/gocov-xml v1.1.0 // indirect
github.com/AlekSi/pointer v1.2.0 // indirect github.com/AlekSi/pointer v1.2.0 // indirect
github.com/BurntSushi/toml v1.4.0 // indirect github.com/BurntSushi/toml v1.4.0 // indirect
github.com/ClickHouse/ch-go v0.66.1 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/andybalholm/brotli v1.1.1 // indirect github.com/andybalholm/brotli v1.1.1 // indirect
github.com/axw/gocov v1.2.1 // indirect github.com/axw/gocov v1.2.1 // indirect
@@ -134,6 +132,7 @@ require (
github.com/jcmturner/rpc/v2 v2.0.3 // indirect github.com/jcmturner/rpc/v2 v2.0.3 // indirect
github.com/jellydator/ttlcache/v2 v2.11.1 // indirect github.com/jellydator/ttlcache/v2 v2.11.1 // indirect
github.com/jessevdk/go-flags v1.5.0 // indirect github.com/jessevdk/go-flags v1.5.0 // indirect
github.com/jhump/protoreflect v1.17.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect github.com/jinzhu/now v1.1.5 // indirect
github.com/josharian/native v1.1.0 // indirect github.com/josharian/native v1.1.0 // indirect
@@ -199,6 +198,7 @@ require (
golang.org/x/net v0.41.0 // indirect golang.org/x/net v0.41.0 // indirect
golang.org/x/sync v0.15.0 // indirect golang.org/x/sync v0.15.0 // indirect
golang.org/x/term v0.32.0 // indirect golang.org/x/term v0.32.0 // indirect
golang.org/x/time v0.12.0 // indirect
golang.org/x/tools v0.33.0 // indirect golang.org/x/tools v0.33.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect

View File

@@ -1 +1 @@
sha256-TeYE1s4Yw4Ag2IbmP/bNgzP+XoOiup+gXm25nNaeTAU= sha256-Ejw42fH6T+qZXeR5lJ9ThmzXTWnRg1fSnh70La8LmGw=