pipecraft 0.0.0-releaseit → 0.26.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.
- package/README.md +126 -108
- package/dist/cli/index.d.ts +69 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +94 -22
- package/dist/cli/index.js.map +1 -1
- package/dist/generators/init.tpl.d.ts +70 -0
- package/dist/generators/init.tpl.d.ts.map +1 -1
- package/dist/generators/init.tpl.js +100 -8
- package/dist/generators/init.tpl.js.map +1 -1
- package/dist/generators/workflows.tpl.d.ts +86 -0
- package/dist/generators/workflows.tpl.d.ts.map +1 -1
- package/dist/generators/workflows.tpl.js +101 -9
- package/dist/generators/workflows.tpl.js.map +1 -1
- package/dist/templates/actions/calculate-version.yml.tpl.d.ts +47 -0
- package/dist/templates/actions/calculate-version.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/calculate-version.yml.tpl.js +72 -3
- package/dist/templates/actions/calculate-version.yml.tpl.js.map +1 -1
- package/dist/templates/actions/create-pr.yml.tpl.d.ts +14 -0
- package/dist/templates/actions/create-pr.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/create-pr.yml.tpl.js +22 -2
- package/dist/templates/actions/create-pr.yml.tpl.js.map +1 -1
- package/dist/templates/actions/create-release.yml.tpl.d.ts +18 -0
- package/dist/templates/actions/create-release.yml.tpl.d.ts.map +1 -0
- package/dist/templates/actions/create-release.yml.tpl.js +141 -0
- package/dist/templates/actions/create-release.yml.tpl.js.map +1 -0
- package/dist/templates/actions/create-tag.yml.tpl.d.ts +14 -0
- package/dist/templates/actions/create-tag.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/create-tag.yml.tpl.js +22 -2
- package/dist/templates/actions/create-tag.yml.tpl.js.map +1 -1
- package/dist/templates/actions/detect-changes.yml.tpl.d.ts +70 -0
- package/dist/templates/actions/detect-changes.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/detect-changes.yml.tpl.js +98 -2
- package/dist/templates/actions/detect-changes.yml.tpl.js.map +1 -1
- package/dist/templates/actions/manage-branch.yml.tpl.d.ts +14 -0
- package/dist/templates/actions/manage-branch.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/manage-branch.yml.tpl.js +22 -2
- package/dist/templates/actions/manage-branch.yml.tpl.js.map +1 -1
- package/dist/templates/actions/promote-branch.yml.tpl.d.ts +14 -0
- package/dist/templates/actions/promote-branch.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/promote-branch.yml.tpl.js +50 -7
- package/dist/templates/actions/promote-branch.yml.tpl.js.map +1 -1
- package/dist/templates/workflows/pipeline-path-based.yml.tpl.d.ts +114 -1
- package/dist/templates/workflows/pipeline-path-based.yml.tpl.d.ts.map +1 -1
- package/dist/templates/workflows/pipeline-path-based.yml.tpl.js +479 -74
- package/dist/templates/workflows/pipeline-path-based.yml.tpl.js.map +1 -1
- package/dist/types/index.d.ts +231 -8
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +9 -0
- package/dist/types/index.js.map +1 -1
- package/dist/utils/ast-path-operations.d.ts.map +1 -1
- package/dist/utils/ast-path-operations.js +24 -11
- package/dist/utils/ast-path-operations.js.map +1 -1
- package/dist/utils/config.d.ts +63 -0
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +71 -0
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/github-setup.d.ts +323 -2
- package/dist/utils/github-setup.d.ts.map +1 -1
- package/dist/utils/github-setup.js +551 -23
- package/dist/utils/github-setup.js.map +1 -1
- package/dist/utils/idempotency.d.ts +147 -7
- package/dist/utils/idempotency.d.ts.map +1 -1
- package/dist/utils/idempotency.js +143 -15
- package/dist/utils/idempotency.js.map +1 -1
- package/dist/utils/logger.d.ts +134 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +153 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/preflight.d.ts +223 -12
- package/dist/utils/preflight.d.ts.map +1 -1
- package/dist/utils/preflight.js +216 -16
- package/dist/utils/preflight.js.map +1 -1
- package/dist/utils/versioning.d.ts +160 -8
- package/dist/utils/versioning.d.ts.map +1 -1
- package/dist/utils/versioning.js +179 -15
- package/dist/utils/versioning.js.map +1 -1
- package/package.json +26 -5
- package/.claude/settings.local.json +0 -35
- package/.github/actions/calculate-version/action.yml +0 -106
- package/.github/actions/create-pr/action.yml +0 -122
- package/.github/actions/create-release/action.yml +0 -74
- package/.github/actions/create-tag/action.yml +0 -94
- package/.github/actions/detect-changes/action.yml +0 -62
- package/.github/actions/manage-branch/action.yml +0 -113
- package/.github/actions/promote-branch/action.yml +0 -352
- package/.github/example/workflows/job.analyze.code.yml +0 -26
- package/.github/example/workflows/job.analyze.docker.yml +0 -32
- package/.github/example/workflows/job.app.api.deploy.yml +0 -127
- package/.github/example/workflows/job.app.api.test.yml +0 -102
- package/.github/example/workflows/job.app.docs.deploy.yml +0 -40
- package/.github/example/workflows/job.app.docs.test.yml +0 -50
- package/.github/example/workflows/job.app.web.deploy.yml +0 -96
- package/.github/example/workflows/job.app.web.test.yml +0 -49
- package/.github/example/workflows/job.changes.yml +0 -82
- package/.github/example/workflows/job.create-pr.yml +0 -96
- package/.github/example/workflows/job.env-check.yml +0 -43
- package/.github/example/workflows/job.fast-forward.yml +0 -103
- package/.github/example/workflows/job.lint.yml +0 -64
- package/.github/example/workflows/job.pr-name.yml +0 -70
- package/.github/example/workflows/job.pr-squash-name.yml +0 -27
- package/.github/example/workflows/job.tag.yml +0 -38
- package/.github/example/workflows/job.version.yml +0 -99
- package/.github/example/workflows/lib.plugin-base.publish.yml +0 -59
- package/.github/example/workflows/pipe.yml +0 -178
- package/.github/example/workflows/scripts/fastforward.sh +0 -51
- package/.github/example/workflows/scripts/pipe-cleaner.sh +0 -70
- package/.github/scripts/fastforward.sh +0 -51
- package/.github/scripts/pipe-cleaner.sh +0 -70
- package/.github/workflows/pipeline.yml +0 -220
- package/.github/workflows/pr-title-check.yml +0 -70
- package/.github/workflows/publish.yml +0 -39
- package/.pipecraftrc.json +0 -78
- package/.release-it.cjs +0 -71
- package/PIPELINE_TESTING_PLAN.md +0 -499
- package/TRUNK_FLOW_PLAN.md +0 -401
- package/assets/logo_banner.png +0 -0
- package/assets/logo_banner.webp +0 -0
- package/docs/USER_JOURNEY_ERRORS.md +0 -352
- package/eslint.config.js +0 -77
- package/examples/basic-config.json +0 -41
- package/examples/monorepo-config.json +0 -49
- package/examples/usage.md +0 -289
- package/scripts/debug-workflows.sh +0 -339
- package/scripts/parse-pipeline.js +0 -29
- package/scripts/test-job-order.cjs +0 -140
- package/scripts/validate-pipeline.cjs +0 -379
- package/scripts/verify-job-order.sh +0 -30
- package/src/cli/index.ts +0 -414
- package/src/generators/init.tpl.ts +0 -126
- package/src/generators/workflows.tpl.ts +0 -80
- package/src/templates/actions/calculate-version.yml.tpl.ts +0 -124
- package/src/templates/actions/create-pr.yml.tpl.ts +0 -147
- package/src/templates/actions/create-tag.yml.tpl.ts +0 -112
- package/src/templates/actions/detect-changes.yml.tpl.ts +0 -87
- package/src/templates/actions/manage-branch.yml.tpl.ts +0 -132
- package/src/templates/actions/promote-branch.yml.tpl.ts +0 -364
- package/src/templates/workflows/pipeline-path-based.yml.tpl.ts +0 -706
- package/src/types/index.ts +0 -64
- package/src/utils/README-ast-path-operations.md +0 -390
- package/src/utils/ast-path-operations.ts +0 -581
- package/src/utils/config.ts +0 -64
- package/src/utils/github-setup.ts +0 -558
- package/src/utils/idempotency.ts +0 -215
- package/src/utils/preflight.ts +0 -306
- package/src/utils/versioning.ts +0 -244
- package/tests/README.md +0 -229
- package/tests/TEST_STRUCTURE.md +0 -256
- package/tests/act/run-act-tests.sh +0 -345
- package/tests/debugging/debug-utils.ts +0 -538
- package/tests/debugging/debug-workflow.test.ts +0 -339
- package/tests/debugging/debug-workflows.sh +0 -339
- package/tests/debugging/iterative-debug.ts +0 -652
- package/tests/debugging/run-debug-tests.sh +0 -431
- package/tests/fixtures/basic-config.json +0 -51
- package/tests/fixtures/invalid-config.json +0 -9
- package/tests/fixtures/pipeline-generated.yml +0 -235
- package/tests/fixtures/pipeline-preserve-comments.yml +0 -245
- package/tests/fixtures/pipeline-user-modified.yml +0 -245
- package/tests/fixtures/test-config.json +0 -58
- package/tests/github-live/README.md +0 -250
- package/tests/github-local/JOB_WORKFLOW_TESTS.md +0 -296
- package/tests/github-local/README.md +0 -240
- package/tests/github-local/run-all-tests.sh +0 -422
- package/tests/github-local/test-job-workflows.sh +0 -631
- package/tests/github-local/test-pipeline-workflow.sh +0 -440
- package/tests/integration/generators.test.ts +0 -578
- package/tests/integration/path-based-template.test.ts +0 -510
- package/tests/integration/simple-path-based.test.ts +0 -415
- package/tests/setup.ts +0 -56
- package/tests/unit/ast-path-operations-extended.test.ts +0 -302
- package/tests/unit/cli.test.ts +0 -541
- package/tests/unit/config-extended.test.ts +0 -412
- package/tests/unit/config.test.ts +0 -152
- package/tests/unit/github-setup.test.ts +0 -189
- package/tests/unit/idempotency-isolated.test.ts +0 -297
- package/tests/unit/job-order.test.ts +0 -157
- package/tests/unit/pipeline-path-based.test.ts +0 -511
- package/tests/unit/validate-pipeline.test.ts +0 -384
- package/tests/unit/versioning-extended.test.ts +0 -279
- package/tests/unit/versioning.test.ts +0 -241
- package/tsconfig.debug.json +0 -17
- package/tsconfig.json +0 -28
- package/vitest.config.ts +0 -51
|
@@ -1,631 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# GitHub Actions Job Workflow Testing Script
|
|
4
|
-
# Tests individual job workflows 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 Job Workflow Testing Script
|
|
47
|
-
|
|
48
|
-
OPTIONS:
|
|
49
|
-
-w, --workflow FILE Test specific workflow file
|
|
50
|
-
-v, --verbose Verbose output
|
|
51
|
-
-d, --debug Debug mode with extra logging
|
|
52
|
-
-c, --no-cleanup Don't clean up test artifacts
|
|
53
|
-
-h, --help Show this help message
|
|
54
|
-
|
|
55
|
-
EXAMPLES:
|
|
56
|
-
$0 # Test all job workflows
|
|
57
|
-
$0 -w job.changes.yml # Test specific workflow
|
|
58
|
-
$0 -v -d # Verbose debug mode
|
|
59
|
-
$0 -w job.version.yml --no-cleanup # Test version workflow, keep artifacts
|
|
60
|
-
|
|
61
|
-
EOF
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
# Function to check prerequisites
|
|
65
|
-
check_prerequisites() {
|
|
66
|
-
print_status "INFO" "Checking prerequisites..."
|
|
67
|
-
|
|
68
|
-
local missing_deps=()
|
|
69
|
-
|
|
70
|
-
# Check for required commands
|
|
71
|
-
if ! command -v act &> /dev/null; then
|
|
72
|
-
missing_deps+=("act")
|
|
73
|
-
fi
|
|
74
|
-
|
|
75
|
-
if ! command -v docker &> /dev/null; then
|
|
76
|
-
missing_deps+=("docker")
|
|
77
|
-
fi
|
|
78
|
-
|
|
79
|
-
if ! command -v jq &> /dev/null; then
|
|
80
|
-
missing_deps+=("jq")
|
|
81
|
-
fi
|
|
82
|
-
|
|
83
|
-
if [ ${#missing_deps[@]} -gt 0 ]; then
|
|
84
|
-
print_status "FAILURE" "Missing dependencies: ${missing_deps[*]}"
|
|
85
|
-
echo -e "${YELLOW}Please install missing dependencies:${NC}"
|
|
86
|
-
for dep in "${missing_deps[@]}"; do
|
|
87
|
-
case $dep in
|
|
88
|
-
"act") echo " - Act: curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash" ;;
|
|
89
|
-
"docker") echo " - Docker: https://docs.docker.com/get-docker/" ;;
|
|
90
|
-
"jq") echo " - jq: brew install jq (macOS) or apt-get install jq (Ubuntu)" ;;
|
|
91
|
-
esac
|
|
92
|
-
done
|
|
93
|
-
exit 1
|
|
94
|
-
fi
|
|
95
|
-
|
|
96
|
-
# Check if Docker is running
|
|
97
|
-
if ! docker info &> /dev/null; then
|
|
98
|
-
print_status "FAILURE" "Docker is not running"
|
|
99
|
-
echo -e "${YELLOW}Please start Docker and try again${NC}"
|
|
100
|
-
exit 1
|
|
101
|
-
fi
|
|
102
|
-
|
|
103
|
-
print_status "SUCCESS" "All prerequisites satisfied"
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
# Function to setup test environment
|
|
107
|
-
setup_test_environment() {
|
|
108
|
-
print_status "INFO" "Setting up test environment..."
|
|
109
|
-
|
|
110
|
-
# Create output directory
|
|
111
|
-
mkdir -p "$OUTPUT_DIR"
|
|
112
|
-
|
|
113
|
-
# Create test configuration
|
|
114
|
-
cat > "$PROJECT_ROOT/.actrc" << EOF
|
|
115
|
-
# Act configuration for testing
|
|
116
|
-
-P ubuntu-latest=catthehacker/ubuntu:act-latest
|
|
117
|
-
-P ubuntu-20.04=catthehacker/ubuntu:act-20.04
|
|
118
|
-
-P ubuntu-18.04=catthehacker/ubuntu:act-18.04
|
|
119
|
-
EOF
|
|
120
|
-
|
|
121
|
-
# Create test environment file
|
|
122
|
-
cat > "$PROJECT_ROOT/.env" << EOF
|
|
123
|
-
# Test environment variables
|
|
124
|
-
GITHUB_ACTIONS=true
|
|
125
|
-
GITHUB_WORKFLOW=test-workflow
|
|
126
|
-
GITHUB_RUN_ID=123456789
|
|
127
|
-
GITHUB_RUN_NUMBER=1
|
|
128
|
-
GITHUB_ACTOR=test-user
|
|
129
|
-
GITHUB_REPOSITORY=test-org/test-repo
|
|
130
|
-
GITHUB_EVENT_NAME=push
|
|
131
|
-
GITHUB_SHA=abc123def456
|
|
132
|
-
GITHUB_REF=refs/heads/main
|
|
133
|
-
GITHUB_HEAD_REF=""
|
|
134
|
-
GITHUB_BASE_REF=""
|
|
135
|
-
GITHUB_WORKSPACE=$PROJECT_ROOT
|
|
136
|
-
GITHUB_TOKEN=test-token
|
|
137
|
-
EOF
|
|
138
|
-
|
|
139
|
-
print_status "SUCCESS" "Test environment setup complete"
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
# Function to test changes workflow
|
|
143
|
-
test_changes_workflow() {
|
|
144
|
-
local workflow_file="$WORKFLOWS_DIR/job.changes.yml"
|
|
145
|
-
|
|
146
|
-
if [ ! -f "$workflow_file" ]; then
|
|
147
|
-
print_status "WARNING" "Changes workflow not found: $workflow_file"
|
|
148
|
-
return 0
|
|
149
|
-
fi
|
|
150
|
-
|
|
151
|
-
print_status "INFO" "Testing Changes workflow..."
|
|
152
|
-
|
|
153
|
-
# Test with different branch scenarios
|
|
154
|
-
local test_scenarios=(
|
|
155
|
-
"refs/heads/main"
|
|
156
|
-
"refs/heads/develop"
|
|
157
|
-
"refs/heads/staging"
|
|
158
|
-
"refs/heads/test"
|
|
159
|
-
)
|
|
160
|
-
|
|
161
|
-
for ref in "${test_scenarios[@]}"; do
|
|
162
|
-
print_status "DEBUG" "Testing with ref: $ref"
|
|
163
|
-
|
|
164
|
-
local act_args=(
|
|
165
|
-
"-W" "$workflow_file"
|
|
166
|
-
"--dry-run"
|
|
167
|
-
"--env" "GITHUB_REF=$ref"
|
|
168
|
-
"--env-file" "$PROJECT_ROOT/.env"
|
|
169
|
-
)
|
|
170
|
-
|
|
171
|
-
if [ "$VERBOSE" = true ]; then
|
|
172
|
-
act_args+=("--verbose")
|
|
173
|
-
fi
|
|
174
|
-
|
|
175
|
-
if [ "$DEBUG" = true ]; then
|
|
176
|
-
act_args+=("--debug")
|
|
177
|
-
fi
|
|
178
|
-
|
|
179
|
-
if act "${act_args[@]}" > "$OUTPUT_DIR/changes-${ref//\//-}.log" 2>&1; then
|
|
180
|
-
print_status "SUCCESS" "Changes workflow passed for $ref"
|
|
181
|
-
else
|
|
182
|
-
print_status "FAILURE" "Changes workflow failed for $ref"
|
|
183
|
-
if [ "$VERBOSE" = true ]; then
|
|
184
|
-
echo "Error details:"
|
|
185
|
-
cat "$OUTPUT_DIR/changes-${ref//\//-}.log"
|
|
186
|
-
fi
|
|
187
|
-
return 1
|
|
188
|
-
fi
|
|
189
|
-
done
|
|
190
|
-
|
|
191
|
-
print_status "SUCCESS" "Changes workflow testing completed"
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
# Function to test version workflow
|
|
195
|
-
test_version_workflow() {
|
|
196
|
-
local workflow_file="$WORKFLOWS_DIR/job.version.yml"
|
|
197
|
-
|
|
198
|
-
if [ ! -f "$workflow_file" ]; then
|
|
199
|
-
print_status "WARNING" "Version workflow not found: $workflow_file"
|
|
200
|
-
return 0
|
|
201
|
-
fi
|
|
202
|
-
|
|
203
|
-
print_status "INFO" "Testing Version workflow..."
|
|
204
|
-
|
|
205
|
-
# Test with different base references
|
|
206
|
-
local test_scenarios=(
|
|
207
|
-
"main"
|
|
208
|
-
"develop"
|
|
209
|
-
"staging"
|
|
210
|
-
)
|
|
211
|
-
|
|
212
|
-
for base_ref in "${test_scenarios[@]}"; do
|
|
213
|
-
print_status "DEBUG" "Testing with base ref: $base_ref"
|
|
214
|
-
|
|
215
|
-
local act_args=(
|
|
216
|
-
"-W" "$workflow_file"
|
|
217
|
-
"--dry-run"
|
|
218
|
-
"--input" "baseRef=$base_ref"
|
|
219
|
-
"--env-file" "$PROJECT_ROOT/.env"
|
|
220
|
-
)
|
|
221
|
-
|
|
222
|
-
if [ "$VERBOSE" = true ]; then
|
|
223
|
-
act_args+=("--verbose")
|
|
224
|
-
fi
|
|
225
|
-
|
|
226
|
-
if [ "$DEBUG" = true ]; then
|
|
227
|
-
act_args+=("--debug")
|
|
228
|
-
fi
|
|
229
|
-
|
|
230
|
-
if act "${act_args[@]}" > "$OUTPUT_DIR/version-${base_ref}.log" 2>&1; then
|
|
231
|
-
print_status "SUCCESS" "Version workflow passed for $base_ref"
|
|
232
|
-
else
|
|
233
|
-
print_status "FAILURE" "Version workflow failed for $base_ref"
|
|
234
|
-
if [ "$VERBOSE" = true ]; then
|
|
235
|
-
echo "Error details:"
|
|
236
|
-
cat "$OUTPUT_DIR/version-${base_ref}.log"
|
|
237
|
-
fi
|
|
238
|
-
return 1
|
|
239
|
-
fi
|
|
240
|
-
done
|
|
241
|
-
|
|
242
|
-
print_status "SUCCESS" "Version workflow testing completed"
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
# Function to test tag workflow
|
|
246
|
-
test_tag_workflow() {
|
|
247
|
-
local workflow_file="$WORKFLOWS_DIR/job.tag.yml"
|
|
248
|
-
|
|
249
|
-
if [ ! -f "$workflow_file" ]; then
|
|
250
|
-
print_status "WARNING" "Tag workflow not found: $workflow_file"
|
|
251
|
-
return 0
|
|
252
|
-
fi
|
|
253
|
-
|
|
254
|
-
print_status "INFO" "Testing Tag workflow..."
|
|
255
|
-
|
|
256
|
-
# Test with different version formats
|
|
257
|
-
local test_scenarios=(
|
|
258
|
-
"v1.0.0"
|
|
259
|
-
"v1.2.3"
|
|
260
|
-
"v2.0.0"
|
|
261
|
-
)
|
|
262
|
-
|
|
263
|
-
for version in "${test_scenarios[@]}"; do
|
|
264
|
-
print_status "DEBUG" "Testing with version: $version"
|
|
265
|
-
|
|
266
|
-
local act_args=(
|
|
267
|
-
"-W" "$workflow_file"
|
|
268
|
-
"--dry-run"
|
|
269
|
-
"--input" "version=$version"
|
|
270
|
-
"--input" "tagMessage=Test release $version"
|
|
271
|
-
"--env-file" "$PROJECT_ROOT/.env"
|
|
272
|
-
)
|
|
273
|
-
|
|
274
|
-
if [ "$VERBOSE" = true ]; then
|
|
275
|
-
act_args+=("--verbose")
|
|
276
|
-
fi
|
|
277
|
-
|
|
278
|
-
if [ "$DEBUG" = true ]; then
|
|
279
|
-
act_args+=("--debug")
|
|
280
|
-
fi
|
|
281
|
-
|
|
282
|
-
if act "${act_args[@]}" > "$OUTPUT_DIR/tag-${version}.log" 2>&1; then
|
|
283
|
-
print_status "SUCCESS" "Tag workflow passed for $version"
|
|
284
|
-
else
|
|
285
|
-
print_status "FAILURE" "Tag workflow failed for $version"
|
|
286
|
-
if [ "$VERBOSE" = true ]; then
|
|
287
|
-
echo "Error details:"
|
|
288
|
-
cat "$OUTPUT_DIR/tag-${version}.log"
|
|
289
|
-
fi
|
|
290
|
-
return 1
|
|
291
|
-
fi
|
|
292
|
-
done
|
|
293
|
-
|
|
294
|
-
print_status "SUCCESS" "Tag workflow testing completed"
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
# Function to test createpr workflow
|
|
298
|
-
test_createpr_workflow() {
|
|
299
|
-
local workflow_file="$WORKFLOWS_DIR/job.createpr.yml"
|
|
300
|
-
|
|
301
|
-
if [ ! -f "$workflow_file" ]; then
|
|
302
|
-
print_status "WARNING" "CreatePR workflow not found: $workflow_file"
|
|
303
|
-
return 0
|
|
304
|
-
fi
|
|
305
|
-
|
|
306
|
-
print_status "INFO" "Testing CreatePR workflow..."
|
|
307
|
-
|
|
308
|
-
# Test with different PR scenarios
|
|
309
|
-
local test_scenarios=(
|
|
310
|
-
"develop:main:Test PR:This is a test PR"
|
|
311
|
-
"feature-branch:develop:Feature PR:New feature implementation"
|
|
312
|
-
"hotfix-branch:main:Hotfix PR:Critical bug fix"
|
|
313
|
-
)
|
|
314
|
-
|
|
315
|
-
for scenario in "${test_scenarios[@]}"; do
|
|
316
|
-
IFS=':' read -r source target title body <<< "$scenario"
|
|
317
|
-
print_status "DEBUG" "Testing PR: $source → $target"
|
|
318
|
-
|
|
319
|
-
local act_args=(
|
|
320
|
-
"-W" "$workflow_file"
|
|
321
|
-
"--dry-run"
|
|
322
|
-
"--input" "sourceBranch=$source"
|
|
323
|
-
"--input" "targetBranch=$target"
|
|
324
|
-
"--input" "title=$title"
|
|
325
|
-
"--input" "body=$body"
|
|
326
|
-
"--input" "labels=test,automated"
|
|
327
|
-
"--env-file" "$PROJECT_ROOT/.env"
|
|
328
|
-
)
|
|
329
|
-
|
|
330
|
-
if [ "$VERBOSE" = true ]; then
|
|
331
|
-
act_args+=("--verbose")
|
|
332
|
-
fi
|
|
333
|
-
|
|
334
|
-
if [ "$DEBUG" = true ]; then
|
|
335
|
-
act_args+=("--debug")
|
|
336
|
-
fi
|
|
337
|
-
|
|
338
|
-
if act "${act_args[@]}" > "$OUTPUT_DIR/createpr-${source}-${target}.log" 2>&1; then
|
|
339
|
-
print_status "SUCCESS" "CreatePR workflow passed for $source → $target"
|
|
340
|
-
else
|
|
341
|
-
print_status "FAILURE" "CreatePR workflow failed for $source → $target"
|
|
342
|
-
if [ "$VERBOSE" = true ]; then
|
|
343
|
-
echo "Error details:"
|
|
344
|
-
cat "$OUTPUT_DIR/createpr-${source}-${target}.log"
|
|
345
|
-
fi
|
|
346
|
-
return 1
|
|
347
|
-
fi
|
|
348
|
-
done
|
|
349
|
-
|
|
350
|
-
print_status "SUCCESS" "CreatePR workflow testing completed"
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
# Function to test branch workflow
|
|
354
|
-
test_branch_workflow() {
|
|
355
|
-
local workflow_file="$WORKFLOWS_DIR/job.branch.yml"
|
|
356
|
-
|
|
357
|
-
if [ ! -f "$workflow_file" ]; then
|
|
358
|
-
print_status "WARNING" "Branch workflow not found: $workflow_file"
|
|
359
|
-
return 0
|
|
360
|
-
fi
|
|
361
|
-
|
|
362
|
-
print_status "INFO" "Testing Branch workflow..."
|
|
363
|
-
|
|
364
|
-
# Test different branch actions
|
|
365
|
-
local test_scenarios=(
|
|
366
|
-
"fast-forward:develop:main"
|
|
367
|
-
"create:main:feature-branch"
|
|
368
|
-
"delete:feature-branch"
|
|
369
|
-
)
|
|
370
|
-
|
|
371
|
-
for scenario in "${test_scenarios[@]}"; do
|
|
372
|
-
IFS=':' read -r action source target <<< "$scenario"
|
|
373
|
-
print_status "DEBUG" "Testing branch action: $action"
|
|
374
|
-
|
|
375
|
-
local act_args=(
|
|
376
|
-
"-W" "$workflow_file"
|
|
377
|
-
"--dry-run"
|
|
378
|
-
"--input" "action=$action"
|
|
379
|
-
"--input" "sourceBranch=$source"
|
|
380
|
-
"--input" "targetBranch=$target"
|
|
381
|
-
"--env-file" "$PROJECT_ROOT/.env"
|
|
382
|
-
)
|
|
383
|
-
|
|
384
|
-
if [ "$action" = "create" ]; then
|
|
385
|
-
act_args+=("--input" "branchName=$target")
|
|
386
|
-
fi
|
|
387
|
-
|
|
388
|
-
if [ "$VERBOSE" = true ]; then
|
|
389
|
-
act_args+=("--verbose")
|
|
390
|
-
fi
|
|
391
|
-
|
|
392
|
-
if [ "$DEBUG" = true ]; then
|
|
393
|
-
act_args+=("--debug")
|
|
394
|
-
fi
|
|
395
|
-
|
|
396
|
-
if act "${act_args[@]}" > "$OUTPUT_DIR/branch-${action}.log" 2>&1; then
|
|
397
|
-
print_status "SUCCESS" "Branch workflow passed for $action"
|
|
398
|
-
else
|
|
399
|
-
print_status "FAILURE" "Branch workflow failed for $action"
|
|
400
|
-
if [ "$VERBOSE" = true ]; then
|
|
401
|
-
echo "Error details:"
|
|
402
|
-
cat "$OUTPUT_DIR/branch-${action}.log"
|
|
403
|
-
fi
|
|
404
|
-
return 1
|
|
405
|
-
fi
|
|
406
|
-
done
|
|
407
|
-
|
|
408
|
-
print_status "SUCCESS" "Branch workflow testing completed"
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
# Function to test apps workflow
|
|
412
|
-
test_apps_workflow() {
|
|
413
|
-
local workflow_file="$WORKFLOWS_DIR/job.apps.yml"
|
|
414
|
-
|
|
415
|
-
if [ ! -f "$workflow_file" ]; then
|
|
416
|
-
print_status "WARNING" "Apps workflow not found: $workflow_file"
|
|
417
|
-
return 0
|
|
418
|
-
fi
|
|
419
|
-
|
|
420
|
-
print_status "INFO" "Testing Apps workflow..."
|
|
421
|
-
|
|
422
|
-
# Test different deployment scenarios
|
|
423
|
-
local test_scenarios=(
|
|
424
|
-
"development:api,web:latest"
|
|
425
|
-
"staging:api,web,libs:v1.2.3"
|
|
426
|
-
"production:api,web:latest"
|
|
427
|
-
)
|
|
428
|
-
|
|
429
|
-
for scenario in "${test_scenarios[@]}"; do
|
|
430
|
-
IFS=':' read -r environment domains version <<< "$scenario"
|
|
431
|
-
print_status "DEBUG" "Testing deployment: $environment ($domains)"
|
|
432
|
-
|
|
433
|
-
local act_args=(
|
|
434
|
-
"-W" "$workflow_file"
|
|
435
|
-
"--dry-run"
|
|
436
|
-
"--input" "environment=$environment"
|
|
437
|
-
"--input" "domains=$domains"
|
|
438
|
-
"--input" "version=$version"
|
|
439
|
-
"--env-file" "$PROJECT_ROOT/.env"
|
|
440
|
-
)
|
|
441
|
-
|
|
442
|
-
if [ "$VERBOSE" = true ]; then
|
|
443
|
-
act_args+=("--verbose")
|
|
444
|
-
fi
|
|
445
|
-
|
|
446
|
-
if [ "$DEBUG" = true ]; then
|
|
447
|
-
act_args+=("--debug")
|
|
448
|
-
fi
|
|
449
|
-
|
|
450
|
-
if act "${act_args[@]}" > "$OUTPUT_DIR/apps-${environment}.log" 2>&1; then
|
|
451
|
-
print_status "SUCCESS" "Apps workflow passed for $environment"
|
|
452
|
-
else
|
|
453
|
-
print_status "FAILURE" "Apps workflow failed for $environment"
|
|
454
|
-
if [ "$VERBOSE" = true ]; then
|
|
455
|
-
echo "Error details:"
|
|
456
|
-
cat "$OUTPUT_DIR/apps-${environment}.log"
|
|
457
|
-
fi
|
|
458
|
-
return 1
|
|
459
|
-
fi
|
|
460
|
-
done
|
|
461
|
-
|
|
462
|
-
print_status "SUCCESS" "Apps workflow testing completed"
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
# Function to test all job workflows
|
|
466
|
-
test_all_workflows() {
|
|
467
|
-
print_status "INFO" "Testing all job workflows..."
|
|
468
|
-
|
|
469
|
-
local failed_tests=0
|
|
470
|
-
local total_tests=0
|
|
471
|
-
|
|
472
|
-
# Test each workflow type
|
|
473
|
-
local workflows=(
|
|
474
|
-
"changes:test_changes_workflow"
|
|
475
|
-
"version:test_version_workflow"
|
|
476
|
-
"tag:test_tag_workflow"
|
|
477
|
-
"createpr:test_createpr_workflow"
|
|
478
|
-
"branch:test_branch_workflow"
|
|
479
|
-
"apps:test_apps_workflow"
|
|
480
|
-
)
|
|
481
|
-
|
|
482
|
-
for workflow in "${workflows[@]}"; do
|
|
483
|
-
IFS=':' read -r name test_function <<< "$workflow"
|
|
484
|
-
total_tests=$((total_tests + 1))
|
|
485
|
-
|
|
486
|
-
print_status "INFO" "Testing $name workflow..."
|
|
487
|
-
if $test_function; then
|
|
488
|
-
print_status "SUCCESS" "✅ $name workflow passed"
|
|
489
|
-
else
|
|
490
|
-
print_status "FAILURE" "❌ $name workflow failed"
|
|
491
|
-
failed_tests=$((failed_tests + 1))
|
|
492
|
-
fi
|
|
493
|
-
done
|
|
494
|
-
|
|
495
|
-
# Summary
|
|
496
|
-
echo ""
|
|
497
|
-
print_status "INFO" "Test Summary:"
|
|
498
|
-
echo " Total workflows: $total_tests"
|
|
499
|
-
echo " Passed: $((total_tests - failed_tests))"
|
|
500
|
-
echo " Failed: $failed_tests"
|
|
501
|
-
|
|
502
|
-
if [ $failed_tests -gt 0 ]; then
|
|
503
|
-
print_status "FAILURE" "Some workflows failed testing"
|
|
504
|
-
return 1
|
|
505
|
-
else
|
|
506
|
-
print_status "SUCCESS" "All workflows passed testing"
|
|
507
|
-
return 0
|
|
508
|
-
fi
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
# Function to cleanup test artifacts
|
|
512
|
-
cleanup_test_artifacts() {
|
|
513
|
-
if [ "$CLEANUP" = true ]; then
|
|
514
|
-
print_status "INFO" "Cleaning up test artifacts..."
|
|
515
|
-
|
|
516
|
-
# Remove test files
|
|
517
|
-
rm -f "$PROJECT_ROOT/.actrc"
|
|
518
|
-
rm -f "$PROJECT_ROOT/.env"
|
|
519
|
-
|
|
520
|
-
# Clean up output directory
|
|
521
|
-
if [ -d "$OUTPUT_DIR" ]; then
|
|
522
|
-
rm -rf "$OUTPUT_DIR"
|
|
523
|
-
fi
|
|
524
|
-
|
|
525
|
-
print_status "SUCCESS" "Cleanup complete"
|
|
526
|
-
fi
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
# Function to show test results
|
|
530
|
-
show_test_results() {
|
|
531
|
-
if [ -d "$OUTPUT_DIR" ]; then
|
|
532
|
-
echo ""
|
|
533
|
-
print_status "INFO" "Test Results:"
|
|
534
|
-
echo " Output directory: $OUTPUT_DIR"
|
|
535
|
-
|
|
536
|
-
if [ "$VERBOSE" = true ]; then
|
|
537
|
-
echo " Log files:"
|
|
538
|
-
find "$OUTPUT_DIR" -name "*.log" -exec basename {} \; | while read -r log_file; do
|
|
539
|
-
echo " - $log_file"
|
|
540
|
-
done
|
|
541
|
-
fi
|
|
542
|
-
fi
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
# Parse command line arguments
|
|
546
|
-
while [[ $# -gt 0 ]]; do
|
|
547
|
-
case $1 in
|
|
548
|
-
-w|--workflow)
|
|
549
|
-
WORKFLOW="$2"
|
|
550
|
-
shift 2
|
|
551
|
-
;;
|
|
552
|
-
-v|--verbose)
|
|
553
|
-
VERBOSE=true
|
|
554
|
-
shift
|
|
555
|
-
;;
|
|
556
|
-
-d|--debug)
|
|
557
|
-
DEBUG=true
|
|
558
|
-
shift
|
|
559
|
-
;;
|
|
560
|
-
-c|--no-cleanup)
|
|
561
|
-
CLEANUP=false
|
|
562
|
-
shift
|
|
563
|
-
;;
|
|
564
|
-
-h|--help)
|
|
565
|
-
show_usage
|
|
566
|
-
exit 0
|
|
567
|
-
;;
|
|
568
|
-
*)
|
|
569
|
-
echo -e "${RED}Unknown option: $1${NC}" >&2
|
|
570
|
-
show_usage
|
|
571
|
-
exit 1
|
|
572
|
-
;;
|
|
573
|
-
esac
|
|
574
|
-
done
|
|
575
|
-
|
|
576
|
-
# Main execution
|
|
577
|
-
main() {
|
|
578
|
-
echo -e "${BLUE}GitHub Actions Job Workflow Testing${NC}"
|
|
579
|
-
echo -e "${CYAN}====================================${NC}"
|
|
580
|
-
echo ""
|
|
581
|
-
|
|
582
|
-
# Check prerequisites
|
|
583
|
-
check_prerequisites
|
|
584
|
-
|
|
585
|
-
# Setup test environment
|
|
586
|
-
setup_test_environment
|
|
587
|
-
|
|
588
|
-
# Run tests
|
|
589
|
-
if [ -n "${WORKFLOW:-}" ]; then
|
|
590
|
-
# Test specific workflow
|
|
591
|
-
case "$WORKFLOW" in
|
|
592
|
-
"job.changes.yml"|"changes")
|
|
593
|
-
test_changes_workflow
|
|
594
|
-
;;
|
|
595
|
-
"job.version.yml"|"version")
|
|
596
|
-
test_version_workflow
|
|
597
|
-
;;
|
|
598
|
-
"job.tag.yml"|"tag")
|
|
599
|
-
test_tag_workflow
|
|
600
|
-
;;
|
|
601
|
-
"job.createpr.yml"|"createpr")
|
|
602
|
-
test_createpr_workflow
|
|
603
|
-
;;
|
|
604
|
-
"job.branch.yml"|"branch")
|
|
605
|
-
test_branch_workflow
|
|
606
|
-
;;
|
|
607
|
-
"job.apps.yml"|"apps")
|
|
608
|
-
test_apps_workflow
|
|
609
|
-
;;
|
|
610
|
-
*)
|
|
611
|
-
print_status "FAILURE" "Unknown workflow: $WORKFLOW"
|
|
612
|
-
exit 1
|
|
613
|
-
;;
|
|
614
|
-
esac
|
|
615
|
-
else
|
|
616
|
-
# Test all workflows
|
|
617
|
-
test_all_workflows
|
|
618
|
-
fi
|
|
619
|
-
|
|
620
|
-
# Show results
|
|
621
|
-
show_test_results
|
|
622
|
-
|
|
623
|
-
# Cleanup
|
|
624
|
-
cleanup_test_artifacts
|
|
625
|
-
|
|
626
|
-
echo ""
|
|
627
|
-
print_status "SUCCESS" "Job workflow testing complete!"
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
# Run main function
|
|
631
|
-
main "$@"
|