forked from DataDog/orchestrion
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
187 lines (152 loc) · 6.18 KB
/
Makefile
File metadata and controls
187 lines (152 loc) · 6.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
.PHONY: all test test-e2e format format/go format/yaml lint lint/action lint/go lint/yaml lint/makefile \
build install dd-trace-go dd-trace-go-setup test-integration \
docs tmp/make-help.txt actionlint yamlfmt gotestfmt ratchet \
ratchet/pin ratchet/update ratchet/check checkmake embedmd help
# Allow overriding via env var `orchestrion_dir` or `ORCHESTRION_DIR`
ORCHESTRION_DIR ?= $(if $(orchestrion_dir),$(orchestrion_dir),$(CURDIR))
DD_TRACE_GO_DIR ?= $(CURDIR)/tmp/dd-trace-go
DDTRACE_INTEGRATION_DIR := $(DD_TRACE_GO_DIR)/internal/orchestrion/_integration
.DEFAULT_GOAL := help
.PHONY: help
help: ## Show this help message
@echo 'Usage: make [target]'
@echo ''
@echo 'Targets:'
@awk 'BEGIN {FS = ":.*?## "} /^[A-Za-z0-9_./-]+:.*?## / {printf " %-20s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
all: build format lint test
build: ## Build orchestrion binary to bin/orchestrion
go build -o bin/orchestrion main.go
install: ## Install orchestrion to $$GOPATH/bin
go install .
format: ## Format Go code and YAML files
format: format/go format/yaml
format/go: ## Format Go code only
format/go: golangci-lint
@echo "Formatting Go code..."
golangci-lint fmt
format/yaml: ## Format YAML files only (excludes testdata)
format/yaml: yamlfmt
@echo "Formatting YAML files..."
yamlfmt -dstar '**/*.yml' '**/*.yaml'
lint: ## Run all linters (Go, YAML, GitHub Actions, Makefiles)
lint: lint/go lint/yaml lint/action lint/makefile
lint/action: ## Lint GitHub Actions workflows
lint/action: actionlint ratchet/check
@echo "Linting GitHub Actions workflows..."
actionlint
lint/go: ## Run golangci-lint on Go code
lint/go: golangci-lint
@echo "Linting Go code..."
golangci-lint run
lint/yaml: ## Lint YAML formatting
lint/yaml: yamlfmt
@echo "Linting YAML files..."
yamlfmt -dstar '**/*.yml' '**/*.yaml'
lint/makefile: ## Lint Makefiles
lint/makefile: checkmake
@echo "Linting Makefiles..."
checkmake --config=.checkmake Makefile $(shell find . -type f \( -name 'Makefile' -o -name 'makefile' -o -name 'GNUmakefile' -o -name '*.mk' \) -not -path './tmp/*' -not -path './_*' -not -path './Makefile')
ratchet/pin: ## Pin GitHub Actions to commit SHAs
ratchet/pin: ratchet
@echo "Pinning GitHub Actions to commit SHAs..."
ratchet pin .github/workflows/*.yml .github/actions/**/action.yml
ratchet/update: ## Update pinned GitHub Actions to latest versions
ratchet/update: ratchet
@echo "Updating pinned GitHub Actions to latest versions..."
ratchet update .github/workflows/*.yml .github/actions/**/action.yml
ratchet/check: ## Verify all GitHub Actions are pinned
ratchet/check: ratchet
@echo "Checking GitHub Actions are pinned..."
ratchet lint .github/workflows/*.yml .github/actions/**/action.yml
docs: ## Update embedded documentation in markdown files
docs: embedmd tmp/make-help.txt
@echo "Updating embedded documentation..."
embedmd -w CONTRIBUTING.md
tmp/make-help.txt: ## Generate make help output for embedding in documentation
tmp/make-help.txt: $(MAKEFILE_LIST)
@mkdir -p tmp
@$(MAKE) --no-print-directory help > tmp/make-help.txt
# Tests
# Integration with dd-trace-go using orchestrion
#
# The following Make targets automate the manual steps below:
#
# console
# $ git clone github.com:DataDog/dd-trace-go # Clone the DataDog/dd-trace-go repository
# $ cd dd-trace-go/internal/orchestrion/_integration # Move into the integration tests directory
# $ go mod edit \ # Use the local copy of orchestrion
# -replace "github.com/DataDog/orchestrion=>${orchestrion_dir}"
# $ go mod tidy # Make sure go.mod & go.sum are up-to-date
# $ go run github.com/DataDog/orchestrion \ # Run integration test suite with orchestrion
# go test -shuffle=on ./...
#
# Usage examples:
# make test-integration # run tests (expects setup done)
# make dd-trace-go-setup # clone + set replace only
dd-trace-go:
@mkdir -p ./tmp
@if [ ! -d "$(DD_TRACE_GO_DIR)/.git" ]; then \
echo "Cloning dd-trace-go (shallow) into $(DD_TRACE_GO_DIR)"; \
git clone --depth 1 --no-tags git@github.com:DataDog/dd-trace-go.git "$(DD_TRACE_GO_DIR)"; \
else \
echo "dd-trace-go already exists at $(DD_TRACE_GO_DIR)"; \
fi
.ONESHELL:
dd-trace-go-setup: dd-trace-go
@echo "Using orchestrion from: $(ORCHESTRION_DIR)"
@echo "Integration dir: $(DDTRACE_INTEGRATION_DIR)"
cd $(DDTRACE_INTEGRATION_DIR)
go mod edit -replace "github.com/DataDog/orchestrion=$(ORCHESTRION_DIR)"
go mod tidy
.ONESHELL:
test: ## Run unit tests
test: gotestfmt
set -euo pipefail
go test -json -v -timeout=5m ./... 2>&1 | tee ./gotest.log | gotestfmt
.ONESHELL:
test-e2e: ## Run end-to-end tests
test-e2e: build
set -euo pipefail
@echo "Running end-to-end tests..."
go test -tags=e2e -v -timeout=10m ./test/e2e/ 2>&1 | tee test-e2e.log
.ONESHELL:
test-integration: ## Run integration tests with dd-trace-go
test-integration: dd-trace-go-setup
cd $(DDTRACE_INTEGRATION_DIR)
go run github.com/DataDog/orchestrion go test -v -shuffle=on -failfast ./... | tee $(ORCHESTRION_DIR)/test-integration.log
# Install tools
gotestfmt:
@if ! command -v gotestfmt >/dev/null 2>&1; then \
echo "Installing gotestfmt..."; \
go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest; \
fi
golangci-lint:
@if ! command -v golangci-lint >/dev/null 2>&1; then \
echo "Installing golangci-lint..."; \
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest; \
fi
actionlint:
@if ! command -v actionlint >/dev/null 2>&1; then \
echo "Installing actionlint..."; \
go install github.com/rhysd/actionlint/cmd/actionlint@latest; \
fi
yamlfmt:
@if ! command -v yamlfmt >/dev/null 2>&1; then \
echo "Installing yamlfmt..."; \
go install github.com/google/yamlfmt/cmd/yamlfmt@latest; \
fi
ratchet:
@if ! command -v ratchet >/dev/null 2>&1; then \
echo "Installing ratchet..."; \
go install github.com/sethvargo/ratchet@latest; \
fi
checkmake:
@if ! command -v checkmake >/dev/null 2>&1; then \
echo "Installing checkmake..."; \
go install github.com/checkmake/checkmake/cmd/checkmake@latest; \
fi
embedmd:
@if ! command -v embedmd >/dev/null 2>&1; then \
echo "Installing embedmd..."; \
go install github.com/campoy/embedmd@latest; \
fi