Skip to content

Commit e6ca517

Browse files
committed
chore(checks): Add Makefile checks
Signed-off-by: Kemal Akkoyun <[email protected]>
1 parent 53b84e7 commit e6ca517

File tree

5 files changed

+47
-2
lines changed

5 files changed

+47
-2
lines changed

.checkmake

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[default]
2+
# Checkmake configuration for dd-trace-go
3+
# This file configures rules for Makefile linting
4+
5+
# Disable minphony rule - not all utility Makefiles need standard targets
6+
[minphony]
7+
disabled = true
8+
9+
# Increase max body length for complex targets like help
10+
[maxbodylength]
11+
maxBodyLength = 20

.github/workflows/static-checks.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ jobs:
5555
- name: Copyright
5656
run: |
5757
go run ./scripts/check_copyright.go
58+
- name: Checkmake
59+
run: |
60+
export PATH="${{ github.workspace }}/bin:${PATH}"
61+
./scripts/lint.sh --misc
5862
5963
check-modules:
6064
runs-on: ubuntu-latest

Makefile

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,34 @@ help: ## Show this help message
1313
all: tools-install generate lint test ## Run complete build pipeline (tools, generate, lint, test)
1414

1515
.PHONY: tools-install
16-
tools-install: ## Install development tools
16+
tools-install: tools-install/checkmake ## Install development tools
1717
@./scripts/install_tools.sh --tools-dir $(TOOLS) --bin-dir $(BIN)
1818

19+
# checkmake is installed as a pre-built binary rather than via go install
20+
# because it requires Go 1.25+, which would force an upgrade of our _tools module.
21+
# We keep the _tools module on Go 1.24.0 to match our main project requirements.
22+
# For platforms without pre-built binaries, we fall back to building from source.
23+
.PHONY: tools-install/checkmake
24+
tools-install/checkmake: ## Install checkmake binary for Makefile linting
25+
@mkdir -p $(BIN)
26+
@if [ ! -f $(BIN)/checkmake ]; then \
27+
echo "Installing checkmake..."; \
28+
CHECKMAKE_VERSION=0.2.2; \
29+
OS=$$(uname -s | tr '[:upper:]' '[:lower:]'); \
30+
ARCH=$$(uname -m); \
31+
if [ "$$ARCH" = "x86_64" ]; then ARCH="amd64"; fi; \
32+
if [ "$$ARCH" = "aarch64" ]; then ARCH="arm64"; fi; \
33+
BINARY="checkmake-$$CHECKMAKE_VERSION.$$OS.$$ARCH"; \
34+
if curl -sSfL -o $(BIN)/checkmake "https://github.com/checkmake/checkmake/releases/download/$$CHECKMAKE_VERSION/$$BINARY" 2>/dev/null; then \
35+
chmod +x $(BIN)/checkmake; \
36+
echo "checkmake $$CHECKMAKE_VERSION installed from pre-built binary"; \
37+
else \
38+
echo "Pre-built binary not available for $$OS/$$ARCH, building from source..."; \
39+
GOBIN=$(abspath $(BIN)) go install github.com/checkmake/checkmake/cmd/checkmake@latest; \
40+
echo "checkmake installed from source"; \
41+
fi; \
42+
fi
43+
1944
.PHONY: clean
2045
clean: ## Clean build artifacts
2146
rm -rvf coverprofile.txt *.out *.test vendor core_coverage.txt gotestsum-*
@@ -44,6 +69,10 @@ lint/go/fix: tools-install ## Fix linting issues automatically
4469
lint/shell: tools-install ## Run shell script linting checks
4570
$(BIN_PATH) ./scripts/lint.sh --shell
4671

72+
.PHONY: lint/misc
73+
lint/misc: tools-install ## Run miscellaneous linting checks (copyright, Makefiles)
74+
$(BIN_PATH) ./scripts/lint.sh --misc
75+
4776
.PHONY: format
4877
format: tools-install ## Format code
4978
$(BIN_PATH) ./scripts/format.sh --all

scripts/install_tools.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ run "cd \"$TOOLS_DIR_ABS\" && GOWORK=$GOWORK go mod download"
9898

9999
# Install tools
100100
message "Installing tools to $BIN_DIR_ABS..."
101-
run "cd \"$TOOLS_DIR_ABS\" && GOWORK=$GOWORK GOBIN=\"$BIN_DIR_ABS\" go install \$(grep -E '^[[:space:]]*_[[:space:]]+\".*\"' tools.go | awk -F'\"' '{print \$2}')"
101+
run "cd \"$TOOLS_DIR_ABS\" && GOWORK=$GOWORK GOBIN=\"$BIN_DIR_ABS\" go install -v \$(grep -E '^[[:space:]]*_[[:space:]]+\".*\"' tools.go | awk -F'\"' '{print \$2}')"
102102

103103
message "Tools installation completed successfully"
104104
message "Installed tools are available in: $BIN_DIR"

scripts/lint.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ lint_shell_files() {
5858
lint_misc_files() {
5959
message "Running miscellaneous linters..."
6060
run "go run ./scripts/check_copyright.go"
61+
run "checkmake --config=.checkmake Makefile scripts/autoreleasetagger/Makefile scripts/apiextractor/Makefile profiler/internal/fastdelta/Makefile"
6162
}
6263

6364
# Parse command line arguments

0 commit comments

Comments
 (0)