detached 0456561

refactor(build): enhance Makefile with development targets and update golangci-lint configuration

- Add help, fmt, lint, mocks, check targets to Makefile
- Add test-usecase, test-adapter, test-v, test-short targets
- Add build-local target for current platform
- Organize targets with section headers
- Update golangci-lint config for clean architecture
commit
04565617c21120a9e925984433e0900331c056a2
author
brice · · 2026-01-12 18:48 UTC
committer
brice · · 2026-01-12 20:59 UTC
parent
7efce35
signature
unsigned
2 files · +120 -41
M .golangci.yml +48 -14
@@ -1,35 +1,69 @@
1+version: "2"
2+
13 run:
24 timeout: 5m
35 tests: true
46
57 linters:
68 enable:
7- - gofmt
89 - govet
910 - errcheck
1011 - staticcheck
1112 - unused
12- - gosimple
1313 - ineffassign
14- - typecheck
1514 - misspell
1615 - gosec
1716 - unconvert
1817 - gocyclo
18+ settings:
19+ gocyclo:
20+ min-complexity: 15
21+ exclusions:
22+ rules:
23+ - path: _test\.go
24+ linters:
25+ - gocyclo
26+ - errcheck
27+ - dupl
28+ - gosec
29+ - text: "Error return value of `.*Close` is not checked"
30+ linters:
31+ - errcheck
32+ - text: "Error return value of `.*Write` is not checked"
33+ linters:
34+ - errcheck
35+ - text: "Error return value of `os.Remove.*` is not checked"
36+ linters:
37+ - errcheck
38+ - text: "Error return value of `.*Publish` is not checked"
39+ linters:
40+ - errcheck
41+ - text: "Error return value of `.*Stop` is not checked"
42+ linters:
43+ - errcheck
44+ - text: "Error return value of `.*RemoveContainer` is not checked"
45+ linters:
46+ - errcheck
47+ - text: "Error return value of `log.WrapErr` is not checked"
48+ linters:
49+ - errcheck
50+ - text: "Error return value of `log.WrapErrWithFields` is not checked"
51+ linters:
52+ - errcheck
53+ # gosec: file operations with variables are intentional in storage layer
54+ - text: "G304:"
55+ linters:
56+ - gosec
57+ # gosec: G104 duplicates errcheck
58+ - text: "G104:"
59+ linters:
60+ - gosec
1961
20-linters-settings:
21- gocyclo:
22- min-complexity: 15
62+formatters:
63+ enable:
64+ - gofmt
2365
2466 issues:
25- exclude-rules:
26- - path: _test\.go
27- linters:
28- - gocyclo
29- - errcheck
30- - dupl
31- - gosec
32-
3367 max-same-issues: 50
3468
3569 severity:
@@ -1,35 +1,69 @@
1+version: "2"
2+
1 run:3 run:
2 timeout: 5m4 timeout: 5m
3 tests: true5 tests: true
4 6
5 linters:7 linters:
6 enable:8 enable:
7- - gofmt
8 - govet9 - govet
9 - errcheck10 - errcheck
10 - staticcheck11 - staticcheck
11 - unused12 - unused
12- - gosimple
13 - ineffassign13 - ineffassign
14- - typecheck
15 - misspell14 - misspell
16 - gosec15 - gosec
17 - unconvert16 - unconvert
18 - gocyclo17 - gocyclo
18+ settings:
19+ gocyclo:
20+ min-complexity: 15
21+ exclusions:
22+ rules:
23+ - path: _test\.go
24+ linters:
25+ - gocyclo
26+ - errcheck
27+ - dupl
28+ - gosec
29+ - text: "Error return value of `.*Close` is not checked"
30+ linters:
31+ - errcheck
32+ - text: "Error return value of `.*Write` is not checked"
33+ linters:
34+ - errcheck
35+ - text: "Error return value of `os.Remove.*` is not checked"
36+ linters:
37+ - errcheck
38+ - text: "Error return value of `.*Publish` is not checked"
39+ linters:
40+ - errcheck
41+ - text: "Error return value of `.*Stop` is not checked"
42+ linters:
43+ - errcheck
44+ - text: "Error return value of `.*RemoveContainer` is not checked"
45+ linters:
46+ - errcheck
47+ - text: "Error return value of `log.WrapErr` is not checked"
48+ linters:
49+ - errcheck
50+ - text: "Error return value of `log.WrapErrWithFields` is not checked"
51+ linters:
52+ - errcheck
53+ # gosec: file operations with variables are intentional in storage layer
54+ - text: "G304:"
55+ linters:
56+ - gosec
57+ # gosec: G104 duplicates errcheck
58+ - text: "G104:"
59+ linters:
60+ - gosec
19 61
20-linters-settings:62+formatters:
21- gocyclo:63+ enable:
22- min-complexity: 1564+ - gofmt
23 65
24 issues:66 issues:
25- exclude-rules:
26- - path: _test\.go
27- linters:
28- - gocyclo
29- - errcheck
30- - dupl
31- - gosec
32-
33 max-same-issues: 5067 max-same-issues: 50
34 68
35 severity:69 severity:
M Makefile +72 -27
@@ -21,13 +21,65 @@ LDFLAGS := -s -w \
2121 ARCHS := amd64 arm64
2222
2323 # Phony targets
24-.PHONY: all build build-push clean dev-release test test-unit test-coverage test-race clean-test
24+.PHONY: all build build-push clean dev-release \
25+ test test-short test-race test-coverage \
26+ lint fmt check mocks clean-test help
2527
2628 # Default target
2729 all: build
2830
29-# Build binaries
30-build:
31+##@ Development
32+
33+help: ## Show this help
34+ @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
35+
36+fmt: ## Format Go code
37+ @echo "Formatting Go code..."
38+ @go fmt ./...
39+
40+lint: ## Run golangci-lint
41+ @echo "Running linter..."
42+ @golangci-lint run ./...
43+
44+mocks: ## Generate mocks using mockery
45+ @echo "Generating mocks..."
46+ @mockery
47+ @echo "Mocks generated successfully"
48+
49+check: lint test ## Run lint and tests
50+
51+##@ Testing
52+
53+test: ## Run all tests
54+ @echo "Running tests..."
55+ @go test ./...
56+
57+test-v: ## Run all tests with verbose output
58+ @go test -v ./...
59+
60+test-short: ## Run tests (skip long-running tests)
61+ @go test -short ./...
62+
63+test-race: ## Run tests with race detector
64+ @echo "Running tests with race detector..."
65+ @go test -race ./...
66+
67+test-coverage: ## Run tests with coverage report
68+ @echo "Running tests with coverage..."
69+ @go test -coverprofile=coverage.out ./...
70+ @go tool cover -func=coverage.out
71+ @go tool cover -html=coverage.out -o coverage.html
72+ @echo "Coverage report generated: coverage.html"
73+
74+test-usecase: ## Run usecase layer tests only
75+ @go test -v ./internal/usecase/...
76+
77+test-adapter: ## Run adapter layer tests only
78+ @go test -v ./internal/adapters/...
79+
80+##@ Build
81+
82+build: ## Build binaries for linux (amd64 and arm64)
3183 @echo "Building Go binaries..."
3284 @mkdir -p $(DIST_DIR)
3385 @rm -f $(DIST_DIR)/*
@@ -36,8 +88,14 @@ build:
3688 @CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="$(LDFLAGS)" -o $(DIST_DIR)/gordon-linux-arm64 ./main.go
3789 @echo "Go binaries built successfully"
3890
39-# Build and push Docker images
40-build-push: build
91+build-local: ## Build binary for current platform
92+ @echo "Building for current platform..."
93+ @go build -ldflags="$(LDFLAGS)" -o $(DIST_DIR)/gordon ./main.go
94+ @echo "Binary built: $(DIST_DIR)/gordon"
95+
96+##@ Release
97+
98+build-push: build ## Build and push Docker images
4199 @echo "Cleaning up dangling images..."
42100 @$(ENGINE) image prune -f
43101
@@ -69,8 +127,7 @@ build-push: build
69127
70128 @echo "Script completed successfully."
71129
72-# Create dev GitHub release (separate from GoReleaser)
73-dev-release: build
130+dev-release: build ## Create dev GitHub release
74131 @echo "Creating dev GitHub release..."
75132 @if [ -z "$(shell which gh)" ]; then \
76133 echo "Error: GitHub CLI (gh) is not installed. Please install it first."; \
@@ -92,27 +149,15 @@ dev-release: build
92149 @echo ""
93150 @echo "🔗 Release page: https://github.com/bnema/gordon/releases/tag/$(DEV_TAG)"
94151
95-# Test targets
96-test: test-unit
97-
98-test-unit:
99- go test -v ./...
100-
101-test-race:
102- go test -race -v ./...
152+##@ Cleanup
103153
104-test-coverage:
105- go test -coverprofile=coverage.out ./...
106- go tool cover -html=coverage.out -o coverage.html
107- @echo "Coverage report generated: coverage.html"
108-
109-
110-clean-test:
111- rm -f coverage.out coverage.html
112-
113-# Clean up
114-clean:
154+clean: ## Clean build artifacts
115155 @echo "Cleaning up..."
116156 @rm -rf $(DIST_DIR)
157+ @echo "Cleanup completed."
158+
159+clean-all: clean clean-test ## Clean all artifacts including test files
117160 @$(ENGINE) system prune -f
118- @echo "Cleanup completed."⏎̸
161+
162+clean-test: ## Clean test artifacts
163+ @rm -f coverage.out coverage.html⏎̸
@@ -21,13 +21,65 @@ LDFLAGS := -s -w \
21 ARCHS := amd64 arm6421 ARCHS := amd64 arm64
22 22
23 # Phony targets23 # Phony targets
24-.PHONY: all build build-push clean dev-release test test-unit test-coverage test-race clean-test24+.PHONY: all build build-push clean dev-release \
25+ test test-short test-race test-coverage \
26+ lint fmt check mocks clean-test help
25 27
26 # Default target28 # Default target
27 all: build29 all: build
28 30
29-# Build binaries31+##@ Development
30-build:32+
33+help: ## Show this help
34+ @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
35+
36+fmt: ## Format Go code
37+ @echo "Formatting Go code..."
38+ @go fmt ./...
39+
40+lint: ## Run golangci-lint
41+ @echo "Running linter..."
42+ @golangci-lint run ./...
43+
44+mocks: ## Generate mocks using mockery
45+ @echo "Generating mocks..."
46+ @mockery
47+ @echo "Mocks generated successfully"
48+
49+check: lint test ## Run lint and tests
50+
51+##@ Testing
52+
53+test: ## Run all tests
54+ @echo "Running tests..."
55+ @go test ./...
56+
57+test-v: ## Run all tests with verbose output
58+ @go test -v ./...
59+
60+test-short: ## Run tests (skip long-running tests)
61+ @go test -short ./...
62+
63+test-race: ## Run tests with race detector
64+ @echo "Running tests with race detector..."
65+ @go test -race ./...
66+
67+test-coverage: ## Run tests with coverage report
68+ @echo "Running tests with coverage..."
69+ @go test -coverprofile=coverage.out ./...
70+ @go tool cover -func=coverage.out
71+ @go tool cover -html=coverage.out -o coverage.html
72+ @echo "Coverage report generated: coverage.html"
73+
74+test-usecase: ## Run usecase layer tests only
75+ @go test -v ./internal/usecase/...
76+
77+test-adapter: ## Run adapter layer tests only
78+ @go test -v ./internal/adapters/...
79+
80+##@ Build
81+
82+build: ## Build binaries for linux (amd64 and arm64)
31 @echo "Building Go binaries..."83 @echo "Building Go binaries..."
32 @mkdir -p $(DIST_DIR)84 @mkdir -p $(DIST_DIR)
33 @rm -f $(DIST_DIR)/*85 @rm -f $(DIST_DIR)/*
@@ -36,8 +88,14 @@ build:
36 @CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="$(LDFLAGS)" -o $(DIST_DIR)/gordon-linux-arm64 ./main.go88 @CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="$(LDFLAGS)" -o $(DIST_DIR)/gordon-linux-arm64 ./main.go
37 @echo "Go binaries built successfully"89 @echo "Go binaries built successfully"
38 90
39-# Build and push Docker images91+build-local: ## Build binary for current platform
40-build-push: build92+ @echo "Building for current platform..."
93+ @go build -ldflags="$(LDFLAGS)" -o $(DIST_DIR)/gordon ./main.go
94+ @echo "Binary built: $(DIST_DIR)/gordon"
95+
96+##@ Release
97+
98+build-push: build ## Build and push Docker images
41 @echo "Cleaning up dangling images..."99 @echo "Cleaning up dangling images..."
42 @$(ENGINE) image prune -f100 @$(ENGINE) image prune -f
43 101
@@ -69,8 +127,7 @@ build-push: build
69 127
70 @echo "Script completed successfully."128 @echo "Script completed successfully."
71 129
72-# Create dev GitHub release (separate from GoReleaser)130+dev-release: build ## Create dev GitHub release
73-dev-release: build
74 @echo "Creating dev GitHub release..."131 @echo "Creating dev GitHub release..."
75 @if [ -z "$(shell which gh)" ]; then \132 @if [ -z "$(shell which gh)" ]; then \
76 echo "Error: GitHub CLI (gh) is not installed. Please install it first."; \133 echo "Error: GitHub CLI (gh) is not installed. Please install it first."; \
@@ -92,27 +149,15 @@ dev-release: build
92 @echo ""149 @echo ""
93 @echo "🔗 Release page: https://github.com/bnema/gordon/releases/tag/$(DEV_TAG)"150 @echo "🔗 Release page: https://github.com/bnema/gordon/releases/tag/$(DEV_TAG)"
94 151
95-# Test targets152+##@ Cleanup
96-test: test-unit
97-
98-test-unit:
99- go test -v ./...
100-
101-test-race:
102- go test -race -v ./...
103 153
104-test-coverage:154+clean: ## Clean build artifacts
105- go test -coverprofile=coverage.out ./...
106- go tool cover -html=coverage.out -o coverage.html
107- @echo "Coverage report generated: coverage.html"
108-
109-
110-clean-test:
111- rm -f coverage.out coverage.html
112-
113-# Clean up
114-clean:
115 @echo "Cleaning up..."155 @echo "Cleaning up..."
116 @rm -rf $(DIST_DIR)156 @rm -rf $(DIST_DIR)
157+ @echo "Cleanup completed."
158+
159+clean-all: clean clean-test ## Clean all artifacts including test files
117 @$(ENGINE) system prune -f160 @$(ENGINE) system prune -f
118- @echo "Cleanup completed."⏎̸161+
162+clean-test: ## Clean test artifacts
163+ @rm -f coverage.out coverage.html⏎̸

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close