Skip to content

Commit 0fd4bb4

Browse files
cstocktonChris Stockton
andauthored
chore: replace dev-deps with per-tool check targets (#2149)
When developing locally I always comment out dev-deps due to the failed soda command. Today I did a grepped through the repo and it seems soda is no longer used. - Remove unused `soda` command - Could not find any reference to this - Remove `dev-deps` target that installed all cmds - Add dedicated check targets: - `check-gosec` installs gosec if missing - `check-staticcheck` installs staticcheck if missing - `check-exhaustive` installs exhaustive if missing - `check-oapi-codegen` installs oapi-codegen if missing - Update existing targets to depend on new check targets: - `sec` depends on `check-gosec` - `unused` depends on `check-staticcheck` - `static` depends on `check-staticcheck` and `check-exhaustive` - `generate` depends on `check-oapi-codegen` - Adjust `.PHONY` declarations to include new check targets --------- Co-authored-by: Chris Stockton <[email protected]>
1 parent b118f1f commit 0fd4bb4

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

Makefile

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
.PHONY: all build deps dev-deps image migrate test vet sec format unused
1+
.PHONY: all build deps image migrate test vet sec format unused
2+
.PHONY: check-exhaustive check-gosec check-oapi-codegen check-staticcheck
23
CHECK_FILES?=./...
34

45
ifdef RELEASE_VERSION
@@ -33,13 +34,6 @@ build-strip: deps ## Build a stripped binary, for which the version file needs t
3334
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build \
3435
$(FLAGS) -ldflags "-s -w" -o auth-arm64-strip
3536

36-
dev-deps: ## Install developer dependencies
37-
@go install github.com/gobuffalo/pop/soda@latest
38-
@go install github.com/securego/gosec/v2/cmd/gosec@latest
39-
@go install honnef.co/go/tools/cmd/staticcheck@latest
40-
@go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@latest
41-
@go install github.com/nishanths/exhaustive/cmd/exhaustive@latest
42-
4337
deps: ## Install dependencies.
4438
@go mod download
4539
@go mod verify
@@ -57,26 +51,40 @@ test: build ## Run tests.
5751
vet: # Vet the code
5852
go vet $(CHECK_FILES)
5953

60-
sec: dev-deps # Check for security vulnerabilities
54+
sec: check-gosec # Check for security vulnerabilities
6155
gosec -quiet -exclude-generated $(CHECK_FILES)
6256
gosec -quiet -tests -exclude-generated -exclude=G104 $(CHECK_FILES)
6357

64-
unused: dev-deps # Look for unused code
58+
check-gosec:
59+
@command -v gosec >/dev/null 2>&1 \
60+
|| @go install github.com/securego/gosec/v2/cmd/gosec@latest
61+
62+
unused: | check-staticcheck # Look for unused code
6563
@echo "Unused code:"
6664
staticcheck -checks U1000 $(CHECK_FILES)
67-
6865
@echo
69-
7066
@echo "Code used only in _test.go (do move it in those files):"
7167
staticcheck -checks U1000 -tests=false $(CHECK_FILES)
7268

73-
static: dev-deps
69+
static: | check-staticcheck check-exhaustive
7470
staticcheck ./...
7571
exhaustive ./...
7672

77-
generate: dev-deps
73+
check-staticcheck:
74+
@command -v staticcheck >/dev/null 2>&1 \
75+
|| @go install honnef.co/go/tools/cmd/staticcheck@latest
76+
77+
check-exhaustive:
78+
@command -v exhaustive >/dev/null 2>&1 \
79+
|| @go install github.com/nishanths/exhaustive/cmd/exhaustive@latest
80+
81+
generate: | check-oapi-codegen
7882
go generate ./...
7983

84+
check-oapi-codegen:
85+
@command -v oapi-codegen >/dev/null 2>&1 \
86+
|| go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@latest
87+
8088
dev: ## Run the development containers
8189
${DOCKER_COMPOSE} -f $(DEV_DOCKER_COMPOSE) up
8290

0 commit comments

Comments
 (0)