Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protobuf linter #532

Merged
merged 3 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/buf-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Buf Linter
on:
pull_request:
paths:
- '**.proto'
- '**/buf.*'
- '**/buf.*.*'
- '**/Makefile'
permissions:
contents: read
pull-requests: write
jobs:
buf:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bufbuild/buf-action@v1
with:
input: 'x/emissions/proto'
format: true
lint: true
breaking: false
- uses: bufbuild/buf-action@v1
with:
input: 'x/mint/proto'
format: true
lint: true
breaking: false
13 changes: 0 additions & 13 deletions .github/workflows/format_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,6 @@ jobs:
gofmt-path: '.'
gofmt-flags: '-l -d'

clang-format:
name: "Clang Format Protobuf Check"
runs-on: ubuntu-latest
needs: [gofmt]

steps:
- uses: actions/checkout@v4
- name: Run clang-format style check for C/C++/Protobuf programs.
uses: jidicula/[email protected]
with:
clang-format-version: '17'
include-regex: '^.*\.proto$'

test:
runs-on: ubuntu-latest
timeout-minutes: 10
Expand Down
28 changes: 6 additions & 22 deletions x/emissions/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/make -f
.DEFAULT_GOAL := build
.DEFAULT_GOAL := proto-all

DOCKER := $(shell which docker)

Expand All @@ -15,7 +15,7 @@ test:
@echo "--> Running tests"
go test -v ./...

.PHONY: test test-integration
.PHONY: build test

##################
### Protobuf ###
Expand All @@ -33,28 +33,12 @@ proto-gen:
@go mod tidy

proto-format:
@$(protoImage) find ./ -name "*.proto" -exec clang-format -i {} \;
@$(protoImage) buf format proto/ -w

proto-lint:
@$(protoImage) buf lint proto/ --error-format=json

.PHONY: proto-all proto-gen proto-format proto-lint
proto-check-breaking:
@$(protoImage) buf breaking proto/ --against $(HTTPS_GIT)#branch=main

#################
### Linting ###
#################

golangci_lint_cmd=golangci-lint
golangci_version=v1.51.2

lint:
@echo "--> Running linter"
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version)
@$(golangci_lint_cmd) run ./... --timeout 15m

lint-fix:
@echo "--> Running linter and fixing issues"
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version)
@$(golangci_lint_cmd) run ./... --fix --timeout 15m

.PHONY: lint lint-fix
.PHONY: proto-all proto-gen proto-format proto-lint proto-check-breaking
8 changes: 4 additions & 4 deletions x/emissions/api/v1/reputer.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions x/emissions/api/v1/topic.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions x/emissions/api/v2/events.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading