-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathMakefile
More file actions
184 lines (161 loc) · 6.24 KB
/
Makefile
File metadata and controls
184 lines (161 loc) · 6.24 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
# Makefile for Siderolabs documentation
# Variables
MINT_IMAGE := ghcr.io/siderolabs/docs-mint:latest
CONTAINER_NAME := docs-preview
PORT := 3000
DOCS_GEN_IMAGE := ghcr.io/siderolabs/docs-gen:latest
DOCS_CONVERT_IMAGE := ghcr.io/siderolabs/docs-convert:latest
TALOSCTL_IMAGE := ghcr.io/siderolabs/talosctl:v1.13.0-beta.0
TALOS_VERSION := v1.13
VALE_IMAGE := jdkato/vale:latest
VALE_CONFIG ?= .vale.ini
# Default target
.PHONY: help
help: ## Show this help message
@echo "Available targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
.PHONY: build-mint
build-mint: ## Build the Mintlify documentation container locally
docker build -t $(MINT_IMAGE) ./mintlify
.PHONY: docs-preview preview
docs-preview: ## Build and run the documentation preview server
docker run --rm -it \
--name $(CONTAINER_NAME) \
-p $(PORT):$(PORT) \
-v $(PWD)/public:/docs \
$(MINT_IMAGE) dev
preview: docs-preview ## Alias for docs-preview
.PHONY: broken-links
broken-links: ## Run broken links check
docker run --rm -t \
-v $(PWD)/public:/docs \
$(MINT_IMAGE) broken-links
docs.json: common.yaml omni.yaml ## Generate and validate docs.json from multiple config files
docker pull $(DOCS_GEN_IMAGE)
docker run --rm -v $(PWD):/workspace -w /workspace $(DOCS_GEN_IMAGE) \
common.yaml \
talos-v1.12.yaml \
talos-v1.11.yaml \
talos-v1.10.yaml \
talos-v1.9.yaml \
talos-v1.8.yaml \
talos-v1.7.yaml \
talos-v1.6.yaml \
talos-v1.13.yaml \
omni.yaml \
kubernetes-guides.yaml \
> public/docs.json
docs.json-local: common.yaml omni.yaml docs-gen/main.go ## Generate docs.json using local Go build
cd docs-gen && go run . \
../common.yaml \
../talos-v1.12.yaml \
../talos-v1.11.yaml \
../talos-v1.10.yaml \
../talos-v1.9.yaml \
../talos-v1.8.yaml \
../talos-v1.7.yaml \
../talos-v1.6.yaml \
../talos-v1.13.yaml \
../omni.yaml \
../kubernetes-guides.yaml \
> ../public/docs.json
.PHONY: check-missing
check-missing: ## Check for MDX files not included in config files
docker run --rm -v $(PWD):/workspace -w /workspace $(DOCS_GEN_IMAGE) --detect-missing \
common.yaml \
talos-v1.12.yaml \
talos-v1.11.yaml \
talos-v1.10.yaml \
talos-v1.9.yaml \
talos-v1.8.yaml \
talos-v1.7.yaml \
talos-v1.6.yaml \
talos-v1.13.yaml \
omni.yaml \
kubernetes-guides.yaml
.PHONY: check-missing-local
check-missing-local: ## Check for missing files using local Go build
cd docs-gen && go run . --detect-missing \
../common.yaml \
../talos-v1.12.yaml \
../talos-v1.11.yaml \
../talos-v1.10.yaml \
../talos-v1.9.yaml \
../talos-v1.8.yaml \
../talos-v1.7.yaml \
../talos-v1.6.yaml \
../talos-v1.13.yaml \
../omni.yaml \
../kubernetes-guides.yaml
.PHONY: generate-deps
generate-deps: ## Install Go dependencies for the generator
cd docs-gen && go mod tidy
.PHONY: build-docs-gen-container
build-docs-gen-container: ## Build the docs-gen container locally
docker build -t $(DOCS_GEN_IMAGE) ./docs-gen
.PHONY: build-docs-convert-container
build-docs-convert-container: ## Build the docs-convert container locally
docker build -t $(DOCS_CONVERT_IMAGE) ./docs-convert
.PHONY: test-docs-gen
test-docs-gen: ## Run tests for the docs-gen utility
cd docs-gen && go test -v
.PHONY: test-docs-gen-coverage
test-docs-gen-coverage: ## Run tests with coverage report
cd docs-gen && go test -v -coverprofile=coverage.out \
&& go tool cover -html=coverage.out -o coverage.html
.PHONY: test-docs-gen-race
test-docs-gen-race: ## Run tests with race detection
cd docs-gen && go test -v -race
.PHONY: test-all
test-all: test-docs-gen ## Run all tests
.PHONY: generate-talos-reference
generate-talos-reference: ## Generate Talos reference docs and convert to MDX
@echo "Generating Talos reference documentation..."
docker pull $(TALOSCTL_IMAGE)
docker pull $(DOCS_CONVERT_IMAGE)
mkdir -p _out/docs
docker run --rm -u $(shell id -u):$(shell id -g) -v $(PWD)/_out/docs:/docs $(TALOSCTL_IMAGE) docs /docs
@echo "Converting generated docs to MDX..."
docker run --rm -u $(shell id -u):$(shell id -g) -v $(PWD):/workspace $(DOCS_CONVERT_IMAGE) \
/workspace/_out/docs /workspace/public/talos/$(TALOS_VERSION)/reference/configuration/
rm -rf _out/docs
@echo "Reference documentation generated in public/talos/$(TALOS_VERSION)/reference/configuration"
.PHONY: generate-talos-reference-local
generate-talos-reference-local: ## Generate Talos reference docs using local Go build
@echo "Generating Talos reference documentation..."
docker pull $(TALOSCTL_IMAGE)
mkdir -p _out/docs
docker run --rm -u $(shell id -u):$(shell id -g) -v $(PWD)/_out/docs:/docs $(TALOSCTL_IMAGE) docs /docs
@echo "Converting generated docs to MDX..."
cd docs-convert && go run main.go ../_out/docs ../public/talos/$(TALOS_VERSION)/reference/configuration/
@echo "Reference documentation generated in public/talos/$(TALOS_VERSION)/reference/configuration/"
OMNI_CONFIG_SCHEMA_URL ?= https://raw.githubusercontent.com/siderolabs/omni/refs/heads/main/internal/pkg/config/schema.json
OMNI_CONFIG_REF_PATH := public/omni/reference/omni-configuration.mdx
.PHONY: generate-omni-config-reference
generate-omni-config-reference: ## Generate Omni configuration reference docs from JSON schema
@echo "Generating Omni configuration reference..."
cd omni-config-gen && go run . $(OMNI_CONFIG_SCHEMA_URL) > ../$(OMNI_CONFIG_REF_PATH)
@echo "Reference documentation generated at $(OMNI_CONFIG_REF_PATH)"
.PHONY: vale
vale: ## Run Vale on a file or directory: make vale DOC=public/path/to/file.mdx
@if [ -z "$(DOC)" ]; then \
echo "Usage: make vale DOC=public/path/or/file.mdx"; \
exit 1; \
fi
@if [ ! -f "$(VALE_CONFIG)" ]; then \
echo "$(VALE_CONFIG) not found at repo root."; \
exit 1; \
fi
@echo "Running Vale on $(DOC)"
docker run --rm -v $(PWD):/work -w /work $(VALE_IMAGE) \
--config="$(VALE_CONFIG)" $(VALE_ARGS) "$(DOC)"
.PHONY: vale-changed
vale-changed: ## Run Vale on changed file vs HEAD
@files="$$(git diff --name-only --diff-filter=AM HEAD | grep -E '\.mdx?$$|\.md$$' || true)"; \
if [ -z "$$files" ]; then \
echo "No changed Markdown/MDX files."; \
exit 0; \
fi; \
echo "Linting changed files:" $$files; \
docker run --rm -v $(PWD):/work -w /work $(VALE_IMAGE) \
--config="$(VALE_CONFIG)" $(VALE_ARGS) $$files