pipecraft 0.0.0-releaseit

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 (176) hide show
  1. package/.claude/settings.local.json +35 -0
  2. package/.github/actions/calculate-version/action.yml +106 -0
  3. package/.github/actions/create-pr/action.yml +122 -0
  4. package/.github/actions/create-release/action.yml +74 -0
  5. package/.github/actions/create-tag/action.yml +94 -0
  6. package/.github/actions/detect-changes/action.yml +62 -0
  7. package/.github/actions/manage-branch/action.yml +113 -0
  8. package/.github/actions/promote-branch/action.yml +352 -0
  9. package/.github/example/workflows/job.analyze.code.yml +26 -0
  10. package/.github/example/workflows/job.analyze.docker.yml +32 -0
  11. package/.github/example/workflows/job.app.api.deploy.yml +127 -0
  12. package/.github/example/workflows/job.app.api.test.yml +102 -0
  13. package/.github/example/workflows/job.app.docs.deploy.yml +40 -0
  14. package/.github/example/workflows/job.app.docs.test.yml +50 -0
  15. package/.github/example/workflows/job.app.web.deploy.yml +96 -0
  16. package/.github/example/workflows/job.app.web.test.yml +49 -0
  17. package/.github/example/workflows/job.changes.yml +82 -0
  18. package/.github/example/workflows/job.create-pr.yml +96 -0
  19. package/.github/example/workflows/job.env-check.yml +43 -0
  20. package/.github/example/workflows/job.fast-forward.yml +103 -0
  21. package/.github/example/workflows/job.lint.yml +64 -0
  22. package/.github/example/workflows/job.pr-name.yml +70 -0
  23. package/.github/example/workflows/job.pr-squash-name.yml +27 -0
  24. package/.github/example/workflows/job.tag.yml +38 -0
  25. package/.github/example/workflows/job.version.yml +99 -0
  26. package/.github/example/workflows/lib.plugin-base.publish.yml +59 -0
  27. package/.github/example/workflows/pipe.yml +178 -0
  28. package/.github/example/workflows/scripts/fastforward.sh +51 -0
  29. package/.github/example/workflows/scripts/pipe-cleaner.sh +70 -0
  30. package/.github/scripts/fastforward.sh +51 -0
  31. package/.github/scripts/pipe-cleaner.sh +70 -0
  32. package/.github/workflows/pipeline.yml +220 -0
  33. package/.github/workflows/pr-title-check.yml +70 -0
  34. package/.github/workflows/publish.yml +39 -0
  35. package/.pipecraftrc.json +78 -0
  36. package/.release-it.cjs +71 -0
  37. package/PIPELINE_TESTING_PLAN.md +499 -0
  38. package/README.md +1101 -0
  39. package/TRUNK_FLOW_PLAN.md +401 -0
  40. package/assets/logo_banner.png +0 -0
  41. package/assets/logo_banner.webp +0 -0
  42. package/dist/cli/index.d.ts +3 -0
  43. package/dist/cli/index.d.ts.map +1 -0
  44. package/dist/cli/index.js +364 -0
  45. package/dist/cli/index.js.map +1 -0
  46. package/dist/generators/init.tpl.d.ts +3 -0
  47. package/dist/generators/init.tpl.d.ts.map +1 -0
  48. package/dist/generators/init.tpl.js +117 -0
  49. package/dist/generators/init.tpl.js.map +1 -0
  50. package/dist/generators/workflows.tpl.d.ts +7 -0
  51. package/dist/generators/workflows.tpl.d.ts.map +1 -0
  52. package/dist/generators/workflows.tpl.js +73 -0
  53. package/dist/generators/workflows.tpl.js.map +1 -0
  54. package/dist/templates/actions/calculate-version.yml.tpl.d.ts +3 -0
  55. package/dist/templates/actions/calculate-version.yml.tpl.d.ts.map +1 -0
  56. package/dist/templates/actions/calculate-version.yml.tpl.js +122 -0
  57. package/dist/templates/actions/calculate-version.yml.tpl.js.map +1 -0
  58. package/dist/templates/actions/create-pr.yml.tpl.d.ts +3 -0
  59. package/dist/templates/actions/create-pr.yml.tpl.d.ts.map +1 -0
  60. package/dist/templates/actions/create-pr.yml.tpl.js +145 -0
  61. package/dist/templates/actions/create-pr.yml.tpl.js.map +1 -0
  62. package/dist/templates/actions/create-tag.yml.tpl.d.ts +3 -0
  63. package/dist/templates/actions/create-tag.yml.tpl.d.ts.map +1 -0
  64. package/dist/templates/actions/create-tag.yml.tpl.js +111 -0
  65. package/dist/templates/actions/create-tag.yml.tpl.js.map +1 -0
  66. package/dist/templates/actions/detect-changes.yml.tpl.d.ts +3 -0
  67. package/dist/templates/actions/detect-changes.yml.tpl.d.ts.map +1 -0
  68. package/dist/templates/actions/detect-changes.yml.tpl.js +79 -0
  69. package/dist/templates/actions/detect-changes.yml.tpl.js.map +1 -0
  70. package/dist/templates/actions/manage-branch.yml.tpl.d.ts +3 -0
  71. package/dist/templates/actions/manage-branch.yml.tpl.d.ts.map +1 -0
  72. package/dist/templates/actions/manage-branch.yml.tpl.js +130 -0
  73. package/dist/templates/actions/manage-branch.yml.tpl.js.map +1 -0
  74. package/dist/templates/actions/promote-branch.yml.tpl.d.ts +3 -0
  75. package/dist/templates/actions/promote-branch.yml.tpl.d.ts.map +1 -0
  76. package/dist/templates/actions/promote-branch.yml.tpl.js +362 -0
  77. package/dist/templates/actions/promote-branch.yml.tpl.js.map +1 -0
  78. package/dist/templates/workflows/pipeline-path-based.yml.tpl.d.ts +16 -0
  79. package/dist/templates/workflows/pipeline-path-based.yml.tpl.d.ts.map +1 -0
  80. package/dist/templates/workflows/pipeline-path-based.yml.tpl.js +652 -0
  81. package/dist/templates/workflows/pipeline-path-based.yml.tpl.js.map +1 -0
  82. package/dist/types/index.d.ts +63 -0
  83. package/dist/types/index.d.ts.map +1 -0
  84. package/dist/types/index.js +2 -0
  85. package/dist/types/index.js.map +1 -0
  86. package/dist/utils/ast-path-operations.d.ts +287 -0
  87. package/dist/utils/ast-path-operations.d.ts.map +1 -0
  88. package/dist/utils/ast-path-operations.js +419 -0
  89. package/dist/utils/ast-path-operations.js.map +1 -0
  90. package/dist/utils/config.d.ts +3 -0
  91. package/dist/utils/config.d.ts.map +1 -0
  92. package/dist/utils/config.js +49 -0
  93. package/dist/utils/config.js.map +1 -0
  94. package/dist/utils/github-setup.d.ts +74 -0
  95. package/dist/utils/github-setup.d.ts.map +1 -0
  96. package/dist/utils/github-setup.js +418 -0
  97. package/dist/utils/github-setup.js.map +1 -0
  98. package/dist/utils/idempotency.d.ts +47 -0
  99. package/dist/utils/idempotency.d.ts.map +1 -0
  100. package/dist/utils/idempotency.js +176 -0
  101. package/dist/utils/idempotency.js.map +1 -0
  102. package/dist/utils/preflight.d.ts +55 -0
  103. package/dist/utils/preflight.d.ts.map +1 -0
  104. package/dist/utils/preflight.js +261 -0
  105. package/dist/utils/preflight.js.map +1 -0
  106. package/dist/utils/versioning.d.ts +41 -0
  107. package/dist/utils/versioning.d.ts.map +1 -0
  108. package/dist/utils/versioning.js +219 -0
  109. package/dist/utils/versioning.js.map +1 -0
  110. package/docs/USER_JOURNEY_ERRORS.md +352 -0
  111. package/eslint.config.js +77 -0
  112. package/examples/basic-config.json +41 -0
  113. package/examples/monorepo-config.json +49 -0
  114. package/examples/usage.md +289 -0
  115. package/package.json +58 -0
  116. package/scripts/debug-workflows.sh +339 -0
  117. package/scripts/parse-pipeline.js +29 -0
  118. package/scripts/test-job-order.cjs +140 -0
  119. package/scripts/validate-pipeline.cjs +379 -0
  120. package/scripts/verify-job-order.sh +30 -0
  121. package/src/cli/index.ts +414 -0
  122. package/src/generators/init.tpl.ts +126 -0
  123. package/src/generators/workflows.tpl.ts +80 -0
  124. package/src/templates/actions/calculate-version.yml.tpl.ts +124 -0
  125. package/src/templates/actions/create-pr.yml.tpl.ts +147 -0
  126. package/src/templates/actions/create-tag.yml.tpl.ts +112 -0
  127. package/src/templates/actions/detect-changes.yml.tpl.ts +87 -0
  128. package/src/templates/actions/manage-branch.yml.tpl.ts +132 -0
  129. package/src/templates/actions/promote-branch.yml.tpl.ts +364 -0
  130. package/src/templates/workflows/pipeline-path-based.yml.tpl.ts +706 -0
  131. package/src/types/index.ts +64 -0
  132. package/src/utils/README-ast-path-operations.md +390 -0
  133. package/src/utils/ast-path-operations.ts +581 -0
  134. package/src/utils/config.ts +64 -0
  135. package/src/utils/github-setup.ts +558 -0
  136. package/src/utils/idempotency.ts +215 -0
  137. package/src/utils/preflight.ts +306 -0
  138. package/src/utils/versioning.ts +244 -0
  139. package/tests/README.md +229 -0
  140. package/tests/TEST_STRUCTURE.md +256 -0
  141. package/tests/act/run-act-tests.sh +345 -0
  142. package/tests/debugging/debug-utils.ts +538 -0
  143. package/tests/debugging/debug-workflow.test.ts +339 -0
  144. package/tests/debugging/debug-workflows.sh +339 -0
  145. package/tests/debugging/iterative-debug.ts +652 -0
  146. package/tests/debugging/run-debug-tests.sh +431 -0
  147. package/tests/fixtures/basic-config.json +51 -0
  148. package/tests/fixtures/invalid-config.json +9 -0
  149. package/tests/fixtures/pipeline-generated.yml +235 -0
  150. package/tests/fixtures/pipeline-preserve-comments.yml +245 -0
  151. package/tests/fixtures/pipeline-user-modified.yml +245 -0
  152. package/tests/fixtures/test-config.json +58 -0
  153. package/tests/github-live/README.md +250 -0
  154. package/tests/github-local/JOB_WORKFLOW_TESTS.md +296 -0
  155. package/tests/github-local/README.md +240 -0
  156. package/tests/github-local/run-all-tests.sh +422 -0
  157. package/tests/github-local/test-job-workflows.sh +631 -0
  158. package/tests/github-local/test-pipeline-workflow.sh +440 -0
  159. package/tests/integration/generators.test.ts +578 -0
  160. package/tests/integration/path-based-template.test.ts +510 -0
  161. package/tests/integration/simple-path-based.test.ts +415 -0
  162. package/tests/setup.ts +56 -0
  163. package/tests/unit/ast-path-operations-extended.test.ts +302 -0
  164. package/tests/unit/cli.test.ts +541 -0
  165. package/tests/unit/config-extended.test.ts +412 -0
  166. package/tests/unit/config.test.ts +152 -0
  167. package/tests/unit/github-setup.test.ts +189 -0
  168. package/tests/unit/idempotency-isolated.test.ts +297 -0
  169. package/tests/unit/job-order.test.ts +157 -0
  170. package/tests/unit/pipeline-path-based.test.ts +511 -0
  171. package/tests/unit/validate-pipeline.test.ts +384 -0
  172. package/tests/unit/versioning-extended.test.ts +279 -0
  173. package/tests/unit/versioning.test.ts +241 -0
  174. package/tsconfig.debug.json +17 -0
  175. package/tsconfig.json +28 -0
  176. package/vitest.config.ts +51 -0
@@ -0,0 +1,440 @@
1
+ #!/bin/bash
2
+
3
+ # GitHub Actions Pipeline Workflow Testing Script
4
+ # Tests the main pipeline workflow using Act
5
+
6
+ set -euo pipefail
7
+
8
+ # Colors for output
9
+ RED='\033[0;31m'
10
+ GREEN='\033[0;32m'
11
+ YELLOW='\033[1;33m'
12
+ BLUE='\033[0;34m'
13
+ PURPLE='\033[0;35m'
14
+ CYAN='\033[0;36m'
15
+ NC='\033[0m' # No Color
16
+
17
+ # Configuration
18
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
19
+ PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
20
+ WORKFLOWS_DIR="$PROJECT_ROOT/.github/workflows"
21
+ OUTPUT_DIR="$SCRIPT_DIR/output"
22
+ VERBOSE=false
23
+ DEBUG=false
24
+ CLEANUP=true
25
+
26
+ # Function to print colored output
27
+ print_status() {
28
+ local status=$1
29
+ local message=$2
30
+
31
+ case $status in
32
+ "SUCCESS") echo -e "${GREEN}✓${NC} $message" ;;
33
+ "FAILURE") echo -e "${RED}✗${NC} $message" ;;
34
+ "WARNING") echo -e "${YELLOW}⚠${NC} $message" ;;
35
+ "INFO") echo -e "${BLUE}ℹ${NC} $message" ;;
36
+ "DEBUG") echo -e "${PURPLE}🐛${NC} $message" ;;
37
+ *) echo -e "${CYAN}?${NC} $message" ;;
38
+ esac
39
+ }
40
+
41
+ # Function to show usage
42
+ show_usage() {
43
+ cat << EOF
44
+ Usage: $0 [OPTIONS]
45
+
46
+ GitHub Actions Pipeline Workflow Testing Script
47
+
48
+ OPTIONS:
49
+ -v, --verbose Verbose output
50
+ -d, --debug Debug mode with extra logging
51
+ -c, --no-cleanup Don't clean up test artifacts
52
+ -h, --help Show this help message
53
+
54
+ EXAMPLES:
55
+ $0 # Test pipeline workflow
56
+ $0 -v -d # Verbose debug mode
57
+ $0 --no-cleanup # Test pipeline, keep artifacts
58
+
59
+ EOF
60
+ }
61
+
62
+ # Function to check prerequisites
63
+ check_prerequisites() {
64
+ print_status "INFO" "Checking prerequisites..."
65
+
66
+ local missing_deps=()
67
+
68
+ # Check for required commands
69
+ if ! command -v act &> /dev/null; then
70
+ missing_deps+=("act")
71
+ fi
72
+
73
+ if ! command -v docker &> /dev/null; then
74
+ missing_deps+=("docker")
75
+ fi
76
+
77
+ if ! command -v jq &> /dev/null; then
78
+ missing_deps+=("jq")
79
+ fi
80
+
81
+ if [ ${#missing_deps[@]} -gt 0 ]; then
82
+ print_status "FAILURE" "Missing dependencies: ${missing_deps[*]}"
83
+ echo -e "${YELLOW}Please install missing dependencies:${NC}"
84
+ for dep in "${missing_deps[@]}"; do
85
+ case $dep in
86
+ "act") echo " - Act: curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash" ;;
87
+ "docker") echo " - Docker: https://docs.docker.com/get-docker/" ;;
88
+ "jq") echo " - jq: brew install jq (macOS) or apt-get install jq (Ubuntu)" ;;
89
+ esac
90
+ done
91
+ exit 1
92
+ fi
93
+
94
+ # Check if Docker is running
95
+ if ! docker info &> /dev/null; then
96
+ print_status "FAILURE" "Docker is not running"
97
+ echo -e "${YELLOW}Please start Docker and try again${NC}"
98
+ exit 1
99
+ fi
100
+
101
+ print_status "SUCCESS" "All prerequisites satisfied"
102
+ }
103
+
104
+ # Function to setup test environment
105
+ setup_test_environment() {
106
+ print_status "INFO" "Setting up test environment..."
107
+
108
+ # Create output directory
109
+ mkdir -p "$OUTPUT_DIR"
110
+
111
+ # Create test configuration
112
+ cat > "$PROJECT_ROOT/.actrc" << EOF
113
+ # Act configuration for testing
114
+ -P ubuntu-latest=catthehacker/ubuntu:act-latest
115
+ -P ubuntu-20.04=catthehacker/ubuntu:act-20.04
116
+ -P ubuntu-18.04=catthehacker/ubuntu:act-18.04
117
+ EOF
118
+
119
+ # Create test environment file
120
+ cat > "$PROJECT_ROOT/.env" << EOF
121
+ # Test environment variables
122
+ GITHUB_ACTIONS=true
123
+ GITHUB_WORKFLOW=test-workflow
124
+ GITHUB_RUN_ID=123456789
125
+ GITHUB_RUN_NUMBER=1
126
+ GITHUB_ACTOR=test-user
127
+ GITHUB_REPOSITORY=test-org/test-repo
128
+ GITHUB_EVENT_NAME=push
129
+ GITHUB_SHA=abc123def456
130
+ GITHUB_REF=refs/heads/main
131
+ GITHUB_HEAD_REF=""
132
+ GITHUB_BASE_REF=""
133
+ GITHUB_WORKSPACE=$PROJECT_ROOT
134
+ GITHUB_TOKEN=test-token
135
+ EOF
136
+
137
+ print_status "SUCCESS" "Test environment setup complete"
138
+ }
139
+
140
+ # Function to test pipeline workflow
141
+ test_pipeline_workflow() {
142
+ local workflow_file="$WORKFLOWS_DIR/pipeline.yml"
143
+
144
+ if [ ! -f "$workflow_file" ]; then
145
+ print_status "FAILURE" "Pipeline workflow not found: $workflow_file"
146
+ return 1
147
+ fi
148
+
149
+ print_status "INFO" "Testing Pipeline workflow..."
150
+
151
+ # Test with different branch scenarios
152
+ local test_scenarios=(
153
+ "refs/heads/main"
154
+ "refs/heads/develop"
155
+ "refs/heads/staging"
156
+ "refs/heads/test"
157
+ )
158
+
159
+ for ref in "${test_scenarios[@]}"; do
160
+ print_status "DEBUG" "Testing pipeline with ref: $ref"
161
+
162
+ local act_args=(
163
+ "-W" "$workflow_file"
164
+ "--dry-run"
165
+ "--env" "GITHUB_REF=$ref"
166
+ "--env-file" "$PROJECT_ROOT/.env"
167
+ )
168
+
169
+ if [ "$VERBOSE" = true ]; then
170
+ act_args+=("--verbose")
171
+ fi
172
+
173
+ if [ "$DEBUG" = true ]; then
174
+ act_args+=("--debug")
175
+ fi
176
+
177
+ if act "${act_args[@]}" > "$OUTPUT_DIR/pipeline-${ref//\//-}.log" 2>&1; then
178
+ print_status "SUCCESS" "Pipeline workflow passed for $ref"
179
+ else
180
+ print_status "FAILURE" "Pipeline workflow failed for $ref"
181
+ if [ "$VERBOSE" = true ]; then
182
+ echo "Error details:"
183
+ cat "$OUTPUT_DIR/pipeline-${ref//\//-}.log"
184
+ fi
185
+ return 1
186
+ fi
187
+ done
188
+
189
+ print_status "SUCCESS" "Pipeline workflow testing completed"
190
+ }
191
+
192
+ # Function to test pipeline with different events
193
+ test_pipeline_events() {
194
+ local workflow_file="$WORKFLOWS_DIR/pipeline.yml"
195
+
196
+ print_status "INFO" "Testing Pipeline workflow with different events..."
197
+
198
+ # Test with different GitHub events
199
+ local test_events=(
200
+ "push"
201
+ "pull_request"
202
+ "workflow_dispatch"
203
+ )
204
+
205
+ for event in "${test_events[@]}"; do
206
+ print_status "DEBUG" "Testing pipeline with event: $event"
207
+
208
+ local act_args=(
209
+ "-W" "$workflow_file"
210
+ "--dry-run"
211
+ "--event" "$event"
212
+ "--env-file" "$PROJECT_ROOT/.env"
213
+ )
214
+
215
+ if [ "$VERBOSE" = true ]; then
216
+ act_args+=("--verbose")
217
+ fi
218
+
219
+ if [ "$DEBUG" = true ]; then
220
+ act_args+=("--debug")
221
+ fi
222
+
223
+ if act "${act_args[@]}" > "$OUTPUT_DIR/pipeline-${event}.log" 2>&1; then
224
+ print_status "SUCCESS" "Pipeline workflow passed for $event event"
225
+ else
226
+ print_status "FAILURE" "Pipeline workflow failed for $event event"
227
+ if [ "$VERBOSE" = true ]; then
228
+ echo "Error details:"
229
+ cat "$OUTPUT_DIR/pipeline-${event}.log"
230
+ fi
231
+ return 1
232
+ fi
233
+ done
234
+
235
+ print_status "SUCCESS" "Pipeline event testing completed"
236
+ }
237
+
238
+ # Function to test pipeline job dependencies
239
+ test_pipeline_dependencies() {
240
+ local workflow_file="$WORKFLOWS_DIR/pipeline.yml"
241
+
242
+ print_status "INFO" "Testing Pipeline workflow job dependencies..."
243
+
244
+ # Test workflow structure and job dependencies
245
+ local act_args=(
246
+ "-W" "$workflow_file"
247
+ "--list"
248
+ "--env-file" "$PROJECT_ROOT/.env"
249
+ )
250
+
251
+ if act "${act_args[@]}" > "$OUTPUT_DIR/pipeline-jobs.log" 2>&1; then
252
+ print_status "SUCCESS" "Pipeline job dependencies validated"
253
+
254
+ # Parse job information
255
+ if [ "$VERBOSE" = true ]; then
256
+ echo "Job information:"
257
+ cat "$OUTPUT_DIR/pipeline-jobs.log"
258
+ fi
259
+ else
260
+ print_status "FAILURE" "Pipeline job dependencies validation failed"
261
+ if [ "$VERBOSE" = true ]; then
262
+ echo "Error details:"
263
+ cat "$OUTPUT_DIR/pipeline-jobs.log"
264
+ fi
265
+ return 1
266
+ fi
267
+
268
+ print_status "SUCCESS" "Pipeline dependencies testing completed"
269
+ }
270
+
271
+ # Function to test pipeline with custom inputs
272
+ test_pipeline_inputs() {
273
+ local workflow_file="$WORKFLOWS_DIR/pipeline.yml"
274
+
275
+ print_status "INFO" "Testing Pipeline workflow with custom inputs..."
276
+
277
+ # Test with workflow_dispatch inputs
278
+ local act_args=(
279
+ "-W" "$workflow_file"
280
+ "--dry-run"
281
+ "--event" "workflow_dispatch"
282
+ "--input" "migration_input=true"
283
+ "--input" "seed_input=false"
284
+ "--env-file" "$PROJECT_ROOT/.env"
285
+ )
286
+
287
+ if [ "$VERBOSE" = true ]; then
288
+ act_args+=("--verbose")
289
+ fi
290
+
291
+ if [ "$DEBUG" = true ]; then
292
+ act_args+=("--debug")
293
+ fi
294
+
295
+ if act "${act_args[@]}" > "$OUTPUT_DIR/pipeline-inputs.log" 2>&1; then
296
+ print_status "SUCCESS" "Pipeline workflow passed with custom inputs"
297
+ else
298
+ print_status "FAILURE" "Pipeline workflow failed with custom inputs"
299
+ if [ "$VERBOSE" = true ]; then
300
+ echo "Error details:"
301
+ cat "$OUTPUT_DIR/pipeline-inputs.log"
302
+ fi
303
+ return 1
304
+ fi
305
+
306
+ print_status "SUCCESS" "Pipeline inputs testing completed"
307
+ }
308
+
309
+ # Function to test all pipeline scenarios
310
+ test_all_pipeline_scenarios() {
311
+ print_status "INFO" "Testing all pipeline scenarios..."
312
+
313
+ local failed_tests=0
314
+ local total_tests=0
315
+
316
+ # Test each scenario
317
+ local test_functions=(
318
+ "test_pipeline_workflow:Pipeline Workflow"
319
+ "test_pipeline_events:Pipeline Events"
320
+ "test_pipeline_dependencies:Pipeline Dependencies"
321
+ "test_pipeline_inputs:Pipeline Inputs"
322
+ )
323
+
324
+ for test in "${test_functions[@]}"; do
325
+ IFS=':' read -r test_function test_name <<< "$test"
326
+ total_tests=$((total_tests + 1))
327
+
328
+ print_status "INFO" "Testing $test_name..."
329
+ if $test_function; then
330
+ print_status "SUCCESS" "✅ $test_name passed"
331
+ else
332
+ print_status "FAILURE" "❌ $test_name failed"
333
+ failed_tests=$((failed_tests + 1))
334
+ fi
335
+ done
336
+
337
+ # Summary
338
+ echo ""
339
+ print_status "INFO" "Test Summary:"
340
+ echo " Total scenarios: $total_tests"
341
+ echo " Passed: $((total_tests - failed_tests))"
342
+ echo " Failed: $failed_tests"
343
+
344
+ if [ $failed_tests -gt 0 ]; then
345
+ print_status "FAILURE" "Some pipeline scenarios failed testing"
346
+ return 1
347
+ else
348
+ print_status "SUCCESS" "All pipeline scenarios passed testing"
349
+ return 0
350
+ fi
351
+ }
352
+
353
+ # Function to cleanup test artifacts
354
+ cleanup_test_artifacts() {
355
+ if [ "$CLEANUP" = true ]; then
356
+ print_status "INFO" "Cleaning up test artifacts..."
357
+
358
+ # Remove test files
359
+ rm -f "$PROJECT_ROOT/.actrc"
360
+ rm -f "$PROJECT_ROOT/.env"
361
+
362
+ # Clean up output directory
363
+ if [ -d "$OUTPUT_DIR" ]; then
364
+ rm -rf "$OUTPUT_DIR"
365
+ fi
366
+
367
+ print_status "SUCCESS" "Cleanup complete"
368
+ fi
369
+ }
370
+
371
+ # Function to show test results
372
+ show_test_results() {
373
+ if [ -d "$OUTPUT_DIR" ]; then
374
+ echo ""
375
+ print_status "INFO" "Test Results:"
376
+ echo " Output directory: $OUTPUT_DIR"
377
+
378
+ if [ "$VERBOSE" = true ]; then
379
+ echo " Log files:"
380
+ find "$OUTPUT_DIR" -name "*.log" -exec basename {} \; | while read -r log_file; do
381
+ echo " - $log_file"
382
+ done
383
+ fi
384
+ fi
385
+ }
386
+
387
+ # Parse command line arguments
388
+ while [[ $# -gt 0 ]]; do
389
+ case $1 in
390
+ -v|--verbose)
391
+ VERBOSE=true
392
+ shift
393
+ ;;
394
+ -d|--debug)
395
+ DEBUG=true
396
+ shift
397
+ ;;
398
+ -c|--no-cleanup)
399
+ CLEANUP=false
400
+ shift
401
+ ;;
402
+ -h|--help)
403
+ show_usage
404
+ exit 0
405
+ ;;
406
+ *)
407
+ echo -e "${RED}Unknown option: $1${NC}" >&2
408
+ show_usage
409
+ exit 1
410
+ ;;
411
+ esac
412
+ done
413
+
414
+ # Main execution
415
+ main() {
416
+ echo -e "${BLUE}GitHub Actions Pipeline Workflow Testing${NC}"
417
+ echo -e "${CYAN}=========================================${NC}"
418
+ echo ""
419
+
420
+ # Check prerequisites
421
+ check_prerequisites
422
+
423
+ # Setup test environment
424
+ setup_test_environment
425
+
426
+ # Run all pipeline tests
427
+ test_all_pipeline_scenarios
428
+
429
+ # Show results
430
+ show_test_results
431
+
432
+ # Cleanup
433
+ cleanup_test_artifacts
434
+
435
+ echo ""
436
+ print_status "SUCCESS" "Pipeline workflow testing complete!"
437
+ }
438
+
439
+ # Run main function
440
+ main "$@"