@logickernel/agileflow 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.
- package/README.md +289 -0
- package/bin/agileflow +4 -0
- package/docs/README.md +46 -0
- package/docs/best-practices.md +339 -0
- package/docs/branching-strategy.md +448 -0
- package/docs/cli-reference.md +110 -0
- package/docs/configuration.md +232 -0
- package/docs/conventional-commits/type-build.md +23 -0
- package/docs/conventional-commits/type-chore.md +24 -0
- package/docs/conventional-commits/type-ci.md +23 -0
- package/docs/conventional-commits/type-docs.md +23 -0
- package/docs/conventional-commits/type-feat.md +28 -0
- package/docs/conventional-commits/type-fix.md +27 -0
- package/docs/conventional-commits/type-perf.md +24 -0
- package/docs/conventional-commits/type-refactor.md +24 -0
- package/docs/conventional-commits/type-revert.md +16 -0
- package/docs/conventional-commits/type-style.md +24 -0
- package/docs/conventional-commits/type-test.md +24 -0
- package/docs/conventional-commits.md +234 -0
- package/docs/getting-started.md +209 -0
- package/docs/gitlab-ci-template.md +324 -0
- package/docs/installation.md +163 -0
- package/docs/migration-guide.md +390 -0
- package/docs/release-management.md +498 -0
- package/docs/troubleshooting.md +341 -0
- package/docs/version-centric-cicd.md +166 -0
- package/package.json +39 -0
- package/src/git-utils.js +57 -0
- package/src/index.js +88 -0
- package/src/local.js +17 -0
- package/src/utils.js +376 -0
- package/templates/agileflow-tagged.gitlab-ci.yml +66 -0
- package/templates/agileflow.gitlab-ci.yml +64 -0
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
# Troubleshooting Guide
|
|
2
|
+
|
|
3
|
+
This guide helps you resolve common issues when using AgileFlow. If you encounter a problem not covered here, check the community discussions or open an issue in the project repository.
|
|
4
|
+
|
|
5
|
+
## Quick Diagnosis
|
|
6
|
+
|
|
7
|
+
### Check Pipeline Status
|
|
8
|
+
|
|
9
|
+
First, verify your pipeline status:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# Check if AgileFlow job completed successfully
|
|
13
|
+
gitlab-ci status
|
|
14
|
+
|
|
15
|
+
# View pipeline logs
|
|
16
|
+
gitlab-ci logs agileflow
|
|
17
|
+
|
|
18
|
+
# Check if VERSION variable is available
|
|
19
|
+
echo $VERSION
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Common Symptoms
|
|
23
|
+
|
|
24
|
+
- **Pipeline fails on version stage**
|
|
25
|
+
- **VERSION variable not available**
|
|
26
|
+
- **Build jobs fail with version errors**
|
|
27
|
+
- **Deployment inconsistencies**
|
|
28
|
+
- **Release notes not generated**
|
|
29
|
+
|
|
30
|
+
## Installation Issues
|
|
31
|
+
|
|
32
|
+
### Job Token Permissions Not Available
|
|
33
|
+
|
|
34
|
+
**Problem**: You don't see the "Allow Git push requests to the repository" option in GitLab CI/CD settings.
|
|
35
|
+
|
|
36
|
+
**Solution**:
|
|
37
|
+
1. Check if you're using a self-managed GitLab instance
|
|
38
|
+
2. Enable the feature flag `allow_push_repository_for_job_token`
|
|
39
|
+
3. Ensure you have admin access to the GitLab instance
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# For self-managed GitLab, enable the feature flag
|
|
43
|
+
sudo gitlab-rake gitlab:features:enable allow_push_repository_for_job_token
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Alternative**: Use a personal access token with write permissions to the repository.
|
|
47
|
+
|
|
48
|
+
### Template Include Fails
|
|
49
|
+
|
|
50
|
+
**Problem**: The AgileFlow template include statement fails with a network error.
|
|
51
|
+
|
|
52
|
+
**Solutions**:
|
|
53
|
+
1. **Check network connectivity** to `code.logickernel.com`
|
|
54
|
+
2. **Use local template** if remote access is restricted:
|
|
55
|
+
|
|
56
|
+
```yaml
|
|
57
|
+
# .gitlab-ci.yml
|
|
58
|
+
include:
|
|
59
|
+
- local: templates/AgileFlow.gitlab-ci.yml
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
3. **Copy template locally** and include from your repository:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Download template to your repository
|
|
66
|
+
curl -o templates/AgileFlow.gitlab-ci.yml \
|
|
67
|
+
https://code.logickernel.com/kernel/agileflow/-/raw/main/templates/AgileFlow.gitlab-ci.yml
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Docker Image Pull Fails
|
|
71
|
+
|
|
72
|
+
**Problem**: Cannot pull the AgileFlow Docker image.
|
|
73
|
+
|
|
74
|
+
**Solutions**:
|
|
75
|
+
1. **Check Docker daemon** is running
|
|
76
|
+
2. **Verify image name** and tag
|
|
77
|
+
3. **Check registry access** and authentication
|
|
78
|
+
4. **Use alternative image** if available
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# Test Docker connectivity
|
|
82
|
+
docker pull hello-world
|
|
83
|
+
|
|
84
|
+
# Check AgileFlow image availability
|
|
85
|
+
docker pull registry.logickernel.com/kernel/agileflow:latest
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Version Generation Issues
|
|
89
|
+
|
|
90
|
+
### VERSION Variable Not Available
|
|
91
|
+
|
|
92
|
+
**Problem**: The `${VERSION}` variable is not available in subsequent pipeline stages.
|
|
93
|
+
|
|
94
|
+
**Causes and Solutions**:
|
|
95
|
+
|
|
96
|
+
1. **AgileFlow job failed**
|
|
97
|
+
```bash
|
|
98
|
+
# Check agileflow job status
|
|
99
|
+
gitlab-ci logs agileflow
|
|
100
|
+
|
|
101
|
+
# Ensure job completed successfully
|
|
102
|
+
gitlab-ci status agileflow
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
2. **Missing job dependency**
|
|
106
|
+
```yaml
|
|
107
|
+
# ✅ Good - Proper dependency
|
|
108
|
+
build:
|
|
109
|
+
stage: build
|
|
110
|
+
needs:
|
|
111
|
+
- agileflow
|
|
112
|
+
|
|
113
|
+
# ❌ Bad - No dependency specified
|
|
114
|
+
build:
|
|
115
|
+
stage: build
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Version Not Generated
|
|
119
|
+
|
|
120
|
+
**Problem**: AgileFlow doesn't create a new version tag.
|
|
121
|
+
|
|
122
|
+
**Causes and Solutions**:
|
|
123
|
+
|
|
124
|
+
1. **No conventional commits detected**
|
|
125
|
+
```bash
|
|
126
|
+
# Check commit messages
|
|
127
|
+
git log --oneline -10
|
|
128
|
+
|
|
129
|
+
# Use conventional commit format
|
|
130
|
+
git commit -m "feat: add new feature"
|
|
131
|
+
git commit -m "fix: resolve bug"
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
2. **No merge to main branch**
|
|
135
|
+
```bash
|
|
136
|
+
# Verify you're on main branch
|
|
137
|
+
git branch
|
|
138
|
+
|
|
139
|
+
# Check if changes were merged
|
|
140
|
+
git log --oneline --graph
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Incorrect Version Bumping
|
|
144
|
+
|
|
145
|
+
**Problem**: AgileFlow generates the wrong version number.
|
|
146
|
+
|
|
147
|
+
**Causes and Solutions**:
|
|
148
|
+
|
|
149
|
+
1. **Commit type not recognized**
|
|
150
|
+
```bash
|
|
151
|
+
# Use recognized commit types
|
|
152
|
+
feat: new feature # Minor version bump
|
|
153
|
+
fix: bug fix # Patch version bump
|
|
154
|
+
perf: performance improvement # Patch version bump
|
|
155
|
+
refactor: code refactoring # Patch version bump
|
|
156
|
+
build: build system change # Patch version bump
|
|
157
|
+
ci: CI/CD change # Patch version bump
|
|
158
|
+
test: test additions/changes # Patch version bump
|
|
159
|
+
revert: revert commit # Patch version bump
|
|
160
|
+
feat!: breaking change # Major version bump
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
2. **Breaking change not properly marked**
|
|
164
|
+
```bash
|
|
165
|
+
# Use exclamation mark or footer
|
|
166
|
+
feat!: remove deprecated API
|
|
167
|
+
|
|
168
|
+
# Or use footer
|
|
169
|
+
feat: change API format
|
|
170
|
+
|
|
171
|
+
BREAKING CHANGE: API format changed from v1 to v2
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
3. **Version calculation logic issues**
|
|
175
|
+
```bash
|
|
176
|
+
# Check commit history
|
|
177
|
+
git log --oneline --since="1 week ago"
|
|
178
|
+
|
|
179
|
+
# Verify conventional commit format
|
|
180
|
+
git log --grep="^feat\|^fix\|^perf\|^refactor"
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Pipeline Issues
|
|
184
|
+
|
|
185
|
+
### Build Stage Failures
|
|
186
|
+
|
|
187
|
+
**Problem**: Build jobs fail with version-related errors.
|
|
188
|
+
|
|
189
|
+
**Solutions**:
|
|
190
|
+
|
|
191
|
+
1. **Check VERSION variable usage**
|
|
192
|
+
```yaml
|
|
193
|
+
# ✅ Good - Proper variable usage
|
|
194
|
+
build:
|
|
195
|
+
script:
|
|
196
|
+
- docker build -t myapp:${VERSION} .
|
|
197
|
+
|
|
198
|
+
# ❌ Bad - Hardcoded or incorrect variable
|
|
199
|
+
build:
|
|
200
|
+
script:
|
|
201
|
+
- docker build -t myapp:latest .
|
|
202
|
+
- docker build -t myapp:$VERSION .
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
2. **Verify job dependencies**
|
|
206
|
+
```yaml
|
|
207
|
+
# Ensure build depends on agileflow
|
|
208
|
+
build:
|
|
209
|
+
stage: build
|
|
210
|
+
needs:
|
|
211
|
+
- agileflow
|
|
212
|
+
script:
|
|
213
|
+
- echo "Building version ${VERSION}"
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
3. **Check variable expansion**
|
|
217
|
+
```yaml
|
|
218
|
+
# Test variable availability
|
|
219
|
+
build:
|
|
220
|
+
script:
|
|
221
|
+
- echo "VERSION: ${VERSION}"
|
|
222
|
+
- echo "CI_COMMIT_REF_NAME: ${CI_COMMIT_REF_NAME}"
|
|
223
|
+
- docker build -t myapp:${VERSION} .
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Release Notes Issues
|
|
227
|
+
|
|
228
|
+
### Empty Release Notes
|
|
229
|
+
|
|
230
|
+
**Problem**: Release notes are not generated or are empty.
|
|
231
|
+
|
|
232
|
+
**Solutions**:
|
|
233
|
+
|
|
234
|
+
1. **Check commit message format**
|
|
235
|
+
```bash
|
|
236
|
+
# View recent commits
|
|
237
|
+
git log --oneline -10
|
|
238
|
+
|
|
239
|
+
# Ensure conventional commit format
|
|
240
|
+
git log --grep="^feat\|^fix\|^perf\|^refactor\|^docs\|^test\|^build\|^ci\|^chore\|^style"
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
2. **Verify AgileFlow configuration**
|
|
244
|
+
```javascript
|
|
245
|
+
// agileflow.config.js
|
|
246
|
+
module.exports = {
|
|
247
|
+
releaseNotes: {
|
|
248
|
+
enabled: true,
|
|
249
|
+
format: 'conventional',
|
|
250
|
+
includeBody: true,
|
|
251
|
+
groupByType: true
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
3. **Check tag creation**
|
|
257
|
+
```bash
|
|
258
|
+
# List all tags
|
|
259
|
+
git tag --sort=-version:refname
|
|
260
|
+
|
|
261
|
+
# View tag message
|
|
262
|
+
git tag -l -n99 v1.2.3
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Malformed Release Notes
|
|
266
|
+
|
|
267
|
+
**Problem**: Release notes are generated but poorly formatted.
|
|
268
|
+
|
|
269
|
+
**Solutions**:
|
|
270
|
+
|
|
271
|
+
1. **Improve commit message quality**
|
|
272
|
+
```bash
|
|
273
|
+
# ✅ Good commit messages
|
|
274
|
+
feat(auth): add OAuth2 login support
|
|
275
|
+
fix(api): handle null user ID gracefully
|
|
276
|
+
docs: update installation guide
|
|
277
|
+
|
|
278
|
+
# ❌ Poor commit messages
|
|
279
|
+
add oauth
|
|
280
|
+
fix bug
|
|
281
|
+
update docs
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
2. **Use consistent scopes**
|
|
285
|
+
```bash
|
|
286
|
+
# Consistent scope usage
|
|
287
|
+
feat(auth): add OAuth2 login
|
|
288
|
+
feat(auth): implement JWT refresh
|
|
289
|
+
fix(auth): handle expired tokens
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
3. **Include meaningful descriptions**
|
|
293
|
+
```bash
|
|
294
|
+
# Descriptive commit messages
|
|
295
|
+
feat(auth): add OAuth2 login support with Google and GitHub providers
|
|
296
|
+
|
|
297
|
+
Implements OAuth2 authentication flow supporting multiple
|
|
298
|
+
identity providers. Includes proper error handling and
|
|
299
|
+
user session management.
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
## Debugging Techniques
|
|
303
|
+
|
|
304
|
+
### Enable Debug Logging
|
|
305
|
+
|
|
306
|
+
```yaml
|
|
307
|
+
agileflow:
|
|
308
|
+
variables:
|
|
309
|
+
AGILEFLOW_DEBUG: "true"
|
|
310
|
+
AGILEFLOW_LOG_LEVEL: "debug"
|
|
311
|
+
script:
|
|
312
|
+
- agileflow gitlab-ci --verbose
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### Check Environment Variables
|
|
316
|
+
|
|
317
|
+
```yaml
|
|
318
|
+
debug-env:
|
|
319
|
+
stage: build
|
|
320
|
+
script:
|
|
321
|
+
- echo "VERSION: ${VERSION}"
|
|
322
|
+
- echo "CI_COMMIT_REF_NAME: ${CI_COMMIT_REF_NAME}"
|
|
323
|
+
- echo "CI_COMMIT_SHA: ${CI_COMMIT_SHA}"
|
|
324
|
+
- env | grep -E "(VERSION|CI_|AGILEFLOW_)"
|
|
325
|
+
needs:
|
|
326
|
+
- agileflow
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### Verify Git State
|
|
330
|
+
|
|
331
|
+
```yaml
|
|
332
|
+
verify-git:
|
|
333
|
+
stage: build
|
|
334
|
+
script:
|
|
335
|
+
- git status
|
|
336
|
+
- git log --oneline -5
|
|
337
|
+
- git tag --sort=-version:refname | head -5
|
|
338
|
+
- git remote -v
|
|
339
|
+
needs:
|
|
340
|
+
- agileflow
|
|
341
|
+
```
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# Version-Centric CI/CD Approach
|
|
2
|
+
|
|
3
|
+
AgileFlow introduces a revolutionary approach to CI/CD that prioritizes **version management over environment-based deployments**. This paradigm shift eliminates the complexity of managing multiple deployment branches and environments, replacing them with a streamlined, version-focused workflow.
|
|
4
|
+
|
|
5
|
+
## Traditional Git-Based Flows vs. AgileFlow
|
|
6
|
+
|
|
7
|
+
### Traditional Approach (Branch-Based Environments)
|
|
8
|
+
Traditional CI/CD pipelines often rely on branch-based environment management:
|
|
9
|
+
|
|
10
|
+
```mermaid
|
|
11
|
+
graph LR
|
|
12
|
+
A[main branch] --> B[staging branch]
|
|
13
|
+
B --> C[production branch]
|
|
14
|
+
D[feature branch] --> A
|
|
15
|
+
E[hotfix branch] --> A
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
**Problems with Traditional Approach:**
|
|
19
|
+
- **Environment Drift**: Different branches can diverge, leading to "works in staging, breaks in production"
|
|
20
|
+
- **Complex Branch Management**: Multiple long-lived branches require constant synchronization
|
|
21
|
+
- **Deployment Uncertainty**: Hard to know exactly what version is running in each environment
|
|
22
|
+
- **Rollback Complexity**: Rolling back requires managing multiple branch states
|
|
23
|
+
- **Version Inconsistency**: Different environments may run different versions
|
|
24
|
+
|
|
25
|
+
### AgileFlow Approach (Version-Centric)
|
|
26
|
+
AgileFlow simplifies this by making **every deployment, test, and operation version-centric**:
|
|
27
|
+
|
|
28
|
+
```mermaid
|
|
29
|
+
graph LR
|
|
30
|
+
A[main branch] --> B[Version v1.2.3]
|
|
31
|
+
B --> C[Deploy to Staging]
|
|
32
|
+
B --> D[Deploy to Production]
|
|
33
|
+
B --> E[Run Integration Tests]
|
|
34
|
+
B --> F[Performance Testing]
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Benefits of Version-Centric Approach:**
|
|
38
|
+
- **Single Source of Truth**: All environments run the exact same version
|
|
39
|
+
- **Predictable Deployments**: Every deployment uses a well-identified, immutable version
|
|
40
|
+
- **Simplified Rollbacks**: Rollback to any previous version with confidence
|
|
41
|
+
- **Consistent Testing**: All tests run against the same version that will be deployed
|
|
42
|
+
- **Clear Audit Trail**: Every deployment is tied to a specific, documented version
|
|
43
|
+
|
|
44
|
+
## Simplified Pipeline Stages
|
|
45
|
+
|
|
46
|
+
AgileFlow's CI/CD pipeline consists of just 6 focused stages:
|
|
47
|
+
|
|
48
|
+
### 1. **Version** Stage
|
|
49
|
+
- **Purpose**: Generate semantic version and comprehensive release notes
|
|
50
|
+
- **Output**: `VERSION` variable available to all subsequent stages
|
|
51
|
+
- **Automation**: Uses AgileFlow tool to analyze commit history and determine next version
|
|
52
|
+
- **Artifacts**: Version tag pushed to repository, release notes generated
|
|
53
|
+
|
|
54
|
+
### 2. **Test** Stage
|
|
55
|
+
- **Purpose**: Run tests against the source code before building
|
|
56
|
+
- **Input**: Uses the source code and `VERSION` variable from the version stage
|
|
57
|
+
- **Output**: Test results and validation that the code is ready for building
|
|
58
|
+
- **Benefits**: Catch issues early before building artifacts
|
|
59
|
+
|
|
60
|
+
### 3. **Build** Stage
|
|
61
|
+
- **Purpose**: Create application artifacts and Docker images
|
|
62
|
+
- **Input**: Uses the `VERSION` variable from the version stage
|
|
63
|
+
- **Output**: Versioned artifacts (e.g., `app:v1.2.3`, `frontend:v1.2.3`)
|
|
64
|
+
- **Consistency**: All builds use the same version identifier
|
|
65
|
+
|
|
66
|
+
### 4. **Deploy** Stage
|
|
67
|
+
- **Purpose**: Deploy the versioned artifacts to various environments
|
|
68
|
+
- **Approach**: Deploy the same version to staging, production, etc.
|
|
69
|
+
- **Benefits**: Identical behavior across all environments
|
|
70
|
+
- **Rollback**: Simple version-based rollback (e.g., "rollback to v1.2.2")
|
|
71
|
+
|
|
72
|
+
### 5. **E2E** Stage
|
|
73
|
+
- **Purpose**: Run end-to-end tests against the deployed version
|
|
74
|
+
- **Scope**: Integration tests, end-to-end tests, performance tests
|
|
75
|
+
- **Target**: Tests run against the actual deployed version
|
|
76
|
+
- **Confidence**: Tests validate exactly what will run in production
|
|
77
|
+
|
|
78
|
+
### 6. **Clean** Stage
|
|
79
|
+
- **Purpose**: Cleanup temporary resources and artifacts
|
|
80
|
+
- **Maintenance**: Remove old Docker images, temporary files, etc.
|
|
81
|
+
- **Optimization**: Keep only necessary version artifacts
|
|
82
|
+
|
|
83
|
+
## Real-World Example
|
|
84
|
+
|
|
85
|
+
Here's how the version-centric approach works in practice:
|
|
86
|
+
|
|
87
|
+
```yaml
|
|
88
|
+
# .gitlab-ci.yml
|
|
89
|
+
include:
|
|
90
|
+
- local: templates/AgileFlow.gitlab-ci.yml
|
|
91
|
+
|
|
92
|
+
# Test stage runs tests against source code
|
|
93
|
+
test:
|
|
94
|
+
stage: test
|
|
95
|
+
script:
|
|
96
|
+
- npm test
|
|
97
|
+
- npm run lint
|
|
98
|
+
|
|
99
|
+
# Build stage uses VERSION from agileflow job
|
|
100
|
+
build:
|
|
101
|
+
stage: build
|
|
102
|
+
script:
|
|
103
|
+
- docker build -t myapp:${VERSION} .
|
|
104
|
+
- docker push myapp:${VERSION}
|
|
105
|
+
needs:
|
|
106
|
+
- test
|
|
107
|
+
|
|
108
|
+
# Deploy stage deploys the same version everywhere
|
|
109
|
+
deploy-testing:
|
|
110
|
+
stage: deploy
|
|
111
|
+
script:
|
|
112
|
+
- kubectl set image deployment/myapp myapp=myapp:${VERSION}
|
|
113
|
+
environment:
|
|
114
|
+
name: testing
|
|
115
|
+
needs:
|
|
116
|
+
- build
|
|
117
|
+
|
|
118
|
+
deploy-staging:
|
|
119
|
+
stage: deploy
|
|
120
|
+
script:
|
|
121
|
+
- kubectl set image deployment/myapp myapp=myapp:${VERSION}
|
|
122
|
+
environment:
|
|
123
|
+
name: staging
|
|
124
|
+
when: manual
|
|
125
|
+
needs:
|
|
126
|
+
- build
|
|
127
|
+
|
|
128
|
+
deploy-production:
|
|
129
|
+
stage: deploy
|
|
130
|
+
script:
|
|
131
|
+
- kubectl set image deployment/myapp myapp=myapp:${VERSION}
|
|
132
|
+
environment:
|
|
133
|
+
name: production
|
|
134
|
+
when: manual
|
|
135
|
+
needs:
|
|
136
|
+
- build
|
|
137
|
+
|
|
138
|
+
# E2E stage validates the deployed version
|
|
139
|
+
integration-tests:
|
|
140
|
+
stage: e2e
|
|
141
|
+
script:
|
|
142
|
+
- ./run-tests.sh --version ${VERSION}
|
|
143
|
+
needs:
|
|
144
|
+
- deploy-testing
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Key Advantages
|
|
148
|
+
|
|
149
|
+
1. **Eliminates Environment Drift**: Staging and production always run identical versions
|
|
150
|
+
2. **Simplifies Operations**: DevOps teams work with versions, not branch states
|
|
151
|
+
3. **Improves Reliability**: Every deployment is predictable and auditable
|
|
152
|
+
4. **Reduces Complexity**: No need to manage multiple deployment branches
|
|
153
|
+
5. **Enhances Security**: Version-based deployments provide clear audit trails
|
|
154
|
+
6. **Facilitates Compliance**: Easy to demonstrate what version is running where
|
|
155
|
+
|
|
156
|
+
## Migration Path
|
|
157
|
+
|
|
158
|
+
If you're currently using a traditional branch-based approach:
|
|
159
|
+
|
|
160
|
+
1. **Start with AgileFlow**: Include the template and let it generate versions
|
|
161
|
+
2. **Gradually Simplify**: Remove environment-specific branches over time
|
|
162
|
+
3. **Update Deployments**: Modify deployment scripts to use `${VERSION}` variable
|
|
163
|
+
4. **Standardize Testing**: Run all tests against the versioned artifacts
|
|
164
|
+
5. **Document Changes**: Update runbooks to reference versions instead of branches
|
|
165
|
+
|
|
166
|
+
This approach transforms your CI/CD from a complex, branch-managed system into a simple, version-driven pipeline where every deployment is predictable, auditable, and reliable.
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@logickernel/agileflow",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Automatic semantic versioning and changelog generation based on conventional commits",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"agileflow": "bin/agileflow"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin",
|
|
11
|
+
"src",
|
|
12
|
+
"templates",
|
|
13
|
+
"docs",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"semantic-versioning",
|
|
21
|
+
"conventional-commits",
|
|
22
|
+
"changelog",
|
|
23
|
+
"versioning",
|
|
24
|
+
"git",
|
|
25
|
+
"ci-cd",
|
|
26
|
+
"gitlab",
|
|
27
|
+
"automation",
|
|
28
|
+
"release-management"
|
|
29
|
+
],
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=14.0.0"
|
|
32
|
+
},
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git@code.logickernel.com:kernel/agileflow.git"
|
|
36
|
+
},
|
|
37
|
+
"author": "",
|
|
38
|
+
"license": "ISC"
|
|
39
|
+
}
|
package/src/git-utils.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { execSync } = require('child_process');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Executes a shell command and returns the output.
|
|
8
|
+
* @param {string} command - The command to execute
|
|
9
|
+
* @param {Object} options - Execution options
|
|
10
|
+
* @returns {string} Command output
|
|
11
|
+
* @throws {Error} If command fails
|
|
12
|
+
*/
|
|
13
|
+
function runWithOutput(command, options = {}) {
|
|
14
|
+
try {
|
|
15
|
+
return execSync(command, { stdio: 'pipe', encoding: 'utf8', ...options });
|
|
16
|
+
} catch (error) {
|
|
17
|
+
const captured = {
|
|
18
|
+
stdout: error?.stdout ? String(error.stdout) : '',
|
|
19
|
+
stderr: error?.stderr ? String(error.stderr) : '',
|
|
20
|
+
message: error?.message || 'Command failed',
|
|
21
|
+
status: typeof error?.status === 'number' ? error.status : 1,
|
|
22
|
+
};
|
|
23
|
+
try {
|
|
24
|
+
Object.defineProperty(error, '_captured', { value: captured });
|
|
25
|
+
} catch {
|
|
26
|
+
error._captured = captured;
|
|
27
|
+
}
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Executes a shell command without returning output.
|
|
34
|
+
* @param {string} command - The command to execute
|
|
35
|
+
* @param {Object} options - Execution options
|
|
36
|
+
* @throws {Error} If command fails
|
|
37
|
+
*/
|
|
38
|
+
function run(command, options = {}) {
|
|
39
|
+
execSync(command, { stdio: 'pipe', ...options });
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Ensures the current directory is a git repository.
|
|
44
|
+
* @throws {Error} If the current directory is not a git repository
|
|
45
|
+
*/
|
|
46
|
+
function ensureGitRepo() {
|
|
47
|
+
if (!fs.existsSync('.git')) {
|
|
48
|
+
throw new Error('Current directory is not a git repository (missing .git directory).');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
module.exports = {
|
|
53
|
+
run,
|
|
54
|
+
runWithOutput,
|
|
55
|
+
ensureGitRepo,
|
|
56
|
+
};
|
|
57
|
+
|
package/src/index.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { version } = require('../package.json');
|
|
4
|
+
|
|
5
|
+
function printHelp() {
|
|
6
|
+
console.log(`agileflow - Automatic semantic versioning and changelog generation
|
|
7
|
+
|
|
8
|
+
Usage:
|
|
9
|
+
agileflow [options]
|
|
10
|
+
agileflow <command>
|
|
11
|
+
|
|
12
|
+
Commands:
|
|
13
|
+
gitlab-ci Configure git, compute semver tag, and push to GitLab (CI mode)
|
|
14
|
+
|
|
15
|
+
Options:
|
|
16
|
+
--branch <name> Allow running on specified branch (default: main)
|
|
17
|
+
-h, --help Show this help message
|
|
18
|
+
-v, --version Show version number
|
|
19
|
+
|
|
20
|
+
Examples:
|
|
21
|
+
agileflow # Run on main branch
|
|
22
|
+
agileflow --branch develop # Run on develop branch
|
|
23
|
+
agileflow gitlab-ci
|
|
24
|
+
|
|
25
|
+
For more information, visit: https://code.logickernel.com/kernel/agileflow
|
|
26
|
+
`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function parseArgs(args) {
|
|
30
|
+
const parsed = { branch: 'main' };
|
|
31
|
+
for (let i = 0; i < args.length; i++) {
|
|
32
|
+
if (args[i] === '--branch' && i + 1 < args.length) {
|
|
33
|
+
parsed.branch = args[i + 1];
|
|
34
|
+
i++;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return parsed;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function runLocal(args) {
|
|
41
|
+
const { branch } = parseArgs(args);
|
|
42
|
+
const localMain = require('./local.js');
|
|
43
|
+
await localMain(branch);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function main() {
|
|
47
|
+
const [, , cmd, ...rest] = process.argv;
|
|
48
|
+
|
|
49
|
+
// Handle help
|
|
50
|
+
if (cmd === '-h' || cmd === '--help' || cmd === 'help') {
|
|
51
|
+
printHelp();
|
|
52
|
+
process.exit(0);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Handle version
|
|
56
|
+
if (cmd === '-v' || cmd === '--version' || cmd === 'version') {
|
|
57
|
+
console.log(version);
|
|
58
|
+
process.exit(0);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Handle gitlab-ci command
|
|
62
|
+
if (cmd === 'gitlab-ci') {
|
|
63
|
+
console.error('Error: gitlab-ci command is not yet implemented');
|
|
64
|
+
console.error('This feature will be available in a future release.');
|
|
65
|
+
process.exit(1);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Unknown command
|
|
69
|
+
if (cmd && !cmd.startsWith('--')) {
|
|
70
|
+
console.error(`Error: Unknown command "${cmd}"`);
|
|
71
|
+
console.error();
|
|
72
|
+
printHelp();
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Default: run version calculation
|
|
77
|
+
await runLocal(cmd ? [cmd, ...rest] : rest);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
process.on('unhandledRejection', (err) => {
|
|
81
|
+
console.error('Error:', err.message);
|
|
82
|
+
process.exit(1);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
main().catch((err) => {
|
|
86
|
+
console.error('Error:', err.message);
|
|
87
|
+
process.exit(err.status || 1);
|
|
88
|
+
});
|
package/src/local.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const { processVersionInfo } = require('./utils');
|
|
2
|
+
|
|
3
|
+
async function main(branch = 'main') {
|
|
4
|
+
try {
|
|
5
|
+
const { previousVersion, nextVersion, commits, changelog } = await processVersionInfo(branch);
|
|
6
|
+
|
|
7
|
+
console.log(`Previous version: ${previousVersion || 'none'}`);
|
|
8
|
+
console.log(`Next version: ${nextVersion}`);
|
|
9
|
+
console.log(`Commits since latest version: ${commits.length}`);
|
|
10
|
+
console.log(`\nChangelog:\n${changelog}`);
|
|
11
|
+
} catch (err) {
|
|
12
|
+
console.error('Error:', err.message);
|
|
13
|
+
process.exit(err.status || 1);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = main;
|