Skip to content

Commit 005f431

Browse files
authored
Merge pull request #1250 from Goodnessukaigwe/fix/1217-remove-unused-archive-scripts-and-consolidate-into-single-cleanup-tool
[1217] Remove unused archive scripts and consolidate into single cleanup tool
2 parents a1c42a9 + baf04e6 commit 005f431

15 files changed

Lines changed: 225 additions & 367 deletions

CONTRIBUTING.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,11 @@ for the full command set and per-step expectations.
216216

217217
### Script conventions
218218

219-
- Scripts use `kebab-case.sh` (e.g., `setup-mac.sh`).
219+
- Scripts use `kebab-case.sh` (e.g., `cleanup.sh`).
220220
- Every script must pass `shellcheck -S error`.
221+
- Do not add one-off archive or batch scripts under `scripts/`. Use
222+
`scripts/cleanup.sh` (`make cleanup`) as the single cleanup entrypoint, or
223+
remove obsolete helpers entirely.
221224
- Historical or one-off scripts should not be committed to the repository; keep only operational scripts under `scripts/`.
222225

223226
### Manifest and config conventions

CONVENTIONS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ Stellar-K8s/
2626
├── policy/ CEL and OPA policies
2727
├── schemas/ JSON schemas
2828
├── scripts/ Operational scripts
29+
│ ├── ci/ CI helper scripts
30+
│ └── lib/ Shared script library functions
2931
│ ├── lib/ Shared script library functions
3032
│ ├── ci/ CI validation helpers
3133
│ └── archive/ Historical one-off scripts (not part of normal workflow)
@@ -69,6 +71,9 @@ entry points only — detailed content belongs in `docs/`.
6971

7072
| Element | Convention | Example |
7173
|---|---|---|
74+
| File names | `kebab-case.sh` | `cleanup.sh` |
75+
| Operational scripts | live in `scripts/` | `scripts/cleanup.sh`, `scripts/repo-health.sh` |
76+
| One-off / historical | delete or fold into a supported tool | Prefer `scripts/cleanup.sh` over new ad-hoc helpers |
7277
| File names | `kebab-case.sh` | `setup-mac.sh` |
7378
| Operational scripts | live in `scripts/` | `scripts/repo-health.sh` |
7479
| Historical / one-off | do not commit; use issue-specific branches ||
@@ -105,6 +110,9 @@ must not appear in filenames — use the feature name instead
105110
3. **Config files**: Go under `config/` with a clear subdirectory. Use `config/crd/` for CRDs,
106111
`config/samples/` for test resources, and `config/manifests/` for OLM bases.
107112

113+
4. **Scripts**: Operational scripts go in `scripts/`. Do not add one-off archive
114+
or batch helpers — fold cleanup into `scripts/cleanup.sh` (or remove the script).
115+
Scripts must not live at the repository root.
108116
4. **Scripts**: Operational scripts go in `scripts/`. One-off or historical scripts should not
109117
be committed to the repository. Scripts must not live at the repository root.
110118

DEVELOPMENT.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@ This guide walks you through setting up a local development environment for Stel
1818
1919
### Removed maintenance scripts
2020

