-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathMakefile
More file actions
59 lines (48 loc) · 1.52 KB
/
Copy pathMakefile
File metadata and controls
59 lines (48 loc) · 1.52 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
.DEFAULT_GOAL := help
.PHONY: help lint lint-go lint-yaml format test build build-docker action-test clean
## Linting
lint: lint-go lint-yaml ## Run all linters
lint-go: ## Run Go linter (golangci-lint)
@if command -v golangci-lint >/dev/null 2>&1; then \
golangci-lint run ./...; \
else \
echo "golangci-lint not found, skipping"; \
fi
lint-yaml: ## Run YAML linter
@if command -v yamllint >/dev/null 2>&1; then \
if [ -f .yamllint.yml ]; then yamllint -c .yamllint.yml .; else yamllint .; fi; \
else \
echo "yamllint not found, skipping"; \
fi
## Formatting
format: ## Format Go code
gofmt -s -w .
@if command -v goimports >/dev/null 2>&1; then \
goimports -w .; \
else \
echo "goimports not found, skipping"; \
fi
## Testing
test: ## Run Go tests
go test -v ./...
action-test: build-docker ## Run action tests with test playbook
@docker run --rm \
-v $(shell pwd):/github/workspace \
-w /github/workspace \
action-playbook:local \
--playbook tests/basic_playbook.yml \
--inventory tests/hosts.yml \
--galaxy-requirements tests/requirements.yml
## Building
build: ## Build Go binary
CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o main .
build-docker: ## Build Docker image
docker build -t action-playbook:local .
## Cleanup
clean: ## Remove build artifacts
go clean
rm -rf build/ dist/ megalinter-reports/ main
## Help
help: ## Show available targets
@echo "Available targets:"
@grep -E '^[a-zA-Z_-]+:.*?##' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " %-20s %s\n", $$1, $$2}'