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.
- package/.claude/settings.local.json +35 -0
- package/.github/actions/calculate-version/action.yml +106 -0
- package/.github/actions/create-pr/action.yml +122 -0
- package/.github/actions/create-release/action.yml +74 -0
- package/.github/actions/create-tag/action.yml +94 -0
- package/.github/actions/detect-changes/action.yml +62 -0
- package/.github/actions/manage-branch/action.yml +113 -0
- package/.github/actions/promote-branch/action.yml +352 -0
- package/.github/example/workflows/job.analyze.code.yml +26 -0
- package/.github/example/workflows/job.analyze.docker.yml +32 -0
- package/.github/example/workflows/job.app.api.deploy.yml +127 -0
- package/.github/example/workflows/job.app.api.test.yml +102 -0
- package/.github/example/workflows/job.app.docs.deploy.yml +40 -0
- package/.github/example/workflows/job.app.docs.test.yml +50 -0
- package/.github/example/workflows/job.app.web.deploy.yml +96 -0
- package/.github/example/workflows/job.app.web.test.yml +49 -0
- package/.github/example/workflows/job.changes.yml +82 -0
- package/.github/example/workflows/job.create-pr.yml +96 -0
- package/.github/example/workflows/job.env-check.yml +43 -0
- package/.github/example/workflows/job.fast-forward.yml +103 -0
- package/.github/example/workflows/job.lint.yml +64 -0
- package/.github/example/workflows/job.pr-name.yml +70 -0
- package/.github/example/workflows/job.pr-squash-name.yml +27 -0
- package/.github/example/workflows/job.tag.yml +38 -0
- package/.github/example/workflows/job.version.yml +99 -0
- package/.github/example/workflows/lib.plugin-base.publish.yml +59 -0
- package/.github/example/workflows/pipe.yml +178 -0
- package/.github/example/workflows/scripts/fastforward.sh +51 -0
- package/.github/example/workflows/scripts/pipe-cleaner.sh +70 -0
- package/.github/scripts/fastforward.sh +51 -0
- package/.github/scripts/pipe-cleaner.sh +70 -0
- package/.github/workflows/pipeline.yml +220 -0
- package/.github/workflows/pr-title-check.yml +70 -0
- package/.github/workflows/publish.yml +39 -0
- package/.pipecraftrc.json +78 -0
- package/.release-it.cjs +71 -0
- package/PIPELINE_TESTING_PLAN.md +499 -0
- package/README.md +1101 -0
- package/TRUNK_FLOW_PLAN.md +401 -0
- package/assets/logo_banner.png +0 -0
- package/assets/logo_banner.webp +0 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +364 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/generators/init.tpl.d.ts +3 -0
- package/dist/generators/init.tpl.d.ts.map +1 -0
- package/dist/generators/init.tpl.js +117 -0
- package/dist/generators/init.tpl.js.map +1 -0
- package/dist/generators/workflows.tpl.d.ts +7 -0
- package/dist/generators/workflows.tpl.d.ts.map +1 -0
- package/dist/generators/workflows.tpl.js +73 -0
- package/dist/generators/workflows.tpl.js.map +1 -0
- package/dist/templates/actions/calculate-version.yml.tpl.d.ts +3 -0
- package/dist/templates/actions/calculate-version.yml.tpl.d.ts.map +1 -0
- package/dist/templates/actions/calculate-version.yml.tpl.js +122 -0
- package/dist/templates/actions/calculate-version.yml.tpl.js.map +1 -0
- package/dist/templates/actions/create-pr.yml.tpl.d.ts +3 -0
- package/dist/templates/actions/create-pr.yml.tpl.d.ts.map +1 -0
- package/dist/templates/actions/create-pr.yml.tpl.js +145 -0
- package/dist/templates/actions/create-pr.yml.tpl.js.map +1 -0
- package/dist/templates/actions/create-tag.yml.tpl.d.ts +3 -0
- package/dist/templates/actions/create-tag.yml.tpl.d.ts.map +1 -0
- package/dist/templates/actions/create-tag.yml.tpl.js +111 -0
- package/dist/templates/actions/create-tag.yml.tpl.js.map +1 -0
- package/dist/templates/actions/detect-changes.yml.tpl.d.ts +3 -0
- package/dist/templates/actions/detect-changes.yml.tpl.d.ts.map +1 -0
- package/dist/templates/actions/detect-changes.yml.tpl.js +79 -0
- package/dist/templates/actions/detect-changes.yml.tpl.js.map +1 -0
- package/dist/templates/actions/manage-branch.yml.tpl.d.ts +3 -0
- package/dist/templates/actions/manage-branch.yml.tpl.d.ts.map +1 -0
- package/dist/templates/actions/manage-branch.yml.tpl.js +130 -0
- package/dist/templates/actions/manage-branch.yml.tpl.js.map +1 -0
- package/dist/templates/actions/promote-branch.yml.tpl.d.ts +3 -0
- package/dist/templates/actions/promote-branch.yml.tpl.d.ts.map +1 -0
- package/dist/templates/actions/promote-branch.yml.tpl.js +362 -0
- package/dist/templates/actions/promote-branch.yml.tpl.js.map +1 -0
- package/dist/templates/workflows/pipeline-path-based.yml.tpl.d.ts +16 -0
- package/dist/templates/workflows/pipeline-path-based.yml.tpl.d.ts.map +1 -0
- package/dist/templates/workflows/pipeline-path-based.yml.tpl.js +652 -0
- package/dist/templates/workflows/pipeline-path-based.yml.tpl.js.map +1 -0
- package/dist/types/index.d.ts +63 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/ast-path-operations.d.ts +287 -0
- package/dist/utils/ast-path-operations.d.ts.map +1 -0
- package/dist/utils/ast-path-operations.js +419 -0
- package/dist/utils/ast-path-operations.js.map +1 -0
- package/dist/utils/config.d.ts +3 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +49 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/github-setup.d.ts +74 -0
- package/dist/utils/github-setup.d.ts.map +1 -0
- package/dist/utils/github-setup.js +418 -0
- package/dist/utils/github-setup.js.map +1 -0
- package/dist/utils/idempotency.d.ts +47 -0
- package/dist/utils/idempotency.d.ts.map +1 -0
- package/dist/utils/idempotency.js +176 -0
- package/dist/utils/idempotency.js.map +1 -0
- package/dist/utils/preflight.d.ts +55 -0
- package/dist/utils/preflight.d.ts.map +1 -0
- package/dist/utils/preflight.js +261 -0
- package/dist/utils/preflight.js.map +1 -0
- package/dist/utils/versioning.d.ts +41 -0
- package/dist/utils/versioning.d.ts.map +1 -0
- package/dist/utils/versioning.js +219 -0
- package/dist/utils/versioning.js.map +1 -0
- package/docs/USER_JOURNEY_ERRORS.md +352 -0
- package/eslint.config.js +77 -0
- package/examples/basic-config.json +41 -0
- package/examples/monorepo-config.json +49 -0
- package/examples/usage.md +289 -0
- package/package.json +58 -0
- package/scripts/debug-workflows.sh +339 -0
- package/scripts/parse-pipeline.js +29 -0
- package/scripts/test-job-order.cjs +140 -0
- package/scripts/validate-pipeline.cjs +379 -0
- package/scripts/verify-job-order.sh +30 -0
- package/src/cli/index.ts +414 -0
- package/src/generators/init.tpl.ts +126 -0
- package/src/generators/workflows.tpl.ts +80 -0
- package/src/templates/actions/calculate-version.yml.tpl.ts +124 -0
- package/src/templates/actions/create-pr.yml.tpl.ts +147 -0
- package/src/templates/actions/create-tag.yml.tpl.ts +112 -0
- package/src/templates/actions/detect-changes.yml.tpl.ts +87 -0
- package/src/templates/actions/manage-branch.yml.tpl.ts +132 -0
- package/src/templates/actions/promote-branch.yml.tpl.ts +364 -0
- package/src/templates/workflows/pipeline-path-based.yml.tpl.ts +706 -0
- package/src/types/index.ts +64 -0
- package/src/utils/README-ast-path-operations.md +390 -0
- package/src/utils/ast-path-operations.ts +581 -0
- package/src/utils/config.ts +64 -0
- package/src/utils/github-setup.ts +558 -0
- package/src/utils/idempotency.ts +215 -0
- package/src/utils/preflight.ts +306 -0
- package/src/utils/versioning.ts +244 -0
- package/tests/README.md +229 -0
- package/tests/TEST_STRUCTURE.md +256 -0
- package/tests/act/run-act-tests.sh +345 -0
- package/tests/debugging/debug-utils.ts +538 -0
- package/tests/debugging/debug-workflow.test.ts +339 -0
- package/tests/debugging/debug-workflows.sh +339 -0
- package/tests/debugging/iterative-debug.ts +652 -0
- package/tests/debugging/run-debug-tests.sh +431 -0
- package/tests/fixtures/basic-config.json +51 -0
- package/tests/fixtures/invalid-config.json +9 -0
- package/tests/fixtures/pipeline-generated.yml +235 -0
- package/tests/fixtures/pipeline-preserve-comments.yml +245 -0
- package/tests/fixtures/pipeline-user-modified.yml +245 -0
- package/tests/fixtures/test-config.json +58 -0
- package/tests/github-live/README.md +250 -0
- package/tests/github-local/JOB_WORKFLOW_TESTS.md +296 -0
- package/tests/github-local/README.md +240 -0
- package/tests/github-local/run-all-tests.sh +422 -0
- package/tests/github-local/test-job-workflows.sh +631 -0
- package/tests/github-local/test-pipeline-workflow.sh +440 -0
- package/tests/integration/generators.test.ts +578 -0
- package/tests/integration/path-based-template.test.ts +510 -0
- package/tests/integration/simple-path-based.test.ts +415 -0
- package/tests/setup.ts +56 -0
- package/tests/unit/ast-path-operations-extended.test.ts +302 -0
- package/tests/unit/cli.test.ts +541 -0
- package/tests/unit/config-extended.test.ts +412 -0
- package/tests/unit/config.test.ts +152 -0
- package/tests/unit/github-setup.test.ts +189 -0
- package/tests/unit/idempotency-isolated.test.ts +297 -0
- package/tests/unit/job-order.test.ts +157 -0
- package/tests/unit/pipeline-path-based.test.ts +511 -0
- package/tests/unit/validate-pipeline.test.ts +384 -0
- package/tests/unit/versioning-extended.test.ts +279 -0
- package/tests/unit/versioning.test.ts +241 -0
- package/tsconfig.debug.json +17 -0
- package/tsconfig.json +28 -0
- package/vitest.config.ts +51 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"ciProvider": "github",
|
|
3
|
+
"mergeStrategy": "fast-forward",
|
|
4
|
+
"requireConventionalCommits": true,
|
|
5
|
+
"initialBranch": "alpha",
|
|
6
|
+
"finalBranch": "epsilon",
|
|
7
|
+
"branchFlow": [
|
|
8
|
+
"alpha",
|
|
9
|
+
"beta",
|
|
10
|
+
"gamma",
|
|
11
|
+
"delta",
|
|
12
|
+
"epsilon"
|
|
13
|
+
],
|
|
14
|
+
"semver": {
|
|
15
|
+
"bumpRules": {
|
|
16
|
+
"feat": "minor",
|
|
17
|
+
"fix": "patch",
|
|
18
|
+
"breaking": "major"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"actions": {
|
|
22
|
+
"onDevelopMerge": [
|
|
23
|
+
"runTests",
|
|
24
|
+
"fastForwardToStaging"
|
|
25
|
+
],
|
|
26
|
+
"onStagingMerge": [
|
|
27
|
+
"runTests",
|
|
28
|
+
"calculateVersion",
|
|
29
|
+
"createOrFastForwardToMain"
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
"domains": {
|
|
33
|
+
"fake-domain1": {
|
|
34
|
+
"paths": [
|
|
35
|
+
"apps/fake-domain1/**"
|
|
36
|
+
],
|
|
37
|
+
"description": "fake-domain1 application changes"
|
|
38
|
+
},
|
|
39
|
+
"fake-domain2": {
|
|
40
|
+
"paths": [
|
|
41
|
+
"apps/fake-domain2/**"
|
|
42
|
+
],
|
|
43
|
+
"description": "fake-domain2 application changes"
|
|
44
|
+
},
|
|
45
|
+
"fake-domain3": {
|
|
46
|
+
"paths": [
|
|
47
|
+
"libs/fake-domain3/**"
|
|
48
|
+
],
|
|
49
|
+
"description": "fake-domain3 application changes"
|
|
50
|
+
},
|
|
51
|
+
"fake-domain4": {
|
|
52
|
+
"paths": [
|
|
53
|
+
".github/workflows/fake-domain4/**"
|
|
54
|
+
],
|
|
55
|
+
"description": "fake-domain4 application changes"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
# GitHub Actions Live Testing
|
|
2
|
+
|
|
3
|
+
This directory contains tests for running GitHub Actions workflows on actual GitHub infrastructure.
|
|
4
|
+
|
|
5
|
+
## 🎯 Purpose
|
|
6
|
+
|
|
7
|
+
Live GitHub Actions testing allows us to:
|
|
8
|
+
- Test workflows in the real GitHub environment
|
|
9
|
+
- Validate workflow behavior with actual GitHub APIs
|
|
10
|
+
- Test performance under real conditions
|
|
11
|
+
- Debug issues that only occur in the live environment
|
|
12
|
+
- Validate workflow reliability and stability
|
|
13
|
+
|
|
14
|
+
## 📁 Structure
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
tests/github-live/
|
|
18
|
+
├── README.md # This file
|
|
19
|
+
├── run-live-tests.sh # Main test runner script
|
|
20
|
+
├── setup-test-env.sh # Environment setup script
|
|
21
|
+
├── test-workflows.sh # Individual workflow testing
|
|
22
|
+
├── fixtures/ # Test data and configurations
|
|
23
|
+
│ ├── test-configs/ # Test configurations
|
|
24
|
+
│ ├── mock-data/ # Mock data for workflows
|
|
25
|
+
│ └── expected-outputs/ # Expected test outputs
|
|
26
|
+
└── helpers/ # Test helper scripts
|
|
27
|
+
├── github-runner.sh # GitHub Actions execution helper
|
|
28
|
+
└── workflow-monitor.sh # Workflow monitoring helper
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## 🚀 Quick Start
|
|
32
|
+
|
|
33
|
+
### Prerequisites
|
|
34
|
+
```bash
|
|
35
|
+
# Install GitHub CLI
|
|
36
|
+
brew install gh # macOS
|
|
37
|
+
# Or download from: https://cli.github.com/
|
|
38
|
+
|
|
39
|
+
# Authenticate with GitHub
|
|
40
|
+
gh auth login
|
|
41
|
+
|
|
42
|
+
# Set up GitHub token
|
|
43
|
+
export GITHUB_TOKEN="your_github_token"
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Running Tests
|
|
47
|
+
```bash
|
|
48
|
+
# Run all live tests
|
|
49
|
+
./tests/github-live/run-live-tests.sh
|
|
50
|
+
|
|
51
|
+
# Test specific workflow
|
|
52
|
+
./tests/github-live/test-workflows.sh --workflow pipeline.yml
|
|
53
|
+
|
|
54
|
+
# Run with verbose output
|
|
55
|
+
./tests/github-live/run-live-tests.sh --verbose
|
|
56
|
+
|
|
57
|
+
# Run with debug mode
|
|
58
|
+
./tests/github-live/run-live-tests.sh --debug
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## 🔧 Configuration
|
|
62
|
+
|
|
63
|
+
### GitHub Authentication
|
|
64
|
+
```bash
|
|
65
|
+
# Set up GitHub token
|
|
66
|
+
export GITHUB_TOKEN="your_github_token"
|
|
67
|
+
|
|
68
|
+
# Or use GitHub CLI
|
|
69
|
+
gh auth token
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Test Environment
|
|
73
|
+
```bash
|
|
74
|
+
# Set up test environment
|
|
75
|
+
./tests/github-live/setup-test-env.sh
|
|
76
|
+
|
|
77
|
+
# This creates:
|
|
78
|
+
# - Test repository setup
|
|
79
|
+
# - Workflow trigger configuration
|
|
80
|
+
# - Test data and fixtures
|
|
81
|
+
# - Monitoring setup
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## 📋 Test Workflows
|
|
85
|
+
|
|
86
|
+
### Supported Workflows
|
|
87
|
+
- **pipeline.yml**: Main workflow orchestration
|
|
88
|
+
- **job.changes.yml**: Change detection workflow
|
|
89
|
+
- **job.version.yml**: Version management workflow
|
|
90
|
+
- **job.tag.yml**: Tag creation workflow
|
|
91
|
+
- **job.createpr.yml**: PR creation workflow
|
|
92
|
+
- **job.branch.yml**: Branch management workflow
|
|
93
|
+
- **job.apps.yml**: Application-specific workflows
|
|
94
|
+
|
|
95
|
+
### Test Scenarios
|
|
96
|
+
1. **Basic Execution**: Test workflow runs without errors
|
|
97
|
+
2. **Environment Variables**: Test with different env vars
|
|
98
|
+
3. **Conditional Logic**: Test workflow conditions and branches
|
|
99
|
+
4. **Job Dependencies**: Test job dependency chains
|
|
100
|
+
5. **Error Handling**: Test failure scenarios
|
|
101
|
+
6. **Performance**: Test execution time and resource usage
|
|
102
|
+
7. **API Limits**: Test GitHub API rate limiting
|
|
103
|
+
8. **Concurrency**: Test parallel workflow execution
|
|
104
|
+
|
|
105
|
+
## 🧪 Test Examples
|
|
106
|
+
|
|
107
|
+
### Basic Workflow Test
|
|
108
|
+
```bash
|
|
109
|
+
# Test main pipeline
|
|
110
|
+
./tests/github-live/test-workflows.sh --workflow pipeline.yml
|
|
111
|
+
|
|
112
|
+
# Test with specific event
|
|
113
|
+
./tests/github-live/test-workflows.sh --workflow pipeline.yml --event push
|
|
114
|
+
|
|
115
|
+
# Test with environment variables
|
|
116
|
+
./tests/github-live/test-workflows.sh --workflow pipeline.yml --env GITHUB_REF=refs/heads/main
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Advanced Testing
|
|
120
|
+
```bash
|
|
121
|
+
# Test with secrets
|
|
122
|
+
./tests/github-live/test-workflows.sh --workflow pipeline.yml --secrets GITHUB_TOKEN=your_token
|
|
123
|
+
|
|
124
|
+
# Test with artifacts
|
|
125
|
+
./tests/github-live/test-workflows.sh --workflow pipeline.yml --artifacts
|
|
126
|
+
|
|
127
|
+
# Test with matrix strategy
|
|
128
|
+
./tests/github-live/test-workflows.sh --workflow pipeline.yml --matrix os:ubuntu-latest,node:18
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## 🔍 Debugging
|
|
132
|
+
|
|
133
|
+
### Common Issues
|
|
134
|
+
1. **Authentication**: Verify GitHub token permissions
|
|
135
|
+
2. **Rate limits**: Check GitHub API rate limits
|
|
136
|
+
3. **Workflow syntax**: Check YAML syntax and GitHub Actions syntax
|
|
137
|
+
4. **Environment variables**: Verify all required env vars are set
|
|
138
|
+
5. **Secrets**: Ensure all required secrets are available
|
|
139
|
+
|
|
140
|
+
### Debug Commands
|
|
141
|
+
```bash
|
|
142
|
+
# List available workflows
|
|
143
|
+
gh workflow list
|
|
144
|
+
|
|
145
|
+
# Show workflow details
|
|
146
|
+
gh workflow view pipeline.yml
|
|
147
|
+
|
|
148
|
+
# Run workflow manually
|
|
149
|
+
gh workflow run pipeline.yml
|
|
150
|
+
|
|
151
|
+
# Check workflow runs
|
|
152
|
+
gh run list
|
|
153
|
+
|
|
154
|
+
# View workflow logs
|
|
155
|
+
gh run view <run-id>
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## 📊 Test Results
|
|
159
|
+
|
|
160
|
+
### Output Format
|
|
161
|
+
```
|
|
162
|
+
✅ Workflow: pipeline.yml
|
|
163
|
+
✅ Job: changes (2.3s)
|
|
164
|
+
✅ Job: versioning (1.8s)
|
|
165
|
+
✅ Job: deployments (4.2s)
|
|
166
|
+
⚠️ Job: testing (skipped - no changes)
|
|
167
|
+
|
|
168
|
+
❌ Workflow: job.changes.yml
|
|
169
|
+
❌ Job: changes (failed - missing env var)
|
|
170
|
+
📝 Error: GITHUB_TOKEN not set
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Performance Metrics
|
|
174
|
+
- **Execution Time**: Track workflow execution time
|
|
175
|
+
- **Resource Usage**: Monitor CPU and memory usage
|
|
176
|
+
- **Job Dependencies**: Validate dependency chains
|
|
177
|
+
- **Error Rates**: Track failure rates and patterns
|
|
178
|
+
- **API Usage**: Monitor GitHub API usage
|
|
179
|
+
|
|
180
|
+
## 🔄 Continuous Integration
|
|
181
|
+
|
|
182
|
+
### GitHub Actions Integration
|
|
183
|
+
```yaml
|
|
184
|
+
name: Live Tests
|
|
185
|
+
on: [push, pull_request]
|
|
186
|
+
jobs:
|
|
187
|
+
live-tests:
|
|
188
|
+
runs-on: ubuntu-latest
|
|
189
|
+
steps:
|
|
190
|
+
- uses: actions/checkout@v4
|
|
191
|
+
- name: Run Live Tests
|
|
192
|
+
run: ./tests/github-live/run-live-tests.sh
|
|
193
|
+
env:
|
|
194
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Local Development
|
|
198
|
+
```bash
|
|
199
|
+
# Watch mode for development
|
|
200
|
+
./tests/github-live/run-live-tests.sh --watch
|
|
201
|
+
|
|
202
|
+
# Run specific test suite
|
|
203
|
+
./tests/github-live/run-live-tests.sh --suite pipeline
|
|
204
|
+
|
|
205
|
+
# Run with coverage
|
|
206
|
+
./tests/github-live/run-live-tests.sh --coverage
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## 📚 Best Practices
|
|
210
|
+
|
|
211
|
+
### Test Organization
|
|
212
|
+
1. **Group related tests**: Organize tests by workflow type
|
|
213
|
+
2. **Use fixtures**: Create reusable test data
|
|
214
|
+
3. **Mock external services**: Avoid external dependencies where possible
|
|
215
|
+
4. **Test edge cases**: Include error scenarios and edge cases
|
|
216
|
+
|
|
217
|
+
### Performance
|
|
218
|
+
1. **Parallel execution**: Run independent tests in parallel
|
|
219
|
+
2. **Resource management**: Monitor GitHub Actions resource usage
|
|
220
|
+
3. **Cleanup**: Clean up test artifacts after runs
|
|
221
|
+
4. **Rate limiting**: Respect GitHub API rate limits
|
|
222
|
+
|
|
223
|
+
### Maintenance
|
|
224
|
+
1. **Regular updates**: Keep test dependencies updated
|
|
225
|
+
2. **Documentation**: Document test scenarios and expected outcomes
|
|
226
|
+
3. **Monitoring**: Track test performance and reliability
|
|
227
|
+
4. **Feedback**: Collect feedback from test results
|
|
228
|
+
|
|
229
|
+
## 🆘 Troubleshooting
|
|
230
|
+
|
|
231
|
+
### Common Problems
|
|
232
|
+
```bash
|
|
233
|
+
# GitHub token issues
|
|
234
|
+
gh auth status
|
|
235
|
+
|
|
236
|
+
# Workflow syntax errors
|
|
237
|
+
gh workflow view pipeline.yml
|
|
238
|
+
|
|
239
|
+
# Environment variable issues
|
|
240
|
+
gh workflow run pipeline.yml --env GITHUB_REF=refs/heads/main
|
|
241
|
+
|
|
242
|
+
# Rate limit issues
|
|
243
|
+
gh api rate_limit
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Getting Help
|
|
247
|
+
- [GitHub CLI Documentation](https://cli.github.com/)
|
|
248
|
+
- [GitHub Actions Documentation](https://docs.github.com/en/actions)
|
|
249
|
+
- [GitHub API Documentation](https://docs.github.com/en/rest)
|
|
250
|
+
- [Project Issues](https://github.com/your-org/pipecraft/issues)
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
# Job Workflow Testing Guide
|
|
2
|
+
|
|
3
|
+
This document outlines the testing strategy for each job workflow generated by Pipecraft.
|
|
4
|
+
|
|
5
|
+
## 📋 Job Workflow Overview
|
|
6
|
+
|
|
7
|
+
### 1. Changes Workflow (`job.changes.yml`)
|
|
8
|
+
**Purpose**: Detects which domains have changed between branches
|
|
9
|
+
**Key Features**:
|
|
10
|
+
- Uses `dorny/paths-filter@v3` to detect changes
|
|
11
|
+
- Supports multi-branch flow (develop → test → staging → main)
|
|
12
|
+
- Outputs boolean flags for each domain
|
|
13
|
+
- Forces full deployment on main/staging/test branches
|
|
14
|
+
|
|
15
|
+
**Test Scenarios**:
|
|
16
|
+
- Different branch references (main, develop, staging, test)
|
|
17
|
+
- Path filtering for each domain
|
|
18
|
+
- Branch flow logic validation
|
|
19
|
+
- Output generation for all domains
|
|
20
|
+
|
|
21
|
+
### 2. Version Workflow (`job.version.yml`)
|
|
22
|
+
**Purpose**: Calculates semantic version based on conventional commits
|
|
23
|
+
**Key Features**:
|
|
24
|
+
- Analyzes commits since last tag
|
|
25
|
+
- Determines version bump type (major/minor/patch)
|
|
26
|
+
- Supports conventional commit format
|
|
27
|
+
- Outputs current, next, and version type
|
|
28
|
+
|
|
29
|
+
**Test Scenarios**:
|
|
30
|
+
- Different base references (main, develop, staging)
|
|
31
|
+
- Various commit types (feat, fix, breaking)
|
|
32
|
+
- Version calculation logic
|
|
33
|
+
- Output validation
|
|
34
|
+
|
|
35
|
+
### 3. Tag Workflow (`job.tag.yml`)
|
|
36
|
+
**Purpose**: Creates and pushes Git tags for releases
|
|
37
|
+
**Key Features**:
|
|
38
|
+
- Validates version format (v1.2.3)
|
|
39
|
+
- Checks for existing tags
|
|
40
|
+
- Creates annotated tags with messages
|
|
41
|
+
- Pushes tags to remote repository
|
|
42
|
+
|
|
43
|
+
**Test Scenarios**:
|
|
44
|
+
- Valid version formats (v1.0.0, v1.2.3, v2.0.0)
|
|
45
|
+
- Invalid version formats
|
|
46
|
+
- Existing tag detection
|
|
47
|
+
- Tag creation and pushing
|
|
48
|
+
|
|
49
|
+
### 4. CreatePR Workflow (`job.createpr.yml`)
|
|
50
|
+
**Purpose**: Creates pull requests between branches
|
|
51
|
+
**Key Features**:
|
|
52
|
+
- Checks for existing PRs
|
|
53
|
+
- Creates PRs with title, body, and labels
|
|
54
|
+
- Supports different branch combinations
|
|
55
|
+
- Returns PR number and URL
|
|
56
|
+
|
|
57
|
+
**Test Scenarios**:
|
|
58
|
+
- Different branch combinations (develop→main, feature→develop)
|
|
59
|
+
- PR title and body validation
|
|
60
|
+
- Label assignment
|
|
61
|
+
- Existing PR detection
|
|
62
|
+
|
|
63
|
+
### 5. Branch Workflow (`job.branch.yml`)
|
|
64
|
+
**Purpose**: Manages branch operations (fast-forward, create, delete)
|
|
65
|
+
**Key Features**:
|
|
66
|
+
- Fast-forward merging
|
|
67
|
+
- Branch creation from source
|
|
68
|
+
- Branch deletion (local and remote)
|
|
69
|
+
- Input validation for each action
|
|
70
|
+
|
|
71
|
+
**Test Scenarios**:
|
|
72
|
+
- Fast-forward operations
|
|
73
|
+
- Branch creation
|
|
74
|
+
- Branch deletion
|
|
75
|
+
- Input validation
|
|
76
|
+
- Error handling
|
|
77
|
+
|
|
78
|
+
### 6. Apps Workflow (`job.apps.yml`)
|
|
79
|
+
**Purpose**: Deploys applications to different environments
|
|
80
|
+
**Key Features**:
|
|
81
|
+
- Environment-specific configuration
|
|
82
|
+
- Multi-domain deployment
|
|
83
|
+
- Version management
|
|
84
|
+
- Deployment status tracking
|
|
85
|
+
|
|
86
|
+
**Test Scenarios**:
|
|
87
|
+
- Different environments (development, staging, production)
|
|
88
|
+
- Various domain combinations
|
|
89
|
+
- Version handling
|
|
90
|
+
- Deployment status validation
|
|
91
|
+
|
|
92
|
+
## 🧪 Testing Strategy
|
|
93
|
+
|
|
94
|
+
### Unit Testing
|
|
95
|
+
Each workflow is tested in isolation with:
|
|
96
|
+
- Mock inputs and environment variables
|
|
97
|
+
- Validation of workflow syntax
|
|
98
|
+
- Step-by-step execution verification
|
|
99
|
+
- Output validation
|
|
100
|
+
|
|
101
|
+
### Integration Testing
|
|
102
|
+
Workflows are tested with:
|
|
103
|
+
- Real GitHub Actions environment simulation
|
|
104
|
+
- Cross-workflow dependencies
|
|
105
|
+
- End-to-end scenarios
|
|
106
|
+
- Error handling and recovery
|
|
107
|
+
|
|
108
|
+
### End-to-End Testing
|
|
109
|
+
Complete workflows are tested with:
|
|
110
|
+
- Real repository scenarios
|
|
111
|
+
- Multiple workflow combinations
|
|
112
|
+
- Performance testing
|
|
113
|
+
- User experience validation
|
|
114
|
+
|
|
115
|
+
## 🔧 Test Configuration
|
|
116
|
+
|
|
117
|
+
### Environment Setup
|
|
118
|
+
```bash
|
|
119
|
+
# Required environment variables
|
|
120
|
+
export GITHUB_ACTIONS=true
|
|
121
|
+
export GITHUB_WORKFLOW=test-workflow
|
|
122
|
+
export GITHUB_RUN_ID=123456789
|
|
123
|
+
export GITHUB_RUN_NUMBER=1
|
|
124
|
+
export GITHUB_ACTOR=test-user
|
|
125
|
+
export GITHUB_REPOSITORY=test-org/test-repo
|
|
126
|
+
export GITHUB_EVENT_NAME=push
|
|
127
|
+
export GITHUB_SHA=abc123def456
|
|
128
|
+
export GITHUB_REF=refs/heads/main
|
|
129
|
+
export GITHUB_HEAD_REF=""
|
|
130
|
+
export GITHUB_BASE_REF=""
|
|
131
|
+
export GITHUB_WORKSPACE=/path/to/project
|
|
132
|
+
export GITHUB_TOKEN=test-token
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Test Data
|
|
136
|
+
```bash
|
|
137
|
+
# Test configurations
|
|
138
|
+
export TEST_DOMAINS="api,web,libs"
|
|
139
|
+
export TEST_BRANCHES="main,develop,staging"
|
|
140
|
+
export TEST_VERSIONS="v1.0.0,v1.2.3,v2.0.0"
|
|
141
|
+
export TEST_ENVIRONMENTS="development,staging,production"
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## 📊 Test Results
|
|
145
|
+
|
|
146
|
+
### Success Criteria
|
|
147
|
+
- ✅ Workflow syntax validation
|
|
148
|
+
- ✅ Step execution without errors
|
|
149
|
+
- ✅ Output generation
|
|
150
|
+
- ✅ Error handling
|
|
151
|
+
- ✅ Performance within limits
|
|
152
|
+
|
|
153
|
+
### Failure Scenarios
|
|
154
|
+
- ❌ Syntax errors
|
|
155
|
+
- ❌ Missing inputs
|
|
156
|
+
- ❌ Invalid configurations
|
|
157
|
+
- ❌ Timeout errors
|
|
158
|
+
- ❌ Permission issues
|
|
159
|
+
|
|
160
|
+
## 🚀 Running Tests
|
|
161
|
+
|
|
162
|
+
### Individual Workflow Tests
|
|
163
|
+
```bash
|
|
164
|
+
# Test specific workflow
|
|
165
|
+
./tests/github-local/test-job-workflows.sh -w job.changes.yml
|
|
166
|
+
|
|
167
|
+
# Test with verbose output
|
|
168
|
+
./tests/github-local/test-job-workflows.sh -w job.version.yml -v
|
|
169
|
+
|
|
170
|
+
# Test with debug mode
|
|
171
|
+
./tests/github-local/test-job-workflows.sh -w job.tag.yml -d
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### All Workflow Tests
|
|
175
|
+
```bash
|
|
176
|
+
# Test all workflows
|
|
177
|
+
./tests/github-local/test-job-workflows.sh
|
|
178
|
+
|
|
179
|
+
# Test with verbose output
|
|
180
|
+
./tests/github-local/test-job-workflows.sh -v
|
|
181
|
+
|
|
182
|
+
# Test with debug mode
|
|
183
|
+
./tests/github-local/test-job-workflows.sh -d
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## 🔍 Debugging
|
|
187
|
+
|
|
188
|
+
### Common Issues
|
|
189
|
+
1. **Workflow syntax errors**: Check YAML formatting
|
|
190
|
+
2. **Missing inputs**: Verify all required inputs are provided
|
|
191
|
+
3. **Permission issues**: Check GitHub token permissions
|
|
192
|
+
4. **Environment variables**: Verify all required env vars are set
|
|
193
|
+
5. **Docker issues**: Ensure Docker is running
|
|
194
|
+
|
|
195
|
+
### Debug Commands
|
|
196
|
+
```bash
|
|
197
|
+
# List available workflows
|
|
198
|
+
act --list
|
|
199
|
+
|
|
200
|
+
# Show workflow details
|
|
201
|
+
act -W .github/workflows/job.changes.yml --list
|
|
202
|
+
|
|
203
|
+
# Run with verbose output
|
|
204
|
+
act -W .github/workflows/job.changes.yml --verbose
|
|
205
|
+
|
|
206
|
+
# Run with debug output
|
|
207
|
+
act -W .github/workflows/job.changes.yml --debug
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## 📈 Performance Testing
|
|
211
|
+
|
|
212
|
+
### Metrics
|
|
213
|
+
- **Execution time**: Track workflow execution time
|
|
214
|
+
- **Resource usage**: Monitor CPU and memory usage
|
|
215
|
+
- **Step duration**: Measure individual step performance
|
|
216
|
+
- **Error rates**: Track failure rates and patterns
|
|
217
|
+
|
|
218
|
+
### Benchmarks
|
|
219
|
+
- Changes workflow: < 30 seconds
|
|
220
|
+
- Version workflow: < 20 seconds
|
|
221
|
+
- Tag workflow: < 15 seconds
|
|
222
|
+
- CreatePR workflow: < 25 seconds
|
|
223
|
+
- Branch workflow: < 20 seconds
|
|
224
|
+
- Apps workflow: < 60 seconds
|
|
225
|
+
|
|
226
|
+
## 🔄 Continuous Integration
|
|
227
|
+
|
|
228
|
+
### GitHub Actions Integration
|
|
229
|
+
```yaml
|
|
230
|
+
name: Job Workflow Tests
|
|
231
|
+
on: [push, pull_request]
|
|
232
|
+
jobs:
|
|
233
|
+
test-job-workflows:
|
|
234
|
+
runs-on: ubuntu-latest
|
|
235
|
+
steps:
|
|
236
|
+
- uses: actions/checkout@v4
|
|
237
|
+
- name: Install Act
|
|
238
|
+
run: curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash
|
|
239
|
+
- name: Run Job Workflow Tests
|
|
240
|
+
run: ./tests/github-local/test-job-workflows.sh
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Local Development
|
|
244
|
+
```bash
|
|
245
|
+
# Watch mode for development
|
|
246
|
+
./tests/github-local/test-job-workflows.sh --watch
|
|
247
|
+
|
|
248
|
+
# Run specific test suite
|
|
249
|
+
./tests/github-local/test-job-workflows.sh --suite changes
|
|
250
|
+
|
|
251
|
+
# Run with coverage
|
|
252
|
+
./tests/github-local/test-job-workflows.sh --coverage
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## 📚 Best Practices
|
|
256
|
+
|
|
257
|
+
### Test Organization
|
|
258
|
+
1. **Group related tests**: Organize tests by workflow type
|
|
259
|
+
2. **Use fixtures**: Create reusable test data
|
|
260
|
+
3. **Mock external services**: Avoid external dependencies
|
|
261
|
+
4. **Test edge cases**: Include error scenarios and edge cases
|
|
262
|
+
|
|
263
|
+
### Performance
|
|
264
|
+
1. **Parallel execution**: Run independent tests in parallel
|
|
265
|
+
2. **Resource management**: Monitor Docker resource usage
|
|
266
|
+
3. **Cleanup**: Clean up test artifacts after runs
|
|
267
|
+
4. **Caching**: Use Docker layer caching for faster builds
|
|
268
|
+
|
|
269
|
+
### Maintenance
|
|
270
|
+
1. **Regular updates**: Keep Act and test dependencies updated
|
|
271
|
+
2. **Documentation**: Document test scenarios and expected outcomes
|
|
272
|
+
3. **Monitoring**: Track test performance and reliability
|
|
273
|
+
4. **Feedback**: Collect feedback from test results
|
|
274
|
+
|
|
275
|
+
## 🆘 Troubleshooting
|
|
276
|
+
|
|
277
|
+
### Common Problems
|
|
278
|
+
```bash
|
|
279
|
+
# Act not found
|
|
280
|
+
export PATH=$PATH:/usr/local/bin
|
|
281
|
+
|
|
282
|
+
# Docker permission denied
|
|
283
|
+
sudo usermod -aG docker $USER
|
|
284
|
+
|
|
285
|
+
# Workflow syntax errors
|
|
286
|
+
act -W .github/workflows/job.changes.yml --dry-run --verbose
|
|
287
|
+
|
|
288
|
+
# Environment variable issues
|
|
289
|
+
act -W .github/workflows/job.changes.yml --env-file .env
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### Getting Help
|
|
293
|
+
- [Act Documentation](https://github.com/nektos/act)
|
|
294
|
+
- [GitHub Actions Documentation](https://docs.github.com/en/actions)
|
|
295
|
+
- [Docker Documentation](https://docs.docker.com/)
|
|
296
|
+
- [Project Issues](https://github.com/your-org/pipecraft/issues)
|