Skip to content

Commit be8a683

Browse files
committed
Initial step to refactor the CI
1 parent 7ec4913 commit be8a683

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+10067
-0
lines changed

pipelines/Makefile

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
# Makefile for RHDH CI/CD Pipeline
2+
# This is a convenience wrapper around the main.sh entry point
3+
4+
.DEFAULT_GOAL := help
5+
SHELL := /bin/bash
6+
7+
# Colors for output
8+
CYAN := \033[0;36m
9+
GREEN := \033[0;32m
10+
YELLOW := \033[0;33m
11+
RED := \033[0;31m
12+
RESET := \033[0m
13+
14+
# ============================================================================
15+
# Help Target
16+
# ============================================================================
17+
18+
.PHONY: help
19+
help: ## Show this help message
20+
@echo "$(CYAN)RHDH CI/CD Pipeline - Available Targets$(RESET)"
21+
@echo ""
22+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
23+
sort | \
24+
awk 'BEGIN {FS = ":.*?## "}; {printf " $(GREEN)%-30s$(RESET) %s\n", $$1, $$2}'
25+
@echo ""
26+
@echo "$(YELLOW)Examples:$(RESET)"
27+
@echo " make ocp-pull # Run OCP Pull tests"
28+
@echo " make validate # Validate pipeline configuration"
29+
@echo " make clean # Clean up test resources"
30+
31+
# ============================================================================
32+
# Job Execution
33+
# ============================================================================
34+
35+
.PHONY: ocp-pull
36+
ocp-pull: ## Run OCP Pull request tests
37+
@echo "$(CYAN)Running OCP Pull tests...$(RESET)"
38+
@./main.sh
39+
40+
.PHONY: run
41+
run: ## Run the pipeline (alias for main.sh)
42+
@./main.sh
43+
44+
# ============================================================================
45+
# Development Targets
46+
# ============================================================================
47+
48+
.PHONY: validate
49+
validate: ## Validate all shell scripts syntax
50+
@echo "$(CYAN)Validating shell scripts...$(RESET)"
51+
@bash -n main.sh && echo "$(GREEN)$(RESET) main.sh"
52+
@for file in core/*.sh; do \
53+
bash -n "$$file" && echo "$(GREEN)$(RESET) $$file"; \
54+
done
55+
@find modules -name '*.sh' -type f | while read -r file; do \
56+
bash -n "$$file" && echo "$(GREEN)$(RESET) $$file"; \
57+
done
58+
@find jobs -name '*.sh' -type f | while read -r file; do \
59+
bash -n "$$file" && echo "$(GREEN)$(RESET) $$file"; \
60+
done
61+
@for file in scripts/*.sh; do \
62+
bash -n "$$file" && echo "$(GREEN)$(RESET) $$file"; \
63+
done
64+
@echo "$(GREEN)All scripts passed syntax validation$(RESET)"
65+
66+
.PHONY: lint
67+
lint: ## Lint all shell scripts with shellcheck (requires shellcheck)
68+
@echo "$(CYAN)Linting shell scripts with shellcheck...$(RESET)"
69+
@if ! command -v shellcheck &> /dev/null; then \
70+
echo "$(RED)shellcheck not found. Install with: brew install shellcheck$(RESET)"; \
71+
exit 1; \
72+
fi
73+
@find . -name '*.sh' -type f | xargs shellcheck || \
74+
echo "$(YELLOW)Some linting issues found. Review and fix as needed.$(RESET)"
75+
76+
.PHONY: test-integration
77+
test-integration: ## Run integration tests
78+
@echo "$(CYAN)Running integration tests...$(RESET)"
79+
@if [ -f "../test_integration.sh" ]; then \
80+
bash ../test_integration.sh; \
81+
else \
82+
echo "$(YELLOW)Integration test script not found$(RESET)"; \
83+
fi
84+
85+
.PHONY: check-prereqs
86+
check-prereqs: ## Check if all required tools are installed
87+
@echo "$(CYAN)Checking prerequisites...$(RESET)"
88+
@if [ -f "scripts/validate-prerequisites.sh" ]; then \
89+
./scripts/validate-prerequisites.sh; \
90+
else \
91+
echo "$(YELLOW)Prerequisites validation script not found$(RESET)"; \
92+
echo "Checking manually..."; \
93+
which bash || echo "$(RED)✗ bash not found$(RESET)"; \
94+
which oc || echo "$(YELLOW)⚠ oc not found (required for OCP)$(RESET)"; \
95+
which helm || echo "$(YELLOW)⚠ helm not found$(RESET)"; \
96+
which kubectl || echo "$(YELLOW)⚠ kubectl not found$(RESET)"; \
97+
which yq || echo "$(YELLOW)⚠ yq not found$(RESET)"; \
98+
which jq || echo "$(YELLOW)⚠ jq not found$(RESET)"; \
99+
fi
100+
101+
# ============================================================================
102+
# Cleanup Targets
103+
# ============================================================================
104+
105+
.PHONY: clean
106+
clean: ## Clean up test resources and temporary files
107+
@echo "$(CYAN)Cleaning up test resources...$(RESET)"
108+
@./scripts/cleanup.sh
109+
110+
.PHONY: clean-artifacts
111+
clean-artifacts: ## Clean artifacts but keep namespaces
112+
@echo "$(CYAN)Cleaning artifacts...$(RESET)"
113+
@./scripts/cleanup.sh --skip-namespaces
114+
115+
.PHONY: clean-keep-artifacts
116+
clean-keep-artifacts: ## Clean namespaces but keep artifacts for analysis
117+
@echo "$(CYAN)Cleaning namespaces (keeping artifacts)...$(RESET)"
118+
@./scripts/cleanup.sh --keep-artifacts
119+
120+
.PHONY: clean-local-artifacts
121+
clean-local-artifacts: ## Clean local artifact directories (shared_dir and artifact_dir)
122+
@echo "$(CYAN)Cleaning local artifact directories...$(RESET)"
123+
@rm -rf shared_dir artifact_dir
124+
@echo "$(GREEN)Local artifacts cleaned$(RESET)"
125+
126+
# ============================================================================
127+
# Documentation Targets
128+
# ============================================================================
129+
130+
.PHONY: docs
131+
docs: ## Display main documentation
132+
@cat README.md
133+
134+
.PHONY: architecture
135+
architecture: ## Display architecture review
136+
@if [ -f "ARCHITECTURE_REVIEW.md" ]; then \
137+
cat ARCHITECTURE_REVIEW.md; \
138+
else \
139+
echo "$(YELLOW)Architecture review not found$(RESET)"; \
140+
fi
141+
142+
.PHONY: migration
143+
migration: ## Display migration summary
144+
@if [ -f "MIGRATION_SUMMARY.md" ]; then \
145+
cat MIGRATION_SUMMARY.md; \
146+
else \
147+
echo "$(YELLOW)Migration summary not found$(RESET)"; \
148+
fi
149+
150+
# ============================================================================
151+
# Structure Inspection
152+
# ============================================================================
153+
154+
.PHONY: tree
155+
tree: ## Show directory structure
156+
@echo "$(CYAN)Pipeline directory structure:$(RESET)"
157+
@tree -L 3 -I 'node_modules' . || \
158+
(echo "$(YELLOW)tree command not found, using ls instead:$(RESET)" && \
159+
ls -R | grep ":$$" | sed -e 's/:$$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/')
160+
161+
.PHONY: info
162+
info: ## Display pipeline information
163+
@echo "$(CYAN)Pipeline Information:$(RESET)"
164+
@echo " Root: $$(pwd)"
165+
@echo " Core modules: $$(ls core/*.sh 2>/dev/null | wc -l)"
166+
@echo " Platform modules: $$(find modules/platform -name '*.sh' 2>/dev/null | wc -l)"
167+
@echo " Deployment modules: $$(find modules/deployment -name '*.sh' 2>/dev/null | wc -l)"
168+
@echo " Testing modules: $$(find modules/testing -name '*.sh' 2>/dev/null | wc -l)"
169+
@echo " Job handlers: $$(find jobs -name 'handler.sh' 2>/dev/null | wc -l)"
170+
@echo " Config files: $$(find config -type f 2>/dev/null | wc -l)"
171+
172+
# ============================================================================
173+
# CI/CD Simulation
174+
# ============================================================================
175+
176+
.PHONY: ci-local
177+
ci-local: validate lint test-integration ## Run all CI checks locally
178+
@echo "$(GREEN)All CI checks passed!$(RESET)"
179+
180+
# ============================================================================
181+
# Utility Targets
182+
# ============================================================================
183+
184+
.PHONY: permissions
185+
permissions: ## Fix file permissions for all scripts
186+
@echo "$(CYAN)Setting executable permissions...$(RESET)"
187+
@chmod +x main.sh
188+
@chmod +x core/*.sh
189+
@chmod +x modules/**/*.sh
190+
@chmod +x jobs/**/*.sh
191+
@chmod +x scripts/*.sh
192+
@echo "$(GREEN)Permissions updated$(RESET)"
193+
194+
.PHONY: version
195+
version: ## Display version information
196+
@echo "$(CYAN)RHDH CI/CD Pipeline$(RESET)"
197+
@echo "Version: 1.0.0"
198+
@echo "Last Updated: November 2024"
199+
@if [ -f "MIGRATION_SUMMARY.md" ]; then \
200+
echo "Status: $$(grep 'Status:' MIGRATION_SUMMARY.md | head -1)"; \
201+
fi
202+

0 commit comments

Comments
 (0)