-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathMakefile
More file actions
157 lines (140 loc) · 5.49 KB
/
Copy pathMakefile
File metadata and controls
157 lines (140 loc) · 5.49 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
IMAGE_NAME ?= telco-reference
CONTAINER_TOOL ?= podman
# Check that all required dependencies are installed
.PHONY: check-deps
check-deps:
@echo "Checking dependencies for ci-validate..."
@echo ""
@MISSING=0; \
echo -n "Checking yamllint... "; \
if command -v yamllint >/dev/null 2>&1; then \
echo "✓ Found: $$(yamllint --version)"; \
else \
echo "✗ Missing (install: pip install yamllint or brew install yamllint)"; \
MISSING=$$((MISSING+1)); \
fi; \
echo -n "Checking kubectl-cluster_compare... "; \
if command -v kubectl-cluster_compare >/dev/null 2>&1; then \
echo "✓ Found: $$(kubectl-cluster_compare --version 2>&1 | head -1)"; \
else \
echo "✗ Missing (install from: https://github.com/openshift/kube-compare/releases)"; \
MISSING=$$((MISSING+1)); \
fi; \
echo -n "Checking helm-convert... "; \
if command -v helm-convert >/dev/null 2>&1; then \
echo "✓ Found"; \
else \
echo "✗ Missing (install: go install github.com/openshift/kube-compare/addon-tools/helm-convert@latest)"; \
MISSING=$$((MISSING+1)); \
fi; \
echo -n "Checking mcmaker... "; \
if command -v mcmaker >/dev/null 2>&1; then \
echo "✓ Found"; \
else \
echo "✗ Missing (install: go install github.com/lack/mcmaker@latest)"; \
MISSING=$$((MISSING+1)); \
fi; \
echo -n "Checking go... "; \
if command -v go >/dev/null 2>&1; then \
echo "✓ Found: $$(go version)"; \
else \
echo "✗ Missing (install from: https://go.dev/dl/)"; \
MISSING=$$((MISSING+1)); \
fi; \
echo -n "Checking shellcheck... "; \
if command -v shellcheck >/dev/null 2>&1; then \
echo "✓ Found: $$(shellcheck --version 2>&1 | grep version: | head -1)"; \
else \
echo "✗ Missing (install: brew install shellcheck or apt-get install shellcheck)"; \
MISSING=$$((MISSING+1)); \
fi; \
echo ""; \
if [ $$MISSING -eq 0 ]; then \
echo "✅ All dependencies are installed!"; \
echo "You can now run: make ci-validate"; \
exit 0; \
else \
echo "❌ Missing $$MISSING dependencies. Please install them to run ci-validate."; \
exit 1; \
fi
# Basic lint checking
lintCheck:
yamllint -c .yamllint.yaml telco-core/
yamllint -c .yamllint.yaml telco-hub/
yamllint -c .yamllint.yaml telco-ran/
# markdownlint rules, following: https://github.com/openshift/enhancements/blob/master/Makefile
.PHONY: markdownlint-image
markdownlint-image: ## Build local container markdownlint-image
$(CONTAINER_TOOL) image build -f ./hack/Dockerfile.markdownlint --tag $(IMAGE_NAME)-markdownlint:latest ./hack
.PHONY: markdownlint-image-clean
markdownlint-image-clean: ## Remove locally cached markdownlint-image
$(CONTAINER_TOOL) image rm $(IMAGE_NAME)-markdownlint:latest
markdownlint: markdownlint-image ## run the markdown linter
$(CONTAINER_TOOL) run \
--rm=true \
--env RUN_LOCAL=true \
--env VALIDATE_MARKDOWN=true \
--env PULL_BASE_SHA=$(PULL_BASE_SHA) \
-v $$(pwd):/workdir:Z \
$(IMAGE_NAME)-markdownlint:latest
.PHONY: ocp-doc-check
ocp-doc-check: ## Download and run ocp-doc-checker against markdown files
@echo "Detecting platform..."
@OS=$$(uname -s | tr '[:upper:]' '[:lower:]'); \
ARCH=$$(uname -m); \
if [ "$$OS" = "mingw64_nt" ] || [ "$$OS" = "msys_nt" ]; then \
echo "Windows is not supported, skipping ocp-doc-check"; \
exit 0; \
fi; \
if [ "$$ARCH" = "x86_64" ]; then \
ARCH="amd64"; \
elif [ "$$ARCH" = "aarch64" ]; then \
ARCH="arm64"; \
fi; \
BINARY_NAME="ocp-doc-checker-$$OS-$$ARCH"; \
DOWNLOAD_URL="https://github.com/sebrandon1/ocp-doc-checker/releases/latest/download/$$BINARY_NAME"; \
echo "Downloading $$BINARY_NAME from $$DOWNLOAD_URL..."; \
if ! curl -L -f -o ./$$BINARY_NAME $$DOWNLOAD_URL; then \
echo "Failed to download ocp-doc-checker binary"; \
exit 1; \
fi; \
chmod +x ./$$BINARY_NAME; \
echo "Running ocp-doc-checker against repository..."; \
./$$BINARY_NAME -dir . || true; \
rm -f ./$$BINARY_NAME; \
echo "ocp-doc-check completed"
test-kustomize: ## Validate all kustomization.yaml files can build
./hack/test-kustomize.sh
.PHONY: test-shellcheck
test-shellcheck: ## Validate shell scripts with shellcheck
./hack/test-shellcheck.sh
.PHONY: generate-schema-config
generate-schema-config: ## Regenerate hack/crd-schema-config.json from Subscription CRs
python3 hack/generate-schema-config.py
.PHONY: generate-openapi-schemas
generate-openapi-schemas: generate-schema-config ## Regenerate schema.openapi files from CRDs for ACM PolicyGenerator
python3 hack/extract-schema.py --config hack/crd-schema-config.json --component ran \
-o telco-ran/configuration/acmpolicygenerator/schema.openapi
python3 hack/extract-schema.py --config hack/crd-schema-config.json --component core \
-o telco-core/configuration/schema.openapi
.PHONY: check-openapi-schemas
check-openapi-schemas: generate-openapi-schemas ## Verify schema.openapi files are up-to-date
@if ! git diff --exit-code hack/crd-schema-config.json \
telco-ran/configuration/acmpolicygenerator/schema.openapi \
telco-core/configuration/schema.openapi; then \
echo ""; \
echo "ERROR: OpenAPI schema files are out of date."; \
echo "Run 'make generate-openapi-schemas' and commit the result."; \
exit 1; \
fi
ci-validate: lintCheck check-reference-core check-reference-ran check-reference-hub
.PHONY: check-reference-core
check-reference-core:
$(MAKE) -C ./telco-core/configuration check
.PHONY: check-reference-ran
check-reference-ran:
$(MAKE) -C ./telco-ran/configuration check
$(MAKE) -C ./telco-ran/install check
.PHONY: check-reference-hub
check-reference-hub:
$(MAKE) -C ./telco-hub/configuration/reference-crs-kube-compare check