guardian-framework 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +463 -0
  3. package/dist/cli.js +12958 -0
  4. package/dist/exports.js +12765 -0
  5. package/package.json +61 -0
  6. package/templates/languages/go-patterns.md +411 -0
  7. package/templates/languages/java-patterns.md +545 -0
  8. package/templates/languages/python-patterns.md +312 -0
  9. package/templates/languages/rust-patterns.md +232 -0
  10. package/templates/languages/typescript-patterns.md +313 -0
  11. package/templates/pi/INDEX.md +437 -0
  12. package/templates/pi/agent/AGENTS.md +166 -0
  13. package/templates/pi/agents/architecture-coordinator.md +40 -0
  14. package/templates/pi/agents/architecture-validator.md +36 -0
  15. package/templates/pi/agents/bootstrap-implementer.md +37 -0
  16. package/templates/pi/agents/issue-factory.md +31 -0
  17. package/templates/pi/agents/operations-validator.md +32 -0
  18. package/templates/pi/agents/security-validator.md +33 -0
  19. package/templates/pi/architecture/CHANGELOG.md +78 -0
  20. package/templates/pi/architecture/decisions/ADR-template.md +76 -0
  21. package/templates/pi/architecture/diagrams/system-overview.md +159 -0
  22. package/templates/pi/architecture/modules/module-template.md +152 -0
  23. package/templates/pi/context/checklists.md +91 -0
  24. package/templates/pi/context/domain-workflow.md +180 -0
  25. package/templates/pi/context/output-formats.md +135 -0
  26. package/templates/pi/context/patterns-base.md +47 -0
  27. package/templates/pi/context/patterns.md +38 -0
  28. package/templates/pi/context/project.md +88 -0
  29. package/templates/pi/domain/exploration.md +93 -0
  30. package/templates/pi/domain/ubiquitous-language.md +24 -0
  31. package/templates/pi/extensions/architect-lib/generators.ts +528 -0
  32. package/templates/pi/extensions/architect-lib/helpers.ts +344 -0
  33. package/templates/pi/extensions/architect-lib/types.ts +117 -0
  34. package/templates/pi/extensions/architect.ts +1425 -0
  35. package/templates/pi/extensions/ask-user-question.ts +579 -0
  36. package/templates/pi/extensions/bash-guard.ts +556 -0
  37. package/templates/pi/extensions/config-reload.ts +115 -0
  38. package/templates/pi/extensions/coordinator.ts +304 -0
  39. package/templates/pi/extensions/curator.ts +543 -0
  40. package/templates/pi/extensions/domain-explorer.ts +990 -0
  41. package/templates/pi/extensions/filechanges.ts +656 -0
  42. package/templates/pi/extensions/goal-loop.ts +717 -0
  43. package/templates/pi/extensions/hooks.ts +452 -0
  44. package/templates/pi/extensions/kanban.ts +547 -0
  45. package/templates/pi/extensions/pipeline.ts +1246 -0
  46. package/templates/pi/extensions/plan-mode.ts +209 -0
  47. package/templates/pi/extensions/project-scaffolder.ts +284 -0
  48. package/templates/pi/extensions/read-only-mode.ts +192 -0
  49. package/templates/pi/extensions/redaction.ts +128 -0
  50. package/templates/pi/extensions/session-persistence.ts +174 -0
  51. package/templates/pi/extensions/slash-commands.ts +229 -0
  52. package/templates/pi/extensions/snippets.ts +201 -0
  53. package/templates/pi/extensions/validation-runner.ts +100 -0
  54. package/templates/pi/github/agents/architecture-coordinator.agent.md +27 -0
  55. package/templates/pi/github/agents/architecture-validator.agent.md +20 -0
  56. package/templates/pi/github/agents/bootstrap-implementer.agent.md +20 -0
  57. package/templates/pi/github/agents/epic-planner.agent.md +70 -0
  58. package/templates/pi/github/agents/issue-factory.agent.md +20 -0
  59. package/templates/pi/github/agents/operations-validator.agent.md +20 -0
  60. package/templates/pi/github/agents/security-validator.agent.md +20 -0
  61. package/templates/pi/github/copilot/settings.json +16 -0
  62. package/templates/pi/github/copilot-instructions.md +155 -0
  63. package/templates/pi/github/instructions/architecture.instructions.md +71 -0
  64. package/templates/pi/github/instructions/validation.instructions.md +69 -0
  65. package/templates/pi/github/workflows/01-planning-workflow.md +75 -0
  66. package/templates/pi/github/workflows/02-issue-generation-workflow.md +69 -0
  67. package/templates/pi/github/workflows/03-implementation-workflow.md +80 -0
  68. package/templates/pi/github/workflows/04-validation-workflow.md +68 -0
  69. package/templates/pi/preflight_report.json +99 -0
  70. package/templates/pi/prompts/blueprint-update.md +262 -0
  71. package/templates/pi/prompts/blueprint-validate.md +218 -0
  72. package/templates/pi/prompts/bug-fix.md +50 -0
  73. package/templates/pi/prompts/ci-blueprint.md +131 -0
  74. package/templates/pi/prompts/context-refresh.md +258 -0
  75. package/templates/pi/prompts/epic-plan.md +356 -0
  76. package/templates/pi/prompts/epic-template.md +186 -0
  77. package/templates/pi/prompts/feature-development.md +131 -0
  78. package/templates/pi/prompts/git-issues.md +243 -0
  79. package/templates/pi/prompts/hotfix.md +71 -0
  80. package/templates/pi/prompts/issue-closeout.md +342 -0
  81. package/templates/pi/prompts/issue-draft.md +218 -0
  82. package/templates/pi/prompts/issue-implementation-series.md +173 -0
  83. package/templates/pi/prompts/issue-merge.md +372 -0
  84. package/templates/pi/prompts/issue-template-set.md +392 -0
  85. package/templates/pi/prompts/issue-template.md +207 -0
  86. package/templates/pi/prompts/pattern-extract.md +269 -0
  87. package/templates/pi/prompts/plan-to-issues.md +430 -0
  88. package/templates/pi/prompts/refactoring.md +82 -0
  89. package/templates/pi/prompts/scope-analyzer.md +254 -0
  90. package/templates/pi/prompts/sync-check.md +230 -0
  91. package/templates/pi/scripts/categorize-issues.sh +171 -0
  92. package/templates/pi/scripts/ci/check_architecture_conformance.sh +748 -0
  93. package/templates/pi/scripts/ci/check_planning_packet.py +228 -0
  94. package/templates/pi/scripts/ci/run_hardening_stages.sh +264 -0
  95. package/templates/pi/scripts/ci/run_preflight.sh +649 -0
  96. package/templates/pi/scripts/ci/run_stage.sh +193 -0
  97. package/templates/pi/scripts/ci/stage_docs_policy.sh +82 -0
  98. package/templates/pi/scripts/ci/stage_integration.sh +3 -0
  99. package/templates/pi/scripts/ci/stage_lint.sh +130 -0
  100. package/templates/pi/scripts/ci/stage_migration_verify.sh +3 -0
  101. package/templates/pi/scripts/ci/stage_package_build.sh +3 -0
  102. package/templates/pi/scripts/ci/stage_release_readiness.sh +3 -0
  103. package/templates/pi/scripts/ci/stage_remaining.sh +242 -0
  104. package/templates/pi/scripts/ci/stage_security.sh +3 -0
  105. package/templates/pi/scripts/ci/stage_static_analysis.sh +114 -0
  106. package/templates/pi/scripts/ci/stage_unit.sh +119 -0
  107. package/templates/pi/scripts/ci/validate_agent_output.py +181 -0
  108. package/templates/pi/scripts/ci/validate_agent_output.sh +243 -0
  109. package/templates/pi/scripts/create-feature-branch.sh +136 -0
  110. package/templates/pi/scripts/create-mr.sh +117 -0
  111. package/templates/pi/scripts/fetch-issues.sh +131 -0
  112. package/templates/pi/scripts/generate-architecture.sh +161 -0
  113. package/templates/pi/scripts/git/close-epic.sh +69 -0
  114. package/templates/pi/scripts/git/close-issue.sh +35 -0
  115. package/templates/pi/scripts/git/create-tracking-issue.sh +174 -0
  116. package/templates/pi/scripts/git/link-issue-to-epic.sh +51 -0
  117. package/templates/pi/scripts/git/update-tracking-issue.sh +66 -0
  118. package/templates/pi/scripts/languages/go/validate-architecture.sh +139 -0
  119. package/templates/pi/scripts/languages/go/validate-canonical.sh +129 -0
  120. package/templates/pi/scripts/languages/go/validate-ci.sh +132 -0
  121. package/templates/pi/scripts/languages/go/validate-integration.sh +156 -0
  122. package/templates/pi/scripts/languages/go/validate-operations.sh +146 -0
  123. package/templates/pi/scripts/languages/go/validate-security.sh +135 -0
  124. package/templates/pi/scripts/languages/go/validate-tests.sh +125 -0
  125. package/templates/pi/scripts/languages/java/validate-annotations.sh +185 -0
  126. package/templates/pi/scripts/languages/java/validate-architecture.sh +159 -0
  127. package/templates/pi/scripts/languages/java/validate-canonical.sh +114 -0
  128. package/templates/pi/scripts/languages/java/validate-ci.sh +269 -0
  129. package/templates/pi/scripts/languages/java/validate-integration.sh +149 -0
  130. package/templates/pi/scripts/languages/java/validate-operations.sh +142 -0
  131. package/templates/pi/scripts/languages/java/validate-security.sh +174 -0
  132. package/templates/pi/scripts/languages/java/validate-spring-architecture.sh +227 -0
  133. package/templates/pi/scripts/languages/java/validate-tests.sh +159 -0
  134. package/templates/pi/scripts/languages/python/validate-architecture.sh +99 -0
  135. package/templates/pi/scripts/languages/python/validate-canonical.sh +124 -0
  136. package/templates/pi/scripts/languages/python/validate-ci.sh +130 -0
  137. package/templates/pi/scripts/languages/python/validate-integration.sh +119 -0
  138. package/templates/pi/scripts/languages/python/validate-operations.sh +107 -0
  139. package/templates/pi/scripts/languages/python/validate-security.sh +68 -0
  140. package/templates/pi/scripts/languages/python/validate-tests.sh +102 -0
  141. package/templates/pi/scripts/languages/rust/validate-architecture.sh +188 -0
  142. package/templates/pi/scripts/languages/rust/validate-canonical.sh +146 -0
  143. package/templates/pi/scripts/languages/rust/validate-ci.sh +147 -0
  144. package/templates/pi/scripts/languages/rust/validate-integration.sh +149 -0
  145. package/templates/pi/scripts/languages/rust/validate-operations.sh +154 -0
  146. package/templates/pi/scripts/languages/rust/validate-security.sh +153 -0
  147. package/templates/pi/scripts/languages/rust/validate-tests.sh +150 -0
  148. package/templates/pi/scripts/languages/typescript/validate-architecture.sh +157 -0
  149. package/templates/pi/scripts/languages/typescript/validate-canonical.sh +135 -0
  150. package/templates/pi/scripts/languages/typescript/validate-ci.sh +244 -0
  151. package/templates/pi/scripts/languages/typescript/validate-integration.sh +166 -0
  152. package/templates/pi/scripts/languages/typescript/validate-operations.sh +162 -0
  153. package/templates/pi/scripts/languages/typescript/validate-security.sh +169 -0
  154. package/templates/pi/scripts/languages/typescript/validate-tests.sh +158 -0
  155. package/templates/pi/scripts/merge-mr.sh +95 -0
  156. package/templates/pi/scripts/mr-validation.sh +228 -0
  157. package/templates/pi/scripts/validate-architecture-readiness.sh +153 -0
  158. package/templates/pi/scripts/validate-architecture.sh +22 -0
  159. package/templates/pi/scripts/validate-canonical.sh +22 -0
  160. package/templates/pi/scripts/validate-ci.sh +37 -0
  161. package/templates/pi/scripts/validate-integration.sh +22 -0
  162. package/templates/pi/scripts/validate-operations.sh +22 -0
  163. package/templates/pi/scripts/validate-security.sh +22 -0
  164. package/templates/pi/scripts/validate-tests.sh +22 -0
  165. package/templates/pi/scripts/validate-ubiquitous-language.sh +291 -0
  166. package/templates/pi/scripts/validation-cache.sh +139 -0
  167. package/templates/pi/skills/agents/architecture-coordinator.md +178 -0
  168. package/templates/pi/skills/agents/architecture-generator.md +79 -0
  169. package/templates/pi/skills/agents/architecture-validator.md +74 -0
  170. package/templates/pi/skills/agents/ci-mr-validator.md +46 -0
  171. package/templates/pi/skills/agents/code-developer.md +76 -0
  172. package/templates/pi/skills/agents/commit.md +46 -0
  173. package/templates/pi/skills/agents/curator.md +71 -0
  174. package/templates/pi/skills/agents/debug.md +59 -0
  175. package/templates/pi/skills/agents/documentation-maintainer.md +36 -0
  176. package/templates/pi/skills/agents/goal-loop.md +125 -0
  177. package/templates/pi/skills/agents/hooks.md +122 -0
  178. package/templates/pi/skills/agents/integration-validator.md +35 -0
  179. package/templates/pi/skills/agents/issue-creator.md +75 -0
  180. package/templates/pi/skills/agents/issue-factory.md +143 -0
  181. package/templates/pi/skills/agents/kanban.md +85 -0
  182. package/templates/pi/skills/agents/land.md +59 -0
  183. package/templates/pi/skills/agents/operations-validator.md +43 -0
  184. package/templates/pi/skills/agents/pipeline.md +113 -0
  185. package/templates/pi/skills/agents/plan-mode.md +77 -0
  186. package/templates/pi/skills/agents/pull.md +40 -0
  187. package/templates/pi/skills/agents/push.md +41 -0
  188. package/templates/pi/skills/agents/security-validator.md +85 -0
  189. package/templates/pi/skills/agents/session-persistence.md +119 -0
  190. package/templates/pi/skills/agents/slash-commands.md +117 -0
  191. package/templates/pi/skills/agents/snippets.md +99 -0
  192. package/templates/pi/skills/agents/subagent-registry.md +78 -0
  193. package/templates/pi/skills/agents/test-validator.md +42 -0
  194. package/templates/pi/skills/validators/architecture-validator.md +43 -0
  195. package/templates/pi/skills/validators/ci-validator.md +27 -0
  196. package/templates/pi/skills/validators/context-compaction.md +73 -0
  197. package/templates/pi/skills/validators/integration-validator.md +38 -0
  198. package/templates/pi/skills/validators/model-registry.md +96 -0
  199. package/templates/pi/skills/validators/operations-validator.md +34 -0
  200. package/templates/pi/skills/validators/security-guards.md +72 -0
  201. package/templates/pi/skills/validators/security-validator.md +41 -0
  202. package/templates/pi/skills/validators/system-prompt-tiers.md +69 -0
  203. package/templates/pi/skills/validators/test-validator.md +33 -0
  204. package/templates/pi/types.ts +62 -0
  205. package/templates/pi/validators/README.md +93 -0
  206. package/templates/pi/validators/default.toml +209 -0
  207. package/templates/pi/validators/spring.toml +142 -0
  208. package/templates/pi/workpad.md +53 -0
  209. package/templates/project/java/Dockerfile +14 -0
  210. package/templates/project/java/README.md +40 -0
  211. package/templates/project/java/pom.xml +132 -0
  212. package/templates/project/typescript/Dockerfile +15 -0
  213. package/templates/project/typescript/README.md +29 -0
  214. package/templates/project/typescript/package.json +23 -0
  215. package/templates/project/typescript/tsconfig.json +21 -0
  216. package/templates/workflow.md +123 -0
