@logickernel/agileflow 0.4.0 → 0.4.2

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.
@@ -1,339 +1,306 @@
1
- # Best Practices Guide
1
+ # Best Practices
2
2
 
3
- This guide provides recommended practices and patterns for using AgileFlow effectively in your development workflow.
3
+ This guide covers recommended practices for using AgileFlow effectively.
4
+
5
+ ## Decoupled Pipeline Architecture
6
+
7
+ ### Separate Versioning from Build/Deploy
8
+
9
+ AgileFlow works best with a decoupled architecture:
10
+
11
+ ```
12
+ Versioning Workflow Release Workflow
13
+ ────────────────── ─────────────────
14
+ on: push to main on: tag created
15
+ → AgileFlow → build
16
+ → create tag → deploy
17
+ ```
18
+
19
+ **Benefits:**
20
+ - Clear separation of concerns
21
+ - Each pipeline has one responsibility
22
+ - Easy to rerun builds independently
23
+
24
+ ### Version Workflow (Minimal)
25
+
26
+ Keep the versioning workflow simple:
27
+
28
+ ```yaml
29
+ # ✅ Good — Focused on versioning only
30
+ name: Version
31
+ on:
32
+ push:
33
+ branches: [main]
34
+ jobs:
35
+ version:
36
+ steps:
37
+ - uses: actions/checkout@v4
38
+ with:
39
+ fetch-depth: 0
40
+ - run: npx @logickernel/agileflow github
41
+ ```
42
+
43
+ ### Release Workflow (Complete)
44
+
45
+ Put build and deploy logic in the tag-triggered workflow:
46
+
47
+ ```yaml
48
+ # ✅ Good — Triggered by tag, handles build/deploy
49
+ name: Release
50
+ on:
51
+ push:
52
+ tags: ['v*']
53
+ jobs:
54
+ build:
55
+ # Build logic here
56
+ deploy:
57
+ # Deploy logic here
58
+ ```
59
+
60
+ ---
4
61
 
5
62
  ## Commit Message Best Practices
6
63
 
7
- ### 1. Use Conventional Commits Consistently
64
+ ### Use Conventional Commits Consistently
8
65
 
9
66
  ```bash
10
- # ✅ Good - Clear and consistent
67
+ # ✅ Good Clear type and description
11
68
  feat(auth): add OAuth2 login support
12
69
  fix(api): handle null user ID gracefully
13
- docs: update installation guide
14
70
 
15
- # ❌ Bad - Inconsistent and unclear
71
+ # ❌ Bad Unclear
16
72
  add oauth
17
73
  fix bug
18
- update docs
19
74
  ```
20
75
 
21
- ### 2. Add Scopes for Better Organization
76
+ ### Add Scopes for Organization
22
77
 
23
78
  ```bash
24
- # ✅ Good - Scoped commits
25
- feat(auth): implement JWT token validation
26
- fix(api): resolve user lookup timeout
79
+ # ✅ Good Scoped commits
80
+ feat(auth): implement JWT validation
81
+ fix(api): resolve timeout issue
27
82
  docs(readme): add troubleshooting section
28
-
29
- # ❌ Bad - No scope
30
- feat: implement JWT token validation
31
- fix: resolve user lookup timeout
32
- docs: add troubleshooting section
33
83
  ```
34
84
 
35
- ### 3. Write Clear, Descriptive Messages
85
+ ### Mark Breaking Changes Properly
36
86
 
37
87
  ```bash
38
- # ✅ Good - Clear description
39
- feat(auth): add two-factor authentication with SMS
40
- fix(api): handle database connection failures gracefully
41
- docs: add comprehensive API reference
42
-
43
- # ❌ Bad - Vague description
44
- feat: add 2FA
45
- fix: fix bug
46
- docs: update docs
47
- ```
88
+ # ✅ Good Breaking change marked
89
+ feat!: remove deprecated API endpoints
48
90
 
49
- ### 4. Use Breaking Change Indicators Properly
91
+ # Good Using footer
92
+ feat: change API format
50
93
 
51
- ```bash
52
- # ✅ Good - Breaking changes clearly marked
53
- feat!: remove deprecated API endpoints
54
- feat(auth)!: change user ID format to UUID
55
- BREAKING CHANGE: modify database schema
94
+ BREAKING CHANGE: Response uses camelCase keys
56
95
 
57
- # ❌ Bad - Breaking changes not marked
58
- feat: remove deprecated API endpoints
59
- feat(auth): change user ID format to UUID
96
+ # ❌ Bad Not marked
97
+ feat: remove deprecated endpoints
60
98
  ```
61
99
 
62
- ## Pipeline Configuration Best Practices
100
+ ---
101
+
102
+ ## Pipeline Best Practices
63
103
 
