From 8b11ca5887c105819f5d60431467e3d27ec14f85 Mon Sep 17 00:00:00 2001 From: Kemal Akkoyun Date: Thu, 6 Nov 2025 12:47:54 +0100 Subject: [PATCH] chore(checks): Add Makefile checks Signed-off-by: Kemal Akkoyun --- .checkmake | 11 ++++++++++ .github/workflows/static-checks.yml | 4 ++++ Makefile | 31 ++++++++++++++++++++++++++++- README.md | 2 ++ scripts/README.md | 2 ++ scripts/install_tools.sh | 2 +- scripts/lint.sh | 1 + 7 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 .checkmake diff --git a/.checkmake b/.checkmake new file mode 100644 index 0000000000..e35e69c3e1 --- /dev/null +++ b/.checkmake @@ -0,0 +1,11 @@ +[default] +# Checkmake configuration for dd-trace-go +# This file configures rules for Makefile linting + +# Disable minphony rule - not all utility Makefiles need standard targets +[minphony] +disabled = true + +# Increase max body length for complex targets like help +[maxbodylength] +maxBodyLength = 20 diff --git a/.github/workflows/static-checks.yml b/.github/workflows/static-checks.yml index 9695775b29..8da25f1839 100644 --- a/.github/workflows/static-checks.yml +++ b/.github/workflows/static-checks.yml @@ -55,6 +55,10 @@ jobs: - name: Copyright run: | go run ./scripts/check_copyright.go + - name: Run miscellaneous linters (copyright, Makefiles) + run: | + export PATH="${{ github.workspace }}/bin:${PATH}" + make lint/misc check-modules: runs-on: ubuntu-latest diff --git a/Makefile b/Makefile index c217f263ea..dc2b35f6d9 100644 --- a/Makefile +++ b/Makefile @@ -13,9 +13,34 @@ help: ## Show this help message all: tools-install generate lint test ## Run complete build pipeline (tools, generate, lint, test) .PHONY: tools-install -tools-install: ## Install development tools +tools-install: tools-install/checkmake ## Install development tools @./scripts/install_tools.sh --tools-dir $(TOOLS) --bin-dir $(BIN) +# checkmake is installed as a pre-built binary rather than via go install +# because it requires Go 1.25+, which would force an upgrade of our _tools module. +# We keep the _tools module on Go 1.24.0 to match our main project requirements. +# For platforms without pre-built binaries, we fall back to building from source. +.PHONY: tools-install/checkmake +tools-install/checkmake: ## Install checkmake binary for Makefile linting + @mkdir -p $(BIN) + @if [ ! -f $(BIN)/checkmake ]; then \ + echo "Installing checkmake..."; \ + CHECKMAKE_VERSION=0.2.2; \ + OS=$$(uname -s | tr '[:upper:]' '[:lower:]'); \ + ARCH=$$(uname -m); \ + if [ "$$ARCH" = "x86_64" ]; then ARCH="amd64"; fi; \ + if [ "$$ARCH" = "aarch64" ]; then ARCH="arm64"; fi; \ + BINARY="checkmake-$$CHECKMAKE_VERSION.$$OS.$$ARCH"; \ + if curl -sSfL -o $(BIN)/checkmake "https://github.com/checkmake/checkmake/releases/download/$$CHECKMAKE_VERSION/$$BINARY" 2>/dev/null; then \ + chmod +x $(BIN)/checkmake; \ + echo "checkmake $$CHECKMAKE_VERSION installed from pre-built binary"; \ + else \ + echo "Pre-built binary not available for $$OS/$$ARCH, building from source..."; \ + GOBIN=$(abspath $(BIN)) go install github.com/checkmake/checkmake/cmd/checkmake@latest; \ + echo "checkmake installed from source"; \ + fi; \ + fi + .PHONY: clean clean: ## Clean build artifacts rm -rvf coverprofile.txt *.out *.test vendor core_coverage.txt gotestsum-* @@ -44,6 +69,10 @@ lint/go/fix: tools-install ## Fix linting issues automatically lint/shell: tools-install ## Run shell script linting checks $(BIN_PATH) ./scripts/lint.sh --shell +.PHONY: lint/misc +lint/misc: tools-install ## Run miscellaneous linting checks (copyright, Makefiles) + $(BIN_PATH) ./scripts/lint.sh --misc + .PHONY: format format: tools-install ## Format code $(BIN_PATH) ./scripts/format.sh --all diff --git a/README.md b/README.md index 01069a2224..16bc6ace0e 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ Targets: help Show this help message all Run complete build pipeline (tools, generate, lint, test) tools-install Install development tools + tools-install/checkmake Install checkmake binary for Makefile linting clean Clean build artifacts clean-all Clean everything including tools and temporary files generate Run code generation @@ -73,6 +74,7 @@ Targets: lint/go Run Go linting checks lint/go/fix Fix linting issues automatically lint/shell Run shell script linting checks + lint/misc Run miscellaneous linting checks (copyright, Makefiles) format Format code format/shell install shfmt test Run all tests (core, integration, contrib) diff --git a/scripts/README.md b/scripts/README.md index 54d17421c2..7b98275129 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -33,6 +33,7 @@ Targets: help Show this help message all Run complete build pipeline (tools, generate, lint, test) tools-install Install development tools + tools-install/checkmake Install checkmake binary for Makefile linting clean Clean build artifacts clean-all Clean everything including tools and temporary files generate Run code generation @@ -40,6 +41,7 @@ Targets: lint/go Run Go linting checks lint/go/fix Fix linting issues automatically lint/shell Run shell script linting checks + lint/misc Run miscellaneous linting checks (copyright, Makefiles) format Format code format/shell install shfmt test Run all tests (core, integration, contrib) diff --git a/scripts/install_tools.sh b/scripts/install_tools.sh index f90b281975..19264a53db 100755 --- a/scripts/install_tools.sh +++ b/scripts/install_tools.sh @@ -98,7 +98,7 @@ run "cd \"$TOOLS_DIR_ABS\" && GOWORK=$GOWORK go mod download" # Install tools message "Installing tools to $BIN_DIR_ABS..." -run "cd \"$TOOLS_DIR_ABS\" && GOWORK=$GOWORK GOBIN=\"$BIN_DIR_ABS\" go install \$(grep -E '^[[:space:]]*_[[:space:]]+\".*\"' tools.go | awk -F'\"' '{print \$2}')" +run "cd \"$TOOLS_DIR_ABS\" && GOWORK=$GOWORK GOBIN=\"$BIN_DIR_ABS\" go install -v \$(grep -E '^[[:space:]]*_[[:space:]]+\".*\"' tools.go | awk -F'\"' '{print \$2}')" message "Tools installation completed successfully" message "Installed tools are available in: $BIN_DIR" diff --git a/scripts/lint.sh b/scripts/lint.sh index 2c21ecc4f3..9f58cb1124 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -58,6 +58,7 @@ lint_shell_files() { lint_misc_files() { message "Running miscellaneous linters..." run "go run ./scripts/check_copyright.go" + run "checkmake --config=.checkmake Makefile scripts/autoreleasetagger/Makefile scripts/apiextractor/Makefile profiler/internal/fastdelta/Makefile" } # Parse command line arguments