From 049f55d4a10e6359a8a6232e5f3ee402ac350378 Mon Sep 17 00:00:00 2001 From: Alexander Olzem Date: Mon, 27 Apr 2026 13:56:18 +0200 Subject: [PATCH 1/2] fix: restructure makefile and example --- common.mk | 27 +++++++++++++-------------- example/Makefile | 8 +++++++- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/common.mk b/common.mk index 3f16252..135f388 100644 --- a/common.mk +++ b/common.mk @@ -1,4 +1,3 @@ - # Setting SHELL to bash allows bash commands to be executed by recipes. # Options are set to exit when a recipe line exits non-zero or a piped command fails. SHELL = /usr/bin/env bash -o pipefail @@ -66,20 +65,9 @@ help: ## Display this help. clean: rm -rf $(LOCALBIN) -.PHONY: mod -mod: ## Do go mod tidy, download, verify - @$(GO) mod tidy - @$(GO) mod download - @$(GO) mod verify - -## Common linting tasks -.PHONY: golangci-lint -golangci-lint: $(GOLANGCI_LINT) ## run golangci-lint - $(GOLANGCI_LINT) run -v - .PHONY: shellcheck shellcheck: ## run shellcheck - $(SHELLCHECK) $$(git ls-files | grep '.*.sh$$') + $(SHELLCHECK) $$(git ls-files '*\.sh') OSV_SCANNER_CONFIG ?= ./.osv-scanner.toml .PHONY: scan @@ -101,6 +89,17 @@ setup-local-cluster: ## Set up a Kind cluster for local development if it does n $(KIND) create cluster --name $(KIND_CLUSTER) ;; \ esac +##@ Common golang targets +.PHONY: mod +mod: ## run go mod tidy, download, verify + @$(GO) mod tidy + @$(GO) mod download + @$(GO) mod verify + +.PHONY: golangci-lint +golangci-lint: $(GOLANGCI_LINT) ## run golangci-lint + $(GOLANGCI_LINT) run -v + # Install local tools TOOL_LOCK := $(BUILD_PATH)/tools.lock @@ -114,7 +113,7 @@ $(LOCALGOBIN)/%: $(LOCALGOBIN) $(TOOL_LOCK) # ocm cli (sdk v1) cannot be installed with go install because of replace directives in go.mod $(LOCALGOBIN)/ocm: $(LOCALGOBIN) $(TOOL_LOCK) - module=$$(awk "/^ocm / {print \$$2}" $(TOOL_LOCK)); \ + @module=$$(awk "/^ocm / {print \$$2}" $(TOOL_LOCK)); \ version=$$(cut -d@ -f2 <<< $$module); \ test -s $@ && grep -q "$$version" $(LOCALGOBIN)/.ocm-version 2>/dev/null || \ curl -s https://ocm.software/install.sh | VERSION_OCM=$$version bash -s -- $(LOCALGOBIN) && echo $$version > $(LOCALGOBIN)/.ocm-version diff --git a/example/Makefile b/example/Makefile index 1e264f1..df8b07f 100644 --- a/example/Makefile +++ b/example/Makefile @@ -1,5 +1,7 @@ # Include ODC common make targets -DEV_KIT_VERSION := v1.0.2 +# FIXME(user): replace with a static dev-kit release (https://github.com/opendefensecloud/dev-kit/releases) +DEV_KIT_VERSION := refs/heads/main + -include common.mk common.mk: curl --fail -sSL https://raw.githubusercontent.com/opendefensecloud/dev-kit/$(DEV_KIT_VERSION)/common.mk -o common.mk.download && \ @@ -16,3 +18,7 @@ cobra: $(COBRA) scan: echo hello + +fmt: # FIXME(user): Implement the fmt target or disable the pre-commit hook for it (flake.nix) + +lint: # FIXME(user): Implement the lint target or disable the pre-commit hook for it (flake.nix) From ff29eecb3667d73f48da88004ddd5a03ab20c832 Mon Sep 17 00:00:00 2001 From: Alexander Olzem Date: Mon, 27 Apr 2026 13:57:00 +0200 Subject: [PATCH 2/2] feat: add general addlicense target --- common.mk | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common.mk b/common.mk index 135f388..058de66 100644 --- a/common.mk +++ b/common.mk @@ -74,6 +74,11 @@ OSV_SCANNER_CONFIG ?= ./.osv-scanner.toml scan: $(OSV_SCANNER) ## scan for vulnerabilities $(OSV_SCANNER) scan --config $(OSV_SCANNER_CONFIG) -r . +.PHONY: addlicense +addlicense: $(ADDLICENSE) ## Add License headers containing of `license` and `comment` to files matched by `pattern`. + @test -n "$(license)" && test -n "$(comment)" && test -n "$(pattern)" \ + git ls-files '$(pattern)' | xargs -r $(ADDLICENSE) -c '$(comment)' -l '$(license)' -s=only + # Local dev environment .PHONY: setup-local-cluster setup-local-cluster: ## Set up a Kind cluster for local development if it does not exist