-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathMakefile
More file actions
87 lines (72 loc) · 1.99 KB
/
Makefile
File metadata and controls
87 lines (72 loc) · 1.99 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
# Colors for output
GREEN := $(shell printf '\033[32m')
RESET := $(shell printf '\033[0m')
BOLD := $(shell printf '\033[1m')
# Shell source files - use shfmt to find them (respects .editorconfig)
SHELL_SRC_FILES := $(shell shfmt -f .)
.PHONY: all
all: build
.PHONY: build
build:
go build ./...
.PHONY: test
test:
go test ./... -race
.PHONY: test/integration
test/integration:
go test -tags=integration -v -timeout=8m ./...
.PHONY: lint
lint: lint/go lint/shellcheck
.PHONY: lint/go
lint/go:
golangci-lint run --timeout=5m
.PHONY: lint/shellcheck
lint/shellcheck: $(SHELL_SRC_FILES)
echo "--- shellcheck"
shellcheck --external-sources $(SHELL_SRC_FILES)
.PHONY: fmt
fmt: fmt/go fmt/shfmt
.PHONY: fmt/go
fmt/go:
go fmt ./...
.PHONY: fmt/shfmt
fmt/shfmt: $(SHELL_SRC_FILES)
ifdef FILE
# Format single shell script
if [[ -f "$(FILE)" ]] && [[ "$(FILE)" == *.sh ]]; then \
echo "$(GREEN)==>$(RESET) $(BOLD)fmt/shfmt$(RESET) $(FILE)"; \
shfmt -w "$(FILE)"; \
fi
else
echo "$(GREEN)==>$(RESET) $(BOLD)fmt/shfmt$(RESET)"
# Only do diff check in CI, errors on diff.
ifdef CI
shfmt -d $(SHELL_SRC_FILES)
else
shfmt -w $(SHELL_SRC_FILES)
endif
endif
.PHONY: clean
clean:
rm -f coder-logstream-kube
.PHONY: kind/create
kind/create:
./scripts/kind-setup.sh create
.PHONY: kind/delete
kind/delete:
./scripts/kind-setup.sh delete
.PHONY: help
help:
@echo "Available targets:"
@echo " build - Build the project"
@echo " test - Run unit tests"
@echo " test/integration - Run integration tests (requires KinD cluster)"
@echo " lint - Run all linters"
@echo " lint/go - Run golangci-lint"
@echo " lint/shellcheck - Run shellcheck on shell scripts"
@echo " fmt - Format all code"
@echo " fmt/go - Format Go code"
@echo " fmt/shfmt - Format shell scripts"
@echo " kind/create - Create KinD cluster for integration tests"
@echo " kind/delete - Delete KinD cluster"
@echo " clean - Remove build artifacts"