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
23 changes: 7 additions & 16 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ jobs:
with:
go-version: ^1.24

- name: Download dependencies
run: go mod download

- name: Run unit tests and generate the coverage report
run: make test-race

Expand All @@ -37,20 +34,14 @@ jobs:
with:
go-version: ^1.24

- name: Download dependencies
run: go mod download

- name: Install gofumpt
run: go install mvdan.cc/[email protected]

- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/[email protected]
- name: Get golangci-lint version
id: golangci_version
run: echo "version=$(go list -m -f '{{.Version}}' github.com/golangci/golangci-lint/v2)" >> $GITHUB_OUTPUT

- name: Install golangci-lint
run: go install github.com/golangci/golangci-lint/v2/cmd/[email protected]

- name: Lint
run: make lint
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v8
with:
version: ${{ steps.golangci_version.outputs.version }}

- name: Ensure go mod tidy runs without changes
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@

# Builds
/build
/bin
90 changes: 47 additions & 43 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
version: "2"

linters:
enable-all: true
default: all
disable:
- cyclop
- forbidigo
Expand All @@ -24,9 +25,15 @@ linters:
- varnamelen
- wrapcheck
- wsl
- wsl_v5
- exhaustruct
- depguard
- err113
- funcorder
- noinlineerr
- gocognit
- gocyclo
- maintidx

#
# Disabled because of generics:
Expand All @@ -40,52 +47,49 @@ linters:
# Disabled because deprecated:
#

linters-settings:
#
# The G108 rule throws a false positive. We're not actually vulnerable. If
# you're not careful the profiling endpoint is automatically exposed on
# /debug/pprof if you import net/http/pprof. See this link:
#
# https://mmcloughlin.com/posts/your-pprof-is-showing
#
gosec:
excludes:
- G108

tagliatelle:
case:
rules:
json: snake
settings:
#
# The G108 rule throws a false positive. We're not actually vulnerable. If
# you're not careful the profiling endpoint is automatically exposed on
# /debug/pprof if you import net/http/pprof. See this link:
#
# https://mmcloughlin.com/posts/your-pprof-is-showing
#
gosec:
excludes:
- G108

gofumpt:
extra-rules: true
tagliatelle:
case:
rules:
json: snake

exhaustruct:
exclude:
#
# Because it's easier to read without the other fields.
#
- 'GetPayloadsFilters'
exhaustruct:
exclude:
#
# Because it's easier to read without the other fields.
#
- 'GetPayloadsFilters'

#
# Structures outside our control that have a ton of settings. It doesn't
# make sense to specify all of the fields.
#
- 'cobra.Command'
- 'database.*Entry'
- 'http.Server'
- 'logrus.*Formatter'
- 'Options' # redis
#
# Structures outside our control that have a ton of settings. It doesn't
# make sense to specify all of the fields.
#
- 'cobra.Command'
- 'database.*Entry'
- 'http.Server'
- 'logrus.*Formatter'
- 'Options' # redis

#
# Excluded because there are private fields (not capitalized) that are
# not initialized. If possible, I think these should be altered.
#
- 'Datastore'
- 'Housekeeper'
- 'MockBeaconClient'
- 'RelayAPI'
- 'Webserver'
#
# Excluded because there are private fields (not capitalized) that are
# not initialized. If possible, I think these should be altered.
#
- 'Datastore'
- 'Housekeeper'
- 'MockBeaconClient'
- 'RelayAPI'
- 'Webserver'

formatters:
enable:
Expand Down
34 changes: 25 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@

VERSION := $(shell git describe --tags --always --dirty="-dev")

# Install tools to project-local bin directory
GOBIN := $(CURDIR)/bin
export GOBIN

# Extract pinned versions from go.mod (single source of truth)
define modver
$(shell go list -m -f '{{.Version}}' $(1))
endef

# Tool installation targets (versions from go.mod via tools.go)
GOLANGCI_LINT := github.com/golangci/golangci-lint/v2/cmd/golangci-lint
GCI := github.com/daixiang0/gci
GOFUMPT := mvdan.cc/gofumpt

##@ Help

.PHONY: help
Expand Down Expand Up @@ -44,25 +58,27 @@ test: ## Run tests
test-race: ## Run tests with race detector
go test -race ./...

.PHONY: install-tools
install-tools: ## Install development tools from tools/tools.go
@echo "Installing tools into $(GOBIN)"
go install $(GOLANGCI_LINT)
go install $(GCI)
go install $(GOFUMPT)

.PHONY: lint
lint: ## Run linters
gofmt -d -s .
gofumpt -d -extra .
go vet ./...
staticcheck ./...
golangci-lint run
# nilaway ./...
$(GOBIN)/golangci-lint run

.PHONY: fmt
fmt: ## Format the code
gofmt -s -w .
gci write .
gofumpt -w -extra .
$(GOBIN)/gci write .
$(GOBIN)/gofumpt -w -extra .
go mod tidy

.PHONY: gofumpt
gofumpt: ## Run gofumpt
gofumpt -l -w -extra .
$(GOBIN)/gofumpt -l -w -extra .

.PHONY: lt
lt: lint test ## Run linters and tests
Expand Down
Loading