Skip to content

Commit

Permalink
ci: add buf lints to generated file checks
Browse files Browse the repository at this point in the history
Signed-off-by: William Findlay <william.findlay@isovalent.com>
  • Loading branch information
will-isovalent committed Feb 12, 2025
1 parent 47347c6 commit 3760d67
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
16 changes: 13 additions & 3 deletions .github/workflows/generated-files.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,22 @@ on:
- main
- v*
paths-ignore:
- 'docs/**'
- "docs/**"
pull_request:
paths-ignore:
- 'docs/**'
- "docs/**"

jobs:
checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Lint protobuf
run: |
# TODO: enable linting once we have a chance to fix the underlying issues
# make -C api lint EXTRA_BUF_FLAGS="--error-format=github-actions"
make -C api check-breaking EXTRA_BUF_FLAGS="--error-format=github-actions"
make -C api format EXTRA_BUF_FLAGS="--exit-code --error-format=github-actions"
generated-files:
runs-on: ubuntu-latest
steps:
Expand All @@ -19,7 +29,7 @@ jobs:
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
# renovate: datasource=golang-version depName=go
go-version: '1.23.5'
go-version: "1.23.5"
- name: Go version
run: go version
- name: Validate that generated files are up to date.
Expand Down
14 changes: 8 additions & 6 deletions api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

include ../Makefile.defs

EXTRA_BUF_FLAGS ?=

.PHONY: all
all:

Expand All @@ -12,19 +14,19 @@ __all_local: __format_local __check-breaking_local __proto_local #__lint_local

.PHONY: __proto_local
__proto_local:
$(BUF) generate
$(BUF) generate $(EXTRA_BUF_FLAGS)

.PHONY: __lint_local
__lint_local:
$(BUF) lint
$(BUF) lint $(EXTRA_BUF_FLAGS)

.PHONY: __format_local
__format_local:
$(BUF) format -w
$(BUF) format -w $(EXTRA_BUF_FLAGS)

.PHONY: __check-breaking_local
__check-breaking_local:
$(BUF) breaking /src/api --against "$(CURDIR)/../.git#branch=$(BUF_BREAKING_AGAINST_BRANCH),subdir=api/v1"
$(BUF) breaking /src/api --against "$(CURDIR)/../.git#branch=$(BUF_BREAKING_AGAINST_BRANCH),subdir=api/v1" $(EXTRA_BUF_FLAGS)

.PHONY: proto lint format check-breaking
all proto lint format check-breaking:
Expand All @@ -33,7 +35,7 @@ all proto lint format check-breaking:
--workdir /src/api \
--user "$(shell id -u):$(shell id -g)" \
$(BUILDER_IMAGE) \
make -C /src/api __$@_local BUF_BREAKING_AGAINST_BRANCH=$(BUF_BREAKING_AGAINST_BRANCH)
make -C /src/api __$@_local BUF_BREAKING_AGAINST_BRANCH=$(BUF_BREAKING_AGAINST_BRANCH)

.PHONY: debug
debug:
Expand All @@ -42,7 +44,7 @@ debug:
--workdir /src/api \
--user "$(shell id -u):$(shell id -g)" \
$(BUILDER_IMAGE) \
buf
buf $(EXTRA_BUF_FLAGS)

.PHONY: vendor
vendor:
Expand Down

0 comments on commit 3760d67

Please sign in to comment.