21-
The following one-off scripts were removed as part of repository hygiene (#1002). Use the supported replacements instead:
21+
The following one-off scripts were removed as part of repository hygiene
22+
(#1002, #1217). Use the supported replacements instead:
2223

2324
| Removed | Replacement |
2425
|---------|-------------|
26+
| `scripts/cleanup_root.sh` | `scripts/cleanup.sh` (`make cleanup`) |
27+
| `scripts/organize_scripts.sh` | `scripts/cleanup.sh` (`make cleanup`) |
28+
| `scripts/archive/*` | Removed; no archive tree — use `scripts/cleanup.sh` |
29+
| `scripts/lib/batch.sh` | Removed with archive batch scripts |
2530
| `scripts/cleanup_root.sh` | Manual cleanup; no automated replacement |
2631
| `scripts/quickstart-verify.sh` | Golden-path quickstart verification |
2732
| `scripts/dev-utils/*` | `make dev-setup`, `make preflight`, `make health-fast` |
@@ -31,6 +36,18 @@ The following one-off scripts were removed as part of repository hygiene (#1002)
3136
| `src/update_check.rs` | `src/version_check.rs` (used by the operator binary) |
3237
| `src/kubectl_plugin/interactive.rs` | Standard kubectl-stellar subcommands |
3338

39+
#### Repository cleanup
40+
41+
Use the single supported cleanup tool:
42+
43+
```bash
44+
make cleanup # remove root scratch artifacts; guard obsolete paths
45+
make cleanup DRY_RUN=1 # report only
46+
# or
47+
./scripts/cleanup.sh
48+
./scripts/cleanup.sh --dry-run
49+
```
50+
3451
---
3552

3653
## Prerequisites

Makefile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# Test: make test # Run all tests
1111
# Security: make security-all # Audit + scan
1212
# Docker: make docker-build # Local Docker image
13+
# Cleanup: make cleanup # Repo scratch + obsolete-path check
1314
# Clean: make clean # Remove build artifacts
1415
# Health: make health # Full health check
1516
# Help: make help # Show all targets
@@ -35,7 +36,7 @@
3536
collect-failure-diagnostics test-failure-diagnostics \
3637
check-unreachable-modules \
3738
check-pipeline-log-redaction \
38-
clean
39+
cleanup clean
3940

4041
.DEFAULT_GOAL := help
4142

@@ -92,6 +93,7 @@ help: ## Show this help and the canonical command flow
9293
@echo ' Security: make audit Vulnerability scan + policy check'
9394
@echo ' Security: make security-report Generate security report'
9495
@echo ' Docker: make docker-build Local Docker image'
96+
@echo ' Cleanup: make cleanup Scratch artifacts + obsolete-path check'
9597
@echo ' Clean: make clean Remove build artifacts'
9698
@echo ''
9799
@echo 'Workflows:'
@@ -263,6 +265,9 @@ pre-commit-install: ## Install pre-commit hooks
263265
pre-commit install
264266
pre-commit install --hook-type pre-push
265267

268+
cleanup: ## Repository cleanup (scratch artifacts + obsolete archive-path guard)
269+
@bash scripts/cleanup.sh $(if $(filter 1 true TRUE yes YES,$(DRY_RUN)),--dry-run,)
270+
266271
clean: ## Clean build artifacts
267272
$(CARGO) clean
268273

@@ -343,10 +348,10 @@ test-preflight: ## Run bats unit tests for scripts/preflight.sh
343348
@command -v bats >/dev/null 2>&1 || (echo "✗ bats not installed. See https://github.com/bats-core/bats-core" && exit 1)
344349
@bats scripts/tests/preflight.bats
345350

346-
test-shell: ## Run bats unit tests for shared shell helpers
347-
@echo "→ Running shell helper bats tests..."
351+
test-shell: ## Run bats unit tests for the cleanup tool and shared shell helpers
352+
@echo "→ Running cleanup tool bats tests..."
348353
@command -v bats >/dev/null 2>&1 || (echo "✗ bats not installed. See https://github.com/bats-core/bats-core" && exit 1)
349-
@bats scripts/tests/common.bats
354+
@bats scripts/tests/cleanup.bats
350355

351356
collect-failure-diagnostics: ## Assemble a local CI failure diagnostics bundle (#1151)
352357
@echo "→ Assembling failure diagnostics bundle..."

docs/development.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# Local Development with k3d
22

3-
<!-- chart-sync: 2026-07-29T12:00Z Dockerfile cargo-chef latest-rust-1.95-slim-bookworm -->
3+
<!-- chart-sync: 2026-07-30T04:00Z Dockerfile cargo-chef latest-rust-1.95-slim-bookworm -->
44

55
This guide walks you through setting up a fully functional Stellar development environment on your local machine using [k3d](https://k3d.io) — K3s running inside Docker. No cloud account required.
66

7+
For repository scratch cleanup and contributor gates, see root [`DEVELOPMENT.md`](../DEVELOPMENT.md) (`make cleanup`, `make health`) and [`CONTRIBUTING.md`](../CONTRIBUTING.md).
8+
79
---
810

911
## Prerequisites

docs/stale-docs-detector.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
> is flagged as _stale_. CI will fail. Update the doc (or suppress the false
55
> positive), then push.
66
>
7-
> Last refreshed: 2026-07-29 (Makefile / CI wiring updates).
7+
> Last refreshed: 2026-07-30 (Makefile cleanup target / CONTRIBUTING script conventions).
88
99
---
1010

scripts/check-stale-samples.sh

Lines changed: 0 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -39,135 +39,6 @@ if [[ ! -f "$CRD_FILE" ]]; then
3939
exit 1
4040
fi
4141

42-
# Validate each sample file
43-
for sample in "$SAMPLES_DIR"/*.yaml; do
44-
[[ -f "$sample" ]] || continue
45-
46-
filename=$(basename "$sample")
47-
echo "Checking: $filename"
48-
49-
# Skip README
50-
if [[ "$filename" == "README.md" ]]; then
51-
continue
52-
fi
53-
54-
# Check 1: Valid YAML syntax
55-
if ! python3 -c "import yaml; yaml.safe_load(open('$sample'))" 2>/dev/null; then
56-
echo -e " ${RED}${NC} Invalid YAML syntax"
57-
((ERRORS++))
58-
continue
59-
fi
60-
echo -e " ${GREEN}${NC} Valid YAML syntax"
61-
62-
# Check 2: Has apiVersion and kind
63-
if ! grep -q "^apiVersion:" "$sample"; then
64-
echo -e " ${RED}${NC} Missing apiVersion field"
65-
((ERRORS++))
66-
else
67-
echo -e " ${GREEN}${NC} Has apiVersion"
68-
fi
69-
70-
if ! grep -q "^kind:" "$sample"; then
71-
echo -e " ${RED}${NC} Missing kind field"
72-
((ERRORS++))
73-
else
74-
echo -e " ${GREEN}${NC} Has kind"
75-
fi
76-
77-
# Check 3: Has metadata.name
78-
if ! grep -q "^ name:" "$sample"; then
79-
echo -e " ${YELLOW}${NC} Missing metadata.name"
80-
((WARNINGS++))
81-
else
82-
echo -e " ${GREEN}${NC} Has metadata.name"
83-
fi
84-
85-
# Check 4: Has metadata.namespace
86-
if ! grep -q "^ namespace:" "$sample"; then
87-
echo -e " ${YELLOW}${NC} Missing metadata.namespace"
88-
((WARNINGS++))
89-
else
90-
echo -e " ${GREEN}${NC} Has metadata.namespace"
91-
fi
92-
93-
# Check 5: Validate against CRD schema if kubectl is available
94-
if command -v kubectl >/dev/null 2>&1; then
95-
# Dry-run validation against the CRD
96-
if kubectl apply -f "$sample" --dry-run=server 2>/dev/null; then
97-
echo -e " ${GREEN}${NC} Passes CRD validation (dry-run)"
98-
else
99-
echo -e " ${RED}${NC} Failed CRD validation (dry-run)"
100-
((ERRORS++))
101-
fi
102-
else
103-
echo -e " ${YELLOW}${NC} kubectl not available - skipping CRD validation"
104-
fi
105-
106-
echo ""
107-
done
108-
109-
# Summary
110-
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
111-
echo "Sample Manifest Check Summary:"
112-
echo -e " Errors: ${RED}$ERRORS${NC}"
113-
echo -e " Warnings: ${YELLOW}$WARNINGS${NC}"
114-
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
115-
116-
if [[ $ERRORS -gt 0 ]]; then
117-
echo ""
118-
echo "❌ Sample manifest check FAILED"
119-
echo " Fix the errors above or run: make regenerate-samples"
120-
exit 1
121-
elif [[ $WARNINGS -gt 0 ]]; then
122-
echo ""
123-
echo "⚠️ Sample manifest check passed with warnings"
124-
exit 0
125-
else
126-
echo ""
127-
echo "✅ All sample manifests are valid and up-to-date"
128-
exit 0
129-
fi
130-
#!/usr/bin/env bash
131-
# check-stale-samples.sh - Detect and optionally fix stale sample manifests
132-
#
133-
# This script validates that sample manifests in config/samples/ are:
134-
# 1. Syntactically valid YAML
135-
# 2. Conform to the current CRD schema
136-
# 3. Not missing required fields
137-
#
138-
# Related: #1146 - Create automated stale sample manifest detector and fixer
139-
140-
set -euo pipefail
141-
142-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
143-
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
144-
SAMPLES_DIR="$PROJECT_ROOT/config/samples"
145-
CRD_FILE="$PROJECT_ROOT/config/crd/stellarnode-crd.yaml"
146-
147-
# Colors for output
148-
RED='\033[0;31m'
149-
GREEN='\033[0;32m'
150-
YELLOW='\033[1;33m'
151-
NC='\033[0m' # No Color
152-
153-
ERRORS=0
154-
WARNINGS=0
155-
156-
echo "→ Checking sample manifests in $SAMPLES_DIR..."
157-
echo ""
158-
159-
# Check if samples directory exists
160-
if [[ ! -d "$SAMPLES_DIR" ]]; then
161-
echo "ERROR: Samples directory not found: $SAMPLES_DIR"
162-
exit 1
163-
fi
164-
165-
# Check if CRD file exists
166-
if [[ ! -f "$CRD_FILE" ]]; then
167-
echo "ERROR: CRD file not found: $CRD_FILE"
168-
exit 1
169-
fi
170-
17142
# Validate each sample file
17243
for sample in "$SAMPLES_DIR"/*.yaml; do
17344
[[ -f "$sample" ]] || continue

scripts/ci/check-stale-todos.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ CRITICAL_PATHS=(
1515

1616
# Paths that document the TODO policy itself (or generate issues) and would
1717
# otherwise self-match on the words TODO/FIXME.
18-
EXCLUDE_REGEX='(^scripts/ci/check-stale-todos\.sh$|^scripts/archive/)'
18+
EXCLUDE_REGEX='(^scripts/ci/check-stale-todos\.sh$)'
1919

2020
ERRORS=0
2121

0 commit comments

Comments
 (0)