64
- ### 1. Always Use the VERSION Variable
104
+ ### Use Tag as Version
65
105
 
106
+ In your release workflow, extract the version from the tag:
107
+
108
+ **GitHub Actions:**
66
109
  ```yaml
67
- # ✅ Good - Uses VERSION from AgileFlow
68
- build:
69
- stage: build
70
- script:
71
- - docker build -t myapp:${VERSION} .
72
- - docker push myapp:${VERSION}
110
+ - name: Get version
111
+ run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
73
112
 
74
- # ❌ Bad - Hardcoded or branch-based tagging
75
- build:
76
- stage: build
77
- script:
78
- - docker build -t myapp:latest .
79
- - docker build -t myapp:${CI_COMMIT_REF_SLUG} .
113
+ - name: Build
114
+ run: docker build -t myapp:$VERSION .
80
115
  ```
81
116
 
82
- ### 2. Proper Stage Dependencies
83
-
117
+ **GitLab CI:**
84
118
  ```yaml
85
- # ✅ Good - Clear dependency chain
86
- deploy:
87
- stage: deploy
88
- needs:
89
- - build
90
-
91
- # ❌ Bad - No dependencies specified
92
- deploy:
93
- stage: deploy
119
+ build:
120
+ script:
121
+ - docker build -t myapp:$CI_COMMIT_TAG .
122
+ rules:
123
+ - if: '$CI_COMMIT_TAG =~ /^v/'
94
124
  ```
95
125
 
96
- ### 3. Environment-Specific Deployments
126
+ ### Deploy Same Version Everywhere
97
127
 
98
128
  ```yaml
99
- # ✅ Good - Same version, different environments
129
+ # ✅ Good Same version for all environments
100
130
  deploy-staging:
101
- environment:
102
- name: staging
131
+ script:
132
+ - kubectl set image deployment/myapp myapp=myapp:$VERSION
103
133
 
104
134
  deploy-production:
105
- environment:
106
- name: production
107
- when: manual
135
+ script:
136
+ - kubectl set image deployment/myapp myapp=myapp:$VERSION
108
137
  ```
109
138
 
110
- ### 4. Consistent Testing
139
+ ### Add Health Checks
111
140
 
112
141
  ```yaml
113
- # ✅ Good - Test against deployed version
114
- test:
115
- stage: test
142
+ deploy:
116
143
  script:
117
- - ./run-tests.sh --version ${VERSION}
118
- needs:
119
- - deploy-staging
144
+ - kubectl set image deployment/myapp myapp=myapp:$VERSION
145
+ - kubectl rollout status deployment/myapp --timeout=300s
146
+ - ./health-check.sh
120
147
  ```
121
148
 
149
+ ---
150
+
122
151
  ## Version Management Best Practices
123
152
 
124
- ### 1. Keep Releases Small and Focused
153
+ ### Keep Releases Small
125
154
 
126
- - **Small releases** reduce risk and make debugging easier
127
- - **Frequent releases** provide faster feedback
128
- - **Focused changes** make rollbacks more predictable
155
+ - Small releases reduce risk
156
+ - Frequent releases provide faster feedback
157
+ - Focused changes simplify rollbacks
129
158
 
130
- ### 2. Test Thoroughly Before Merging
159
+ ### Test Before Merging
131
160
 
132
- - **Unit tests** should pass on feature branches
133
- - **Integration tests** should run before merge
134
- - **Documentation** should be updated with changes
161
+ - Unit tests pass on feature branches
162
+ - Integration tests run before merge
163
+ - Documentation updated with changes
135
164
 
136
- ### 3. Use Feature Flags for Large Changes
165
+ ### Plan for Rollbacks
137
166
 
167
+ **GitHub Actions:**
138
168
  ```yaml
139
- # ✅ Good - Feature flag for gradual rollout
140
- deploy:
141
- stage: deploy
142
- script:
143
- - kubectl set image deployment/myapp myapp=myapp:${VERSION}
144
- - kubectl patch deployment/myapp -p '{"spec":{"template":{"metadata":{"annotations":{"feature-flag/new-auth":"enabled"}}}}}'
169
+ rollback:
170
+ runs-on: ubuntu-latest
171
+ steps:
172
+ - uses: actions/checkout@v4
173
+ with:
174
+ fetch-depth: 0
175
+ - name: Rollback
176
+ run: |
177
+ PREVIOUS=$(git describe --tags --abbrev=0 HEAD^)
178
+ kubectl set image deployment/myapp myapp=myapp:$PREVIOUS
145
179
  ```
146
180
 