@@ -0,0 +1,269 @@
1
+ #!/usr/bin/env bash
2
+ # ============================================================================
3
+ # validate-ci.sh — Java (Maven/Gradle)
4
+ # ============================================================================
5
+ set -euo pipefail
6
+
7
+ PASS_COUNT=0; ERRORS=(); WARNINGS=()
8
+ RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m'
9
+ pass() { echo -e "${GREEN}✅ PASS${NC} $1"; PASS_COUNT=$((PASS_COUNT + 1)); }
10
+ fail() { echo -e "${RED}❌ FAIL${NC} $1"; ERRORS+=("$1"); }
11
+ warn() { echo -e "${YELLOW}⚠️ WARN${NC} $1"; WARNINGS+=("$1"); }
12
+
13
+ echo "============================================"
14
+ echo " CI/MR Validation (Java)"
15
+ echo "============================================"
16
+ echo ""
17
+
18
+ # Detect build tool
19
+ BUILD_TOOL=""
20
+ if [ -f "pom.xml" ]; then
21
+ BUILD_TOOL="maven"
22
+ elif [ -f "build.gradle" ] || [ -f "build.gradle.kts" ]; then
23
+ BUILD_TOOL="gradle"
24
+ fi
25
+
26
+ if [ -z "$BUILD_TOOL" ]; then
27
+ warn "No build file detected (pom.xml or build.gradle). Is this a Java project?"
28
+ fi
29
+
30
+ # Check Java availability
31
+ if ! command -v java &>/dev/null; then
32
+ warn "Java runtime not found (install JDK 17+ for Spring Boot projects)"
33
+ fi
34
+
35
+ # ---------------------------------------------------------------------------
36
+ # Build
37
+ # ---------------------------------------------------------------------------
38
+ echo "--- Build ---"
39
+ if [ -z "$BUILD_TOOL" ]; then
40
+ pass "No build tool detected, skipping build"
41
+ elif [ "$BUILD_TOOL" = "maven" ] && command -v mvn &>/dev/null; then
42
+ if mvn clean compile -q 2>/dev/null; then
43
+ pass "Maven build succeeded (mvn clean compile)"
44
+ else
45
+ fail "Maven build failed"
46
+ fi
47
+ elif [ "$BUILD_TOOL" = "gradle" ] && command -v gradle &>/dev/null; then
48
+ if gradle build -q 2>/dev/null; then
49
+ pass "Gradle build succeeded (gradle build)"
50
+ else
51
+ fail "Gradle build failed"
52
+ fi
53
+ elif [ "$BUILD_TOOL" = "maven" ]; then
54
+ if [ -f "mvnw" ]; then
55
+ if ./mvnw clean compile -q 2>/dev/null; then
56
+ pass "Maven Wrapper build succeeded (./mvnw clean compile)"
57
+ else
58
+ fail "Maven Wrapper build failed"
59
+ fi
60
+ else
61
+ warn "Maven not found and no mvnw wrapper available, skipping build"
62
+ fi
63
+ elif [ "$BUILD_TOOL" = "gradle" ]; then
64
+ if [ -f "gradlew" ]; then
65
+ if ./gradlew build -q 2>/dev/null; then
66
+ pass "Gradle Wrapper build succeeded (./gradlew build)"
67
+ else
68
+ fail "Gradle Wrapper build failed"
69
+ fi
70
+ else
71
+ warn "Gradle not found and no gradlew wrapper available, skipping build"
72
+ fi
73
+ fi
74
+
75
+ # ---------------------------------------------------------------------------
76
+ # Tests
77
+ # ---------------------------------------------------------------------------
78
+ echo ""
79
+ echo "--- Tests ---"
80
+ if [ -z "$BUILD_TOOL" ]; then
81
+ pass "No build tool detected, skipping tests"
82
+ elif [ "$BUILD_TOOL" = "maven" ] && command -v mvn &>/dev/null; then
83
+ if mvn test -q 2>/dev/null; then
84
+ pass "All tests passed (mvn test)"
85
+ else
86
+ fail "Tests failed (mvn test)"
87
+ fi
88
+ elif [ "$BUILD_TOOL" = "gradle" ] && command -v gradle &>/dev/null; then
89
+ if gradle test -q 2>/dev/null; then
90
+ pass "All tests passed (gradle test)"
91
+ else
92
+ fail "Tests failed (gradle test)"
93
+ fi
94
+ elif [ "$BUILD_TOOL" = "maven" ] && [ -f "mvnw" ]; then
95
+ if ./mvnw test -q 2>/dev/null; then
96
+ pass "All tests passed (./mvnw test)"
97
+ else
98
+ fail "Tests failed (./mvnw test)"
99
+ fi
100
+ elif [ "$BUILD_TOOL" = "gradle" ] && [ -f "gradlew" ]; then
101
+ if ./gradlew test -q 2>/dev/null; then
102
+ pass "All tests passed (./gradlew test)"
103
+ else
104
+ fail "Tests failed (./gradlew test)"
105
+ fi
106
+ else
107
+ warn "No build tool available to run tests"
108
+ fi
109
+
110
+ # ---------------------------------------------------------------------------
111
+ # Lint
112
+ # ---------------------------------------------------------------------------
113
+ echo ""
114
+ echo "--- Lint ---"
115
+ if [ -z "$BUILD_TOOL" ]; then
116
+ pass "No build tool detected, skipping lint"
117
+ elif [ "$BUILD_TOOL" = "maven" ] && [ -f "pom.xml" ]; then
118
+ if grep -q "checkstyle" pom.xml 2>/dev/null; then
119
+ if command -v mvn &>/dev/null; then
120
+ if mvn checkstyle:check -q 2>/dev/null; then
121
+ pass "Checkstyle passed (mvn checkstyle:check)"
122
+ else
123
+ fail "Checkstyle failed"
124
+ fi
125
+ elif [ -f "mvnw" ]; then
126
+ if ./mvnw checkstyle:check -q 2>/dev/null; then
127
+ pass "Checkstyle passed (./mvnw checkstyle:check)"
128
+ else
129
+ fail "Checkstyle failed"
130
+ fi
131
+ fi
132
+ else
133
+ warn "No checkstyle plugin found in pom.xml"
134
+ fi
135
+ elif [ "$BUILD_TOOL" = "gradle" ] && [ -f "build.gradle" ] || [ -f "build.gradle.kts" ]; then
136
+ if command -v gradle &>/dev/null; then
137
+ if gradle checkstyleMain -q 2>/dev/null; then
138
+ pass "Checkstyle passed (gradle checkstyleMain)"
139
+ else
140
+ fail "Checkstyle failed"
141
+ fi
142
+ elif [ -f "gradlew" ]; then
143
+ if ./gradlew checkstyleMain -q 2>/dev/null; then
144
+ pass "Checkstyle passed (./gradlew checkstyleMain)"
145
+ else
146
+ fail "Checkstyle failed"
147
+ fi
148
+ else
149
+ warn "Checkstyle not configured, skipping lint"
150
+ fi
151
+ else
152
+ warn "No linter configuration detected, skipping lint"
153
+ fi
154
+
155
+ # ---------------------------------------------------------------------------
156
+ # Format
157
+ # ---------------------------------------------------------------------------
158
+ echo ""
159
+ echo "--- Format ---"
160
+ if [ -z "$BUILD_TOOL" ]; then
161
+ pass "No build tool detected, skipping format check"
162
+ elif [ "$BUILD_TOOL" = "maven" ]; then
163
+ if command -v mvn &>/dev/null; then
164
+ if mvn spotless:check -q 2>/dev/null; then
165
+ pass "Format check passed (mvn spotless:check)"
166
+ else
167
+ fail "Format check failed (mvn spotless:check)"
168
+ fi
169
+ elif [ -f "mvnw" ]; then
170
+ if ./mvnw spotless:check -q 2>/dev/null; then
171
+ pass "Format check passed (./mvnw spotless:check)"
172
+ else
173
+ fail "Format check failed (./mvnw spotless:check)"
174
+ fi
175
+ else
176
+ warn "Maven not available for format check, skipping"
177
+ fi
178
+ elif [ "$BUILD_TOOL" = "gradle" ]; then
179
+ if command -v gradle &>/dev/null; then
180
+ if gradle spotlessCheck -q 2>/dev/null; then
181
+ pass "Format check passed (gradle spotlessCheck)"
182
+ else
183
+ fail "Format check failed (gradle spotlessCheck)"
184
+ fi
185
+ elif [ -f "gradlew" ]; then
186
+ if ./gradlew spotlessCheck -q 2>/dev/null; then
187
+ pass "Format check passed (./gradlew spotlessCheck)"
188
+ else
189
+ fail "Format check failed (./gradlew spotlessCheck)"
190
+ fi
191
+ else
192
+ warn "Gradle not available for format check, skipping"
193
+ fi
194
+ fi
195
+
196
+ # ---------------------------------------------------------------------------
197
+ # Security Audit
198
+ # ---------------------------------------------------------------------------
199
+ echo ""
200
+ echo "--- Security Audit ---"
201
+ if [ -z "$BUILD_TOOL" ]; then
202
+ pass "No build tool detected, skipping security audit"
203
+ elif [ "$BUILD_TOOL" = "maven" ]; then
204
+ if command -v mvn &>/dev/null; then
205
+ AUDIT_OUT=$(mvn dependency-check:check 2>&1 || true)
206
+ if echo "$AUDIT_OUT" | grep -qi "no vulnerabilities found"; then
207
+ pass "No vulnerabilities found"
208
+ elif echo "$AUDIT_OUT" | grep -qiE "(critical|high)"; then
209
+ fail "Security audit found critical/high vulnerabilities"
210
+ else
211
+ warn "Security audit reported findings (review manually)"
212
+ fi
213
+ elif [ -f "mvnw" ]; then
214
+ AUDIT_OUT=$(./mvnw dependency-check:check 2>&1 || true)
215
+ if echo "$AUDIT_OUT" | grep -qi "no vulnerabilities found"; then
216
+ pass "No vulnerabilities found"
217
+ elif echo "$AUDIT_OUT" | grep -qiE "(critical|high)"; then
218
+ fail "Security audit found critical/high vulnerabilities"
219
+ else
220
+ warn "Security audit reported findings (review manually)"
221
+ fi
222
+ else
223
+ warn "Maven not available for security audit"
224
+ fi
225
+ elif [ "$BUILD_TOOL" = "gradle" ]; then
226
+ if command -v gradle &>/dev/null; then
227
+ AUDIT_OUT=$(gradle dependencyCheck 2>&1 || true)
228
+ if echo "$AUDIT_OUT" | grep -qi "no vulnerabilities found"; then
229
+ pass "No vulnerabilities found"
230
+ elif echo "$AUDIT_OUT" | grep -qiE "(critical|high)"; then
231
+ fail "Security audit found critical/high vulnerabilities"
232
+ else
233
+ warn "Security audit reported findings (review manually)"
234
+ fi
235
+ elif [ -f "gradlew" ]; then
236
+ AUDIT_OUT=$(./gradlew dependencyCheck 2>&1 || true)
237
+ if echo "$AUDIT_OUT" | grep -qi "no vulnerabilities found"; then
238
+ pass "No vulnerabilities found"
239
+ elif echo "$AUDIT_OUT" | grep -qiE "(critical|high)"; then
240
+ fail "Security audit found critical/high vulnerabilities"
241
+ else
242
+ warn "Security audit reported findings (review manually)"
243
+ fi
244
+ else
245
+ warn "Gradle not available for security audit"
246
+ fi
247
+ fi
248
+
249
+ # ---------------------------------------------------------------------------
250
+ # Summary
251
+ # ---------------------------------------------------------------------------
252
+ echo ""
253
+ echo "============================================"
254
+ echo " Summary"
255
+ echo "============================================"
256
+ echo -e " Passed: ${GREEN}${PASS_COUNT}${NC}"
257
+ echo -e " Failed: ${RED}${#ERRORS[@]}${NC}"
258
+ echo ""
259
+
260
+ if [ ${#ERRORS[@]} -gt 0 ]; then
261
+ echo "FAILURES:"
262
+ for err in "${ERRORS[@]}"; do
263
+ echo " - $err"
264
+ done
265
+ exit 1
266
+ fi
267
+
268
+ echo -e "${GREEN}All CI checks passed.${NC}"
269
+ exit 0
@@ -0,0 +1,149 @@
1
+ #!/usr/bin/env bash
2
+ # ============================================================================
3
+ # validate-integration.sh — Java (Spring Boot Integration)
4
+ # ============================================================================
5
+ set -euo pipefail
6
+
7
+ PASS_COUNT=0; ERRORS=(); WARNINGS=()
8
+ RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m'
9
+ pass() { echo -e "${GREEN}✅ PASS${NC} $1"; PASS_COUNT=$((PASS_COUNT + 1)); }
10
+ fail() { echo -e "${RED}❌ FAIL${NC} $1"; ERRORS+=("$1"); }
11
+ warn() { echo -e "${YELLOW}⚠️ WARN${NC} $1"; WARNINGS+=("$1"); }
12
+
13
+ echo "============================================"
14
+ echo " Integration Validation (Java)"
15
+ echo "============================================"
16
+ echo ""
17
+
18
+ SRC_DIR="${1:-src/main/java}"
19
+ TEST_DIR="${2:-src/test/java}"
20
+
21
+ # ---------------------------------------------------------------------------
22
+ # Test Slice Correctness
23
+ # ---------------------------------------------------------------------------
24
+ echo "--- Test Slice Correctness ---"
25
+ if [ -d "$TEST_DIR" ]; then
26
+ # Check for @SpringBootTest usage (no slice annotations)
27
+ FULL_CONTEXT_TESTS=$(grep -r "@SpringBootTest" "$TEST_DIR" --include="*.java" 2>/dev/null | wc -l | tr -d ' ')
28
+ # Check for slice test annotations
29
+ WEB_MVC_TESTS=$(grep -r "@WebMvcTest" "$TEST_DIR" --include="*.java" 2>/dev/null | wc -l | tr -d ' ')
30
+ DATA_JPA_TESTS=$(grep -r "@DataJpaTest" "$TEST_DIR" --include="*.java" 2>/dev/null | wc -l | tr -d ' ')
31
+ JSON_TESTS=$(grep -r "@JsonTest" "$TEST_DIR" --include="*.java" 2>/dev/null | wc -l | tr -d ' ')
32
+ REST_CLIENT_TESTS=$(grep -r "@RestClientTest" "$TEST_DIR" --include="*.java" 2>/dev/null | wc -l | tr -d ' ')
33
+
34
+ TOTAL_SLICE_TESTS=$((WEB_MVC_TESTS + DATA_JPA_TESTS + JSON_TESTS + REST_CLIENT_TESTS))
35
+
36
+ if [ "$FULL_CONTEXT_TESTS" -gt 0 ] || [ "$TOTAL_SLICE_TESTS" -gt 0 ]; then
37
+ if [ "$TOTAL_SLICE_TESTS" -ge "$FULL_CONTEXT_TESTS" ]; then
38
+ pass "Good test slice usage: $TOTAL_SLICE_TESTS slice tests, $FULL_CONTEXT_TESTS full context tests"
39
+ else
40
+ warn "Consider using slice tests (@WebMvcTest, @DataJpaTest) instead of @SpringBootTest where possible. $FULL_CONTEXT_TESTS full / $TOTAL_SLICE_TESTS slice."
41
+ fi
42
+ else
43
+ warn "No Spring test annotations found in test directory"
44
+ fi
45
+ else
46
+ pass "No test directory found, skipping test slice check"
47
+ fi
48
+
49
+ # ---------------------------------------------------------------------------
50
+ # Spring Context Caching
51
+ # ---------------------------------------------------------------------------
52
+ echo ""
53
+ echo "--- Context Caching ---"
54
+ if [ -d "$TEST_DIR" ]; then
55
+ DIRTY_CONTEXT=$(grep -r "@DirtiesContext" "$TEST_DIR" --include="*.java" 2>/dev/null | wc -l | tr -d ' ')
56
+ if [ "$DIRTY_CONTEXT" -gt 0 ]; then
57
+ warn "$DIRTY_CONTEXT @DirtiesContext annotations found — these disable context caching and slow tests"
58
+ else
59
+ pass "No @DirtiesContext found (context caching enabled)"
60
+ fi
61
+ else
62
+ pass "No test directory found, skipping context caching check"
63
+ fi
64
+
65
+ # ---------------------------------------------------------------------------
66
+ # Database State Management
67
+ # ---------------------------------------------------------------------------
68
+ echo ""
69
+ echo "--- Database State Management ---"
70
+ if [ -d "$TEST_DIR" ]; then
71
+ DATA_JPA_CLASSES=$(grep -rl "@DataJpaTest" "$TEST_DIR" --include="*.java" 2>/dev/null || true)
72
+ TRANSACTIONAL_TESTS=0
73
+ if [ -n "$DATA_JPA_CLASSES" ]; then
74
+ TRANSACTIONAL_TESTS=$(echo "$DATA_JPA_CLASSES" | wc -l | tr -d ' ')
75
+ fi
76
+
77
+ ROLLBACK_COUNT=$(grep -r "@Rollback" "$TEST_DIR" --include="*.java" 2>/dev/null | wc -l | tr -d ' ')
78
+
79
+ if [ "$TRANSACTIONAL_TESTS" -gt 0 ] || [ "$ROLLBACK_COUNT" -gt 0 ]; then
80
+ pass "Database state management found (@DataJpaTest: $TRANSACTIONAL_TESTS, @Rollback: $ROLLBACK_COUNT)"
81
+ else
82
+ warn "No explicit database state management found in tests (consider @DataJpaTest or @Rollback)"
83
+ fi
84
+ fi
85
+
86
+ # ---------------------------------------------------------------------------
87
+ # Testcontainers (if applicable)
88
+ # ---------------------------------------------------------------------------
89
+ echo ""
90
+ echo "--- Testcontainers ---"
91
+ if [ -d "$TEST_DIR" ]; then
92
+ TESTCONTAINERS=$(grep -r "testcontainers\|Testcontainers\|@Testcontainers\|@Container" "$TEST_DIR" --include="*.java" 2>/dev/null | head -10)
93
+ if [ -n "$TESTCONTAINERS" ]; then
94
+ pass "Testcontainers detected for integration testing"
95
+ else
96
+ warn "Testcontainers not detected — consider for database/external-service integration tests"
97
+ fi
98
+ fi
99
+
100
+ # ---------------------------------------------------------------------------
101
+ # Mockito Usage
102
+ # ---------------------------------------------------------------------------
103
+ echo ""
104
+ echo "--- Mockito Usage ---"
105
+ if [ -d "$TEST_DIR" ]; then
106
+ MOCKITO_ANNOTATIONS=$(grep -r "@Mock\|@InjectMocks\|@MockBean\|@SpyBean" "$TEST_DIR" --include="*.java" 2>/dev/null | wc -l | tr -d ' ')
107
+ if [ "$MOCKITO_ANNOTATIONS" -gt 0 ]; then
108
+ pass "Mockito usage detected ($MOCKITO_ANNOTATIONS annotations)"
109
+ else
110
+ warn "No Mockito annotations found (@Mock, @InjectMocks, @MockBean)"
111
+ fi
112
+ fi
113
+
114
+ # ---------------------------------------------------------------------------
115
+ # AssertJ / Assertions
116
+ # ---------------------------------------------------------------------------
117
+ echo ""
118
+ echo "--- Assertions ---"
119
+ if [ -d "$TEST_DIR" ]; then
120
+ ASSERTJ=$(grep -r "assertThat\|Assertions.assertThat" "$TEST_DIR" --include="*.java" 2>/dev/null | wc -l | tr -d ' ')
121
+ JUNIT_ASSERT=$(grep -r "assertEquals\|assertTrue\|assertNotNull\|assertThrows" "$TEST_DIR" --include="*.java" 2>/dev/null | wc -l | tr -d ' ')
122
+ if [ "$ASSERTJ" -gt 0 ] || [ "$JUNIT_ASSERT" -gt 0 ]; then
123
+ pass "Assertions found (AssertJ: $ASSERTJ, JUnit: $JUNIT_ASSERT)"
124
+ else
125
+ warn "No assertion calls found in test directory"
126
+ fi
127
+ fi
128
+
129
+ # ---------------------------------------------------------------------------
130
+ # Summary
131
+ # ---------------------------------------------------------------------------
132
+ echo ""
133
+ echo "============================================"
134
+ echo " Summary"
135
+ echo "============================================"
136
+ echo -e " Passed: ${GREEN}${PASS_COUNT}${NC}"
137
+ echo -e " Failed: ${RED}${#ERRORS[@]}${NC}"
138
+ echo ""
139
+
140
+ if [ ${#ERRORS[@]} -gt 0 ]; then
141
+ echo "FAILURES:"
142
+ for err in "${ERRORS[@]}"; do
143
+ echo " - $err"
144
+ done
145
+ exit 1
146
+ fi
147
+
148
+ echo -e "${GREEN}Integration validation passed.${NC}"
149
+ exit 0
@@ -0,0 +1,142 @@
1
+ #!/usr/bin/env bash
2
+ # ============================================================================
3
+ # validate-operations.sh — Java (Spring Boot Operations)
4
+ # ============================================================================
5
+ set -euo pipefail
6
+
7
+ PASS_COUNT=0; ERRORS=(); WARNINGS=()
8
+ RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m'
9
+ pass() { echo -e "${GREEN}✅ PASS${NC} $1"; PASS_COUNT=$((PASS_COUNT + 1)); }
10
+ fail() { echo -e "${RED}❌ FAIL${NC} $1"; ERRORS+=("$1"); }
11
+ warn() { echo -e "${YELLOW}⚠️ WARN${NC} $1"; WARNINGS+=("$1"); }
12
+
13
+ echo "============================================"
14
+ echo " Operations Validation (Java)"
15
+ echo "============================================"
16
+ echo ""
17
+
18
+ SRC_DIR="${1:-src/main/java}"
19
+
20
+ # ---------------------------------------------------------------------------
21
+ # Actuator / Health Endpoints
22
+ # ---------------------------------------------------------------------------
23
+ echo "--- Actuator / Health Endpoints ---"
24
+ if [ -f "pom.xml" ] && grep -q "actuator" pom.xml 2>/dev/null; then
25
+ pass "Spring Boot Actuator dependency found in pom.xml"
26
+ elif [ -f "build.gradle" ] && grep -q "actuator" build.gradle 2>/dev/null; then
27
+ pass "Spring Boot Actuator dependency found in build.gradle"
28
+ elif [ -f "build.gradle.kts" ] && grep -q "actuator" build.gradle.kts 2>/dev/null; then
29
+ pass "Spring Boot Actuator dependency found in build.gradle.kts"
30
+ else
31
+ warn "Spring Boot Actuator not found — add spring-boot-starter-actuator for health checks and metrics"
32
+ fi
33
+
34
+ HEALTH_ENDPOINT=$(find "$SRC_DIR" -name "*HealthIndicator*.java" -o -name "*HealthCheck*.java" 2>/dev/null | head -5)
35
+ if [ -n "$HEALTH_ENDPOINT" ]; then
36
+ pass "Custom health indicators found ($(echo "$HEALTH_ENDPOINT" | wc -l | tr -d ' ') files)"
37
+ else
38
+ warn "No custom health indicators found (consider implementing HealthIndicator for readiness checks)"
39
+ fi
40
+
41
+ # ---------------------------------------------------------------------------
42
+ # @Scheduled Tasks
43
+ # ---------------------------------------------------------------------------
44
+ echo ""
45
+ echo "--- @Scheduled Tasks ---"
46
+ if [ -d "$SRC_DIR" ]; then
47
+ SCHEDULED_COUNT=$(grep -r "@Scheduled" "$SRC_DIR" --include="*.java" 2>/dev/null | wc -l | tr -d ' ')
48
+ if [ "$SCHEDULED_COUNT" -gt 0 ]; then
49
+ # Check if @EnableScheduling is present
50
+ ENABLED_SCHEDULING=$(grep -r "@EnableScheduling" "$SRC_DIR" --include="*.java" 2>/dev/null | wc -l | tr -d ' ')
51
+ if [ "$ENABLED_SCHEDULING" -gt 0 ]; then
52
+ pass "$SCHEDULED_COUNT @Scheduled tasks found with @EnableScheduling"
53
+ else
54
+ warn "$SCHEDULED_COUNT @Scheduled tasks found but @EnableScheduling not found on any configuration"
55
+ fi
56
+ else
57
+ pass "No @Scheduled tasks found"
58
+ fi
59
+ fi
60
+
61
+ # ---------------------------------------------------------------------------
62
+ # @Async Tasks
63
+ # ---------------------------------------------------------------------------
64
+ echo ""
65
+ echo "--- @Async Tasks ---"
66
+ if [ -d "$SRC_DIR" ]; then
67
+ ASYNC_COUNT=$(grep -r "@Async" "$SRC_DIR" --include="*.java" 2>/dev/null | wc -l | tr -d ' ')
68
+ if [ "$ASYNC_COUNT" -gt 0 ]; then
69
+ ENABLED_ASYNC=$(grep -r "@EnableAsync" "$SRC_DIR" --include="*.java" 2>/dev/null | wc -l | tr -d ' ')
70
+ if [ "$ENABLED_ASYNC" -gt 0 ]; then
71
+ pass "$ASYNC_COUNT @Async methods found with @EnableAsync"
72
+ else
73
+ warn "$ASYNC_COUNT @Async methods found but @EnableAsync not found"
74
+ fi
75
+ else
76
+ pass "No @Async methods found"
77
+ fi
78
+ fi
79
+
80
+ # ---------------------------------------------------------------------------
81
+ # Observability (Micrometer / Tracing)
82
+ # ---------------------------------------------------------------------------
83
+ echo ""
84
+ echo "--- Observability ---"
85
+ if [ -f "pom.xml" ] && grep -q "micrometer\|micrometer-tracing" pom.xml 2>/dev/null; then
86
+ pass "Micrometer observability found in pom.xml"
87
+ elif [ -f "build.gradle" ] && grep -q "micrometer\|micrometer-tracing" build.gradle 2>/dev/null; then
88
+ pass "Micrometer observability found in build.gradle"
89
+ elif [ -f "build.gradle.kts" ] && grep -q "micrometer\|micrometer-tracing" build.gradle.kts 2>/dev/null; then
90
+ pass "Micrometer observability found in build.gradle.kts"
91
+ else
92
+ warn "Micrometer not found — consider adding micrometer-tracing for observability"
93
+ fi
94
+
95
+ # ---------------------------------------------------------------------------
96
+ # Logging Configuration
97
+ # ---------------------------------------------------------------------------
98
+ echo ""
99
+ echo "--- Logging Configuration ---"
100
+ LOG_CONFIG=$(find . -name "logback.xml" -o -name "logback-spring.xml" -o -name "log4j2.xml" -o -name "log4j2-spring.xml" 2>/dev/null | head -5)
101
+ if [ -n "$LOG_CONFIG" ]; then
102
+ pass "Logging configuration found ($(echo "$LOG_CONFIG" | wc -l | tr -d ' ') files)"
103
+ else
104
+ warn "No logging configuration file found (consider adding logback-spring.xml)"
105
+ fi
106
+
107
+ # ---------------------------------------------------------------------------
108
+ # Profile-Specific Configuration
109
+ # ---------------------------------------------------------------------------
110
+ echo ""
111
+ echo "--- Profile-Specific Configuration ---"
112
+ PROFILE_FILES=$(find . -name "application-*.yml" -o -name "application-*.yaml" -o -name "application-*.properties" 2>/dev/null | head -10)
113
+ if [ -n "$PROFILE_FILES" ]; then
114
+ pass "Profile-specific configuration found ($(echo "$PROFILE_FILES" | wc -l | tr -d ' ') files)"
115
+ for f in $PROFILE_FILES; do
116
+ echo " - $f"
117
+ done
118
+ else
119
+ warn "No profile-specific configuration files found (consider application-dev.yml, application-prod.yml)"
120
+ fi
121
+
122
+ # ---------------------------------------------------------------------------
123
+ # Summary
124
+ # ---------------------------------------------------------------------------
125
+ echo ""
126
+ echo "============================================"
127
+ echo " Summary"
128
+ echo "============================================"
129
+ echo -e " Passed: ${GREEN}${PASS_COUNT}${NC}"
130
+ echo -e " Failed: ${RED}${#ERRORS[@]}${NC}"
131
+ echo ""
132
+
133
+ if [ ${#ERRORS[@]} -gt 0 ]; then
134
+ echo "FAILURES:"
135
+ for err in "${ERRORS[@]}"; do
136
+ echo " - $err"
137
+ done
138
+ exit 1
139
+ fi
140
+
141
+ echo -e "${GREEN}Operations validation passed.${NC}"
142
+ exit 0