-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
133 lines (104 loc) · 3.59 KB
/
Copy pathMakefile
File metadata and controls
133 lines (104 loc) · 3.59 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
# Primary build tools and paths
PYTHON=python3
GO=go
VENV=.venv
MKDOCS=mkdocs
PIP_COMPILE=pip-compile
SKAFFOLD=skaffold
REQUIREMENTS_IN=docs/requirements.in
REQUIREMENTS_TXT=docs/requirements.txt
CRD_OUT=config/crd
BUILD_TOOLS_DIR=.build
BUILD_TOOLS_DIR_BIN=$(BUILD_TOOLS_DIR)/bin
# CRD API versions to generate CRDs for
CRD_VERSIONS= \
v1alpha1
# List of CRD YAMLs expected
CRD_YAMLS = \
config/crd/v1alpha1/blackstart.pezops.github.io_workflows.yaml
CRD_CHART_DIR=charts/blackstart/crds
CRD_CHART_SRC=config/crd/v1alpha1/blackstart.pezops.github.io_workflows.yaml
CRD_CHART_DST=$(CRD_CHART_DIR)/blackstart.pezops.github.io_workflows-v1alpha1.yaml
# Controller-gen: https://github.com/kubernetes-sigs/controller-tools
CONTROLLER_GEN_VERSION=v0.19.0
CONTROLLER_GEN=$(BUILD_TOOLS_DIR)/bin/controller-gen
# Prettier: https://prettier.io
PRETTIER_VERSION=3.6.2
PRETTIER_DIR=$(BUILD_TOOLS_DIR)/tools/prettier
PRETTIER=$(BUILD_TOOLS_DIR)/bin/prettier
# GolangCI-Lint: https://golangci-lint.run
GOLANGCI_LINT_VERSION=v2.4.0
GOLANGCI_LINT=$(BUILD_TOOLS_DIR)/bin/golangci-lint
RELEASE ?= 0.0.0-dev
.PHONY: build docs-deps docs-serve crds sync-chart-crds docs-modules-gen docs-format docs-venv utils blackstart clean
build: utils crds docs lint test
blackstart:
$(GO) build -o blackstart ./cmd/blackstart
## Utils
utils: controller-gen prettier golangci-lint
controller-gen: $(CONTROLLER_GEN)
$(CONTROLLER_GEN):
@mkdir -p $(BUILD_TOOLS_DIR_BIN)
GOBIN="$(abspath $(BUILD_TOOLS_DIR_BIN))" go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_GEN_VERSION)
prettier: $(PRETTIER)
$(PRETTIER):
@if ! command -v npm >/dev/null 2>&1; then \
echo "Error: npm is not installed. Please install Node.js and npm."; \
exit 1; \
fi
@if ! command -v node >/dev/null 2>&1; then \
echo "Error: node is not installed. Please install Node.js and npm."; \
exit 1; \
fi
@mkdir -p $(BUILD_TOOLS_DIR_BIN)
@mkdir -p $(PRETTIER_DIR)
npm install --prefix $(PRETTIER_DIR) prettier@$(PRETTIER_VERSION)
ln -sf ../tools/prettier/node_modules/.bin/prettier $(PRETTIER)
golangci-lint: $(GOLANGCI_LINT)
$(GOLANGCI_LINT):
@mkdir -p $(BUILD_TOOLS_DIR_BIN)
GOBIN="$(abspath $(BUILD_TOOLS_DIR_BIN))" go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
## Code generation
gen: crds docs
## Code Linting
lint: golangci-lint gen
$(GOLANGCI_LINT) run -v ./...
## Testing
test: lint
$(GO) test -v ./...
crds: controller-gen
@mkdir -p $(CRD_OUT)
@for api in $(CRD_VERSIONS); do \
echo "Generating CRDs for API version $$api"; \
$(CONTROLLER_GEN) crd paths=./api/$$api/... output:crd:dir=$(CRD_OUT)/$$api; \
$(CONTROLLER_GEN) object paths=./api/$$api/...; \
done
@$(MAKE) sync-chart-crds
sync-chart-crds:
@mkdir -p $(CRD_CHART_DIR)
@cp "$(CRD_CHART_SRC)" "$(CRD_CHART_DST)"
@echo "Synced chart CRD: $(CRD_CHART_DST)"
docs: docs-modules-gen docs-format docs-requirements
docs-modules-gen:
$(GO) run internal/module_docs/module_docs.go
docs-format: prettier
$(PRETTIER) --prose-wrap always --print-width 100 --write docs
docs-requirements: $(REQUIREMENTS_TXT)
$(REQUIREMENTS_TXT): $(REQUIREMENTS_IN) | docs-venv
$(PYTHON) -m pip install --upgrade pip pip-tools
$(PIP_COMPILE) --generate-hashes $(REQUIREMENTS_IN)
docs-deps: docs-venv docs-requirements
$(PYTHON) -m pip install -r $(REQUIREMENTS_TXT)
docs-venv:
@if [ ! -d $(VENV) ]; then \
$(PYTHON) -m venv $(VENV); \
fi
. $(VENV)/bin/activate; \
$(PYTHON) -m pip install --upgrade pip; \
docs-serve: docs-venv
. $(VENV)/bin/activate; \
$(MKDOCS) serve
clean:
@rm -rf $(VENV) $(BUILD_TOOLS_DIR)
dev: build
$(SKAFFOLD) dev