147
- ### 4. Monitor Deployments
148
-
181
+ **GitLab CI:**
149
182
  ```yaml
150
- # ✅ Good - Health checks after deployment
151
- deploy:
152
- stage: deploy
183
+ rollback:
153
184
  script:
154
- - kubectl set image deployment/myapp myapp=myapp:${VERSION}
155
- - kubectl rollout status deployment/myapp --timeout=300s
156
- - ./health-check.sh
185
+ - PREVIOUS=$(git describe --tags --abbrev=0 HEAD^)
186
+ - kubectl set image deployment/myapp myapp=myapp:$PREVIOUS
187
+ when: manual
157
188
  ```
158
189
 
159
- ## Security Best Practices
190
+ ---
160
191
 
161
- ### 1. Secure Environment Variables
192
+ ## Security Best Practices
162
193
 
163
- ```yaml
164
- # ✅ Good - Protected and masked variables
165
- variables:
166
- AGILEFLOW_TOKEN: $AGILEFLOW_TOKEN # Protected and masked
167
- GITLAB_USER_NAME: "AgileFlow Bot" # Not sensitive
168
-
169
- # ❌ Bad - Exposed sensitive information
170
- variables:
171
- AGILEFLOW_TOKEN: "glpat-xxxxxxxxxxxxxxxxxxxx"
172
- ```
194
+ ### Protect Tokens
173
195
 
174
- ### 2. Minimal Token Permissions
196
+ **GitHub:**
197
+ - Use repository secrets (automatically protected)
198
+ - Rotate tokens regularly
175
199
 
176
- - **Use project tokens** instead of personal tokens when possible
177
- - **Limit token scope** to only required permissions
178
- - **Regular token rotation** for security
200
+ **GitLab:**
201
+ - Mark variables as Protected and Masked
202
+ - Use project tokens over personal tokens
179
203
 
180
- ### 3. Environment Isolation
204
+ ### Minimal Permissions
181
205
 
182
- ```yaml
183
- # ✅ Good - Environment-specific configurations
184
- deploy-staging:
185
- environment:
186
- name: staging
187
- variables:
188
- DATABASE_URL: $STAGING_DATABASE_URL
206
+ | Platform | Required Permission |
207
+ |----------|---------------------|
208
+ | GitHub | `contents: write` |
209
+ | GitLab | `api` scope, `Maintainer` role |
189
210
 
190
- deploy-production:
191
- environment:
192
- name: production
193
- variables:
194
- DATABASE_URL: $PRODUCTION_DATABASE_URL
195
- ```
211
+ ---
196
212
 
197
213
  ## Performance Best Practices
198
214
 
199
- ### 1. Optimize Build Times
215
+ ### Shallow Clone for Release Workflow
216
+
217
+ The release workflow doesn't need full history:
200
218
 
201
219
  ```yaml
202
- # Good - Cached dependencies
220
+ # Versioning needs full history
221
+ version:
222
+ steps:
223
+ - uses: actions/checkout@v4
224
+ with:
225
+ fetch-depth: 0 # Full history
226
+
227
+ # Release — doesn't need history
203
228
  build:
204
- stage: build
205
- cache:
206
- key: ${CI_COMMIT_REF_SLUG}
207
- paths:
208
- - node_modules/
209
- - .cache/
210
- script:
211
- - npm ci --cache .npm --prefer-offline
212
- - npm run build
229
+ steps:
230
+ - uses: actions/checkout@v4
231
+ # Default shallow clone
213
232
  ```
214
233
 
215
- ### 2. Parallel Job Execution
234
+ ### Cache Dependencies
216
235
 
217
236
  ```yaml
218
- # ✅ Good - Parallel builds for multiple services
219
- build-backend:
220
- stage: build
221
- script:
222
- - docker build -t backend:${VERSION} ./backend
223
-
224
- build-frontend:
225
- stage: build
226
- script:
227
- - docker build -t frontend:${VERSION} ./frontend
228
-
229
- # Both jobs can run in parallel
237
+ - uses: actions/cache@v4
238
+ with:
239
+ path: ~/.npm
240
+ key: npm-${{ hashFiles('package-lock.json') }}
230
241
  ```
231
242
 
232
- ### 3. Efficient Artifact Management
243
+ ### Parallel Jobs
233
244
 
234
245
  ```yaml
235
- # Good - Selective artifacts
236
- build:
237
- stage: build
238
- artifacts:
239
- paths:
240
- - dist/
241
- - build/
242
- expire_in: 1 week
243
- when: on_success
246
+ # Build jobs run in parallel
247
+ build-backend:
248
+ runs-on: ubuntu-latest
249
+ build-frontend:
250
+ runs-on: ubuntu-latest
244
251
  ```
245
252
 
