Skip to content

Find, verify, and analyze leaked credentials

Spruce up Makefile a little (#5347)

Charlie Gunyon4dd8831c5f12
diff --git a/.gitignore b/.gitignore
index afaf047df..e78f7fe9a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@
dist
.env
*.test
+[._]*.sw[a-p]
# rapid property test failure recordings, for local reproduction only
testdata/rapid/
diff --git a/Makefile b/Makefile
index e9065d9ed..bbf06b773 100644
--- a/Makefile
+++ b/Makefile
@@ -1,70 +1,86 @@
-PROTOS_IMAGE ?= trufflesecurity/protos:1.22
+.DEFAULT_GOAL := help
+.PHONY: help
+.PHONY: run
+.PHONY: run-debug
+.PHONY: dogfood
+.PHONY: install
.PHONY: check
.PHONY: lint
+.PHONY: test-failing
.PHONY: test
+.PHONY: test-integration
.PHONY: test-race
-.PHONY: run
-.PHONY: install
+.PHONY: test-detectors
+.PHONY: test-community
+.PHONY: bench
.PHONY: protos
.PHONY: protos-windows
-.PHONY: vendor
-.PHONY: dogfood
+.PHONY: release-protos-image
.PHONY: man
+.PHONY: test-release
+
+PROTOS_IMAGE ?= trufflesecurity/protos:1.22
-dogfood:
+help: ## Display this help message
+ @echo "Usage: make [target]"
+ @echo
+ @echo "Targets:"
+ @awk '/^[a-zA-Z0-9_-]+:.*## / {printf "%s : %s\n", $$1, substr($$0, index($$0, "##") + 3)}' $(MAKEFILE_LIST) | sort | column -t -s ':'
+ @echo
+
+run: ## Run a git scan on this repository
+ CGO_ENABLED=0 go run . git file://. --json
+
+run-debug: ## Run a git scan on this repository with enhanced logging (level 2)
CGO_ENABLED=0 go run . git file://. --json --log-level=2
-install:
+dogfood: run-debug
+
+install: ## Run go install
CGO_ENABLED=0 go install .
-check:
+check: ## Run go fmt and go vet
go fmt $(shell go list ./... | grep -v /vendor/)
go vet $(shell go list ./... | grep -v /vendor/)
-lint:
+lint: ## Run the linter
./scripts/lint.sh
-test-failing:
+test-failing: ## Run tests, displaying only the failures
CGO_ENABLED=0 go test -timeout=5m $(shell go list ./... | grep -v /vendor/) | grep FAIL
-test:
+test: ## Run tests
CGO_ENABLED=0 go test -timeout=5m $(shell go list ./... | grep -v /vendor/)
-test-integration:
+test-integration: ## Run integration tests
CGO_ENABLED=0 go test -timeout=5m -tags=integration $(shell go list ./... | grep -v /vendor/)
-test-race:
+test-race: ## Run the go race condition checker
CGO_ENABLED=1 go test -timeout=5m -race $(shell go list ./... | grep -v /vendor/)
-test-detectors:
+test-detectors: ## Run detector tests
CGO_ENABLED=0 go test -tags=detectors -timeout=5m $(shell go list ./... | grep pkg/detectors)
-test-community:
+test-community: ## Run a subset of tests intended for use by the OSS community
CGO_ENABLED=0 go test -timeout=5m $(shell go list ./... | grep -v /vendor/ | grep -v pkg/sources | grep -v pkg/analyzer/analyzers)
-bench:
+bench: ## Run benchmarks
CGO_ENABLED=0 go test $(shell go list ./pkg/secrets/... | grep -v /vendor/) -benchmem -run=xxx -bench .
-run:
- CGO_ENABLED=0 go run . git file://. --json
-
-run-debug:
- CGO_ENABLED=0 go run . git file://. --json --log-level=2
-
-protos:
+protos: ## Regenerate protocol buffer code
docker run --rm -u "$(shell id -u)" -v "$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))":/pwd "${PROTOS_IMAGE}" bash -c "cd /pwd; /pwd/scripts/gen_proto.sh"
-protos-windows:
+protos-windows: ## Regenerate protocol buffer code on Windows
docker run --rm -v "$(shell cygpath -w $(shell pwd))":/pwd "${PROTOS_IMAGE}" bash -c "cd /pwd; ./scripts/gen_proto.sh"
-release-protos-image:
+release-protos-image: ## Build a Docker image suitable for generating the protocol buffer code
docker buildx build --push --platform=linux/amd64,linux/arm64 \
-t ${PROTOS_IMAGE} -f hack/Dockerfile.protos .
-man:
+man: ## Build man pages
@mkdir -p docs/man
CGO_ENABLED=0 go run . --generate-man-page > docs/man/trufflehog.1
-test-release:
+test-release: ## Test a goreleaser release
goreleaser release --clean --skip=publish,sign --snapshot