Skip to content
Open
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
11 changes: 4 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
# This job executes untrusted PR code (gazelle, gofmt, goimports).
# This job executes untrusted PR code (gazelle, golangci-lint).
persist-credentials: false

- name: Set up Go
Expand All @@ -117,15 +117,12 @@ jobs:
run: make gazelle

- name: Run linters
run: |
gofmt -w .
go install golang.org/x/tools/cmd/goimports@latest
goimports -w .
uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0

- name: Verify no uncommitted changes from linters
- name: Verify no uncommitted changes from gazelle
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "::error::Code is not formatted. Please run 'make gazelle', 'gofmt -w .', and 'goimports -w .' locally and commit the results."
echo "::error::Code is not formatted. Please run 'make gazelle' locally and commit the results."
git diff
exit 1
fi
Expand Down
48 changes: 48 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
version: "2"

run:
go: "1.24"
timeout: 5m

linters:
default: standard
enable:
- goconst
- gocyclo
- misspell
- revive
settings:
goconst:
min-len: 3
min-occurrences: 3
gocyclo:
min-complexity: 30
revive:
rules:
- name: blank-imports
- name: exported
arguments:
- disableStutteringCheck
- name: unused-parameter
- name: unreachable-code
- name: redefines-builtin-id
exclusions:
generated: strict
presets:
- comments
- std-error-handling
rules:
- path: _test\.go
linters:
- errcheck
- goconst
paths:
- tangopb
- tangopbmock
- ".*/mock/"
- ".*mock/"

formatters:
enable:
- gofmt
- goimports
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: build test proto gazelle clean clean-proto run-server run-client-get-graph run-client-changed-targets help
.PHONY: build clean clean-proto gazelle help lint proto run-client-changed-targets run-client-get-graph run-server test

# Bazel wrapper
BAZEL = ./tools/bazel
Expand All @@ -15,6 +15,12 @@ test:
@$(BAZEL) test //...
@echo "All tests passed!"

# Run golangci-lint
lint: ## Run golangci-lint
@echo "Running golangci-lint..."
@golangci-lint run ./...
@echo "Lint passed!"

# Generate protobuf files using protoc
proto:
@echo "Generating protobuf files with protoc..."
Expand Down Expand Up @@ -82,6 +88,7 @@ help:
@echo ""
@echo "Build & Test:"
@echo " make build - Build all targets"
@echo " make lint - Run golangci-lint"
@echo " make test - Run all tests"
@echo " make gazelle - Update BUILD.bazel files"
@echo " make clean - Clean generated files and binaries"
Expand Down
Loading