246
- ## Monitoring and Observability
253
+ ---
247
254
 
248
- ### 1. Pipeline Visibility
255
+ ## Documentation Best Practices
249
256
 
250
- ```yaml
251
- # ✅ Good - Clear job names and descriptions
252
- build-production:
253
- stage: build
254
- description: "Build production artifacts with version ${VERSION}"
255
- script:
256
- - echo "Building version ${VERSION}"
257
- ```
257
+ ### Write Meaningful Commit Messages
258
258
 
259
- ### 2. Deployment Tracking
259
+ ```bash
260
+ # ✅ Good — Becomes clear release note
261
+ feat(auth): add OAuth2 login with Google and GitHub providers
260
262
 
261
- ```yaml
262
- # Good - Track deployment status
263
- deploy:
264
- stage: deploy
265
- script:
266
- - kubectl set image deployment/myapp myapp=myapp:${VERSION}
267
- - echo "Deployed ${VERSION} at $(date)" >> deployment.log
263
+ # ❌ Bad — Poor release note
264
+ feat: add login
268
265
  ```
269
266
 
270
- ### 3. Error Reporting
267
+ ### Include Docs in Changes
271
268
 
272
- ```yaml
273
- # Good - Comprehensive error handling
274
- deploy:
275
- stage: deploy
276
- script:
277
- - |
278
- if ! kubectl set image deployment/myapp myapp=myapp:${VERSION}; then
279
- echo "Deployment failed for version ${VERSION}"
280
- exit 1
281
- fi
282
- ```
269
+ ```bash
270
+ git commit -m "feat(auth): add OAuth2 login
283
271
 
284
- ## Migration Best Practices
272
+ - Implement OAuth2 flow
273
+ - Add configuration documentation
274
+ - Update API reference"
275
+ ```
285
276
 
286
- ### 1. Gradual Adoption
277
+ ---
287
278
 
288
- - **Start with AgileFlow** on new projects
289
- - **Gradually migrate** existing pipelines
290
- - **Test thoroughly** before full migration
279
+ ## Team Best Practices
291
280
 
292
- ### 2. Team Training
281
+ ### Establish Conventions
293
282
 
294
- - **Train team members** on conventional commits
295
- - **Document workflow changes** clearly
296
- - **Provide examples** and templates
283
+ - Document commit message standards
284
+ - Use commit linting (commitlint, husky)
285
+ - Review commit messages in PRs
297
286
 
298
- ### 3. Rollback Planning
287
+ ### Communicate Releases
299
288
 
300
289
  ```yaml
301
- # ✅ Good - Rollback capability
302
- rollback:
303
- stage: deploy
290
+ notify:
304
291
  script:
305
292
  - |
306
- PREVIOUS_VERSION=$(git describe --abbrev=0 --tags v${VERSION%.*}.$((10#${VERSION##*.} - 1)))
307
- kubectl set image deployment/myapp myapp=myapp:${PREVIOUS_VERSION}
308
- when: manual
309
- allow_failure: true
293
+ curl -X POST "$SLACK_WEBHOOK" \
294
+ -d "{\"text\": \"Released $VERSION\"}"
295
+ rules:
296
+ - if: '$CI_COMMIT_TAG =~ /^v/'
310
297
  ```
311
298
 
312
- ## Documentation Best Practices
313
-
314
- ### 1. Keep Documentation Updated
315
-
316
- - **Update README** with new features
317
- - **Document breaking changes** clearly
318
- - **Provide examples** for common use cases
319
-
320
- ### 2. Version-Specific Documentation
321
-
322
- ```yaml
323
- # ✅ Good - Generate version-specific docs
324
- docs:
325
- stage: deploy
326
- script:
327
- - |
328
- echo "# Version ${VERSION}" > docs/versions/${VERSION}.md
329
- echo "Released: $(date)" >> docs/versions/${VERSION}.md
330
- echo "Changes: $(git tag -l -n99 ${VERSION})" >> docs/versions/${VERSION}.md
331
- ```
299
+ ---
332
300
 
333
301
  ## Related Documentation
334
302
 
335
- - [Getting Started](./getting-started.md) - Quick start guide
336
- - [Conventional Commits](./conventional-commits.md) - Commit message format
337
- - [GitLab CI Template](./gitlab-ci-template.md) - Template configuration
338
- - [Configuration](./configuration.md) - Environment variables
339
- - [Troubleshooting](./troubleshooting.md) - Common issues and solutions
303
+ - [Getting Started](./getting-started.md) Quick start
304
+ - [Conventional Commits](./conventional-commits.md) Commit format
305
+ - [Installation Guide](./installation.md) Setup
306
+ - [Troubleshooting](./troubleshooting.md) Common issues