build: ensure proper caching of buf tool

We use a wrapper and we include it in the hash for setup-go
This commit is contained in:
Vincent Bernat
2025-08-21 08:34:15 +02:00
parent 7fd2bbb03f
commit daaf419cef
3 changed files with 18 additions and 3 deletions

View File

@@ -34,6 +34,9 @@ runs:
with:
go-version: ${{ inputs.go-version }}
check-latest: true
cache-dependency-path: |
go.sum
bin/external-tool
- uses: actions/setup-node@v4
if: ${{ inputs.setup-node == 'true' }}
with:

View File

@@ -41,7 +41,7 @@ GENERATED = \
console/data/frontend
.PHONY: all all-indep
BUILD_ARGS=
BUILD_ARGS =
all: fmt lint all-indep ; $(info $(M) building executable) @ ## Build program binary
$Q env GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) \
$(if $(filter amd64,$(TARGETARCH)),GOAMD64=$(TARGETVARIANT),\
@@ -64,13 +64,13 @@ PIGEON = go tool pigeon
REVIVE = go tool revive
STATICCHECK = go tool staticcheck
WWHRD = go tool wwhrd
BUF = go run github.com/bufbuild/buf/cmd/buf@v1.55.1
BUF = ./bin/external-tool buf
# Generated files
.DELETE_ON_ERROR:
common/pb/rawflow_vtproto.pb.go: common/pb/rawflow.pb.go
common/pb/rawflow_vtproto.pb.go: | common/pb/rawflow.pb.go
%.pb.go: buf.gen.yaml %.proto ; $(info $(M) compiling protocol buffers $@…)
$Q $(BUF) generate --path $(@:.pb.go=.proto)

12
bin/external-tool Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/sh
# Wrapper to execute an external tool. This is used a bit like "go tool", but in
# a case we don't want to put the dependency in go.mod (which may be considered
# by an anti-pattern for some tools).
cmd="$1"
shift
case "$cmd" in
buf) exec go run github.com/bufbuild/buf/cmd/buf@v1.55.1 "$@" ;;
esac