@logickernel/agileflow 0.1.0 → 0.2.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.
@@ -1,324 +0,0 @@
1
- # GitLab CI Template Reference
2
-
3
- The AgileFlow GitLab CI template provides a streamlined, version-centric CI/CD pipeline that eliminates the complexity of traditional environment-based deployments.
4
-
5
- ## Overview
6
-
7
- This template implements a 6-stage pipeline that focuses on version management rather than branch-based environment management. Every deployment, test, and operation is performed on well-identified versions, ensuring consistency and reliability across all environments.
8
-
9
- ## Template Structure
10
-
11
- ```yaml
12
- include:
13
- - local: templates/AgileFlow.gitlab-ci.yml
14
- ```
15
-
16
- ## Pipeline Stages
17
-
18
- ### 1. Version Stage
19
- The foundation of the AgileFlow approach. This stage automatically generates semantic versions and comprehensive release notes.
20
-
21
- **Job**: `agileflow`
22
- - **Image**: `registry.logickernel.com/kernel/agileflow:0.8.0`
23
- - **Script**: `agileflow gitlab-ci`
24
- - **Artifacts**: `VERSION` variable (dotenv report)
25
-
26
- **What it does**:
27
- - Analyzes commit history on the main branch
28
- - Calculates the next semantic version based on conventional commits
29
- - Generates comprehensive release notes
30
- - Creates and pushes version tags to the repository
31
- - Makes the `VERSION` variable available to all subsequent stages
32
-
33
- **Output**: The `VERSION` variable contains the generated semantic version (e.g., `v1.2.3`)
34
-
35
- ### 2. Test Stage
36
- Runs tests against the source code before building artifacts.
37
-
38
- **Purpose**: Validate that the source code is ready for building and deployment
39
- **Input**: Source code and `VERSION` variable from the version stage
40
- **Output**: Test results and validation that the code meets quality standards
41
-
42
- **Example implementation**:
43
- ```yaml
44
- test:
45
- stage: test
46
- script:
47
- - npm test
48
- - npm run lint
49
- needs:
50
- - agileflow
51
- ```
52
-
53
- ### 3. Build Stage
54
- Creates application artifacts and Docker images using the version from the version stage.
55
-
56
- **Purpose**: Build versioned artifacts that will be deployed across all environments
57
- **Input**: `VERSION` variable from the version stage
58
- **Output**: Versioned artifacts (e.g., `app:v1.2.3`, `frontend:v1.2.3`)
59
-
60
- **Example implementation**:
61
- ```yaml
62
- build:
63
- stage: build
64
- script:
65
- - docker build -t myapp:${VERSION} .
66
- - docker push myapp:${VERSION}
67
- needs:
68
- - test
69
- ```
70
-
71
- ### 4. Deploy Stage
72
- Deploys the versioned artifacts to various environments.
73
-
74
- **Purpose**: Deploy the same version to staging, production, and other environments
75
- **Approach**: All environments receive identical versions, eliminating environment drift
76
- **Benefits**: Predictable deployments, simplified rollbacks, consistent behavior
77
-
78
- **Example implementation**:
79
- ```yaml
80
- deploy-staging:
81
- stage: deploy
82
- script:
83
- - kubectl set image deployment/myapp myapp=myapp:${VERSION}
84
- environment:
85
- name: staging
86
- needs:
87
- - build
88
-
89
- deploy-production:
90
- stage: deploy
91
- script:
92
- - kubectl set image deployment/myapp myapp=myapp:${VERSION}
93
- environment:
94
- name: production
95
- when: manual
96
- needs:
97
- - build
98
- ```
99
-
100
- ### 5. E2E Stage
101
- Validates the deployed version across all environments.
102
-
103
- **Purpose**: Run tests against the actual deployed version
104
- **Scope**: Integration tests, end-to-end tests, performance tests
105
- **Target**: Tests validate exactly what will run in production
106
-
107
- **Example implementation**:
108
- ```yaml
109
- integration-tests:
110
- stage: e2e
111
- script:
112
- - ./run-tests.sh --version ${VERSION}
113
- needs:
114
- - deploy-staging
115
-
116
- performance-tests:
117
- stage: e2e
118
- script:
119
- - ./run-performance-tests.sh --version ${VERSION}
120
- needs:
121
- - deploy-staging
122
- ```
123
-
124
- ### 6. Clean Stage
125
- Cleanup temporary resources and artifacts.
126
-
127
- **Purpose**: Remove old Docker images, temporary files, and unnecessary artifacts
128
- **Maintenance**: Keep only necessary version artifacts
129
- **Optimization**: Reduce storage costs and improve pipeline performance
130
-
131
- **Example implementation**:
132
- ```yaml
133
- cleanup:
134
- stage: clean
135
- script:
136
- - docker image prune -f
137
- - rm -rf /tmp/build-artifacts
138
- when: always
139
- ```
140
-
141
- ## Key Benefits
142
-
143
- ### Version Consistency
144
- - **Single Source of Truth**: All environments run identical versions
145
- - **No Environment Drift**: Staging and production are always in sync
146
- - **Predictable Deployments**: Every deployment uses a well-identified version
147
-
148
- ### Simplified Operations
149
- - **Clear Version Tracking**: Easy to identify what's running where
150
- - **Simple Rollbacks**: Rollback to any previous version with confidence
151
- - **Reduced Complexity**: No need to manage multiple deployment branches
152
-
153
- ### Enhanced Reliability
154
- - **Auditable Deployments**: Every deployment is tied to a specific version
155
- - **Consistent Testing**: Tests validate the exact version that will be deployed
156
- - **Improved Security**: Version-based deployments provide clear audit trails
157
-
158
- ## Implementation Examples
159
-
160
- ### Basic Implementation
161
- ```yaml
162
- include:
163
- - local: templates/AgileFlow.gitlab-ci.yml
164
-
165
- build:
166
- stage: build
167
- script:
168
- - docker build -t myapp:${VERSION} .
169
- - docker push myapp:${VERSION}
170
- needs:
171
- - agileflow
172
-
173
- deploy:
174
- stage: deploy
175
- script:
176
- - kubectl set image deployment/myapp myapp=myapp:${VERSION}
177
- needs:
178
- - build
179
- ```
180
-
181
- ### Advanced Implementation with Multiple Services
182
- ```yaml
183
- include:
184
- - local: templates/AgileFlow.gitlab-ci.yml
185
-
186
- build-backend:
187
- stage: build
188
- script:
189
- - docker build -t backend:${VERSION} ./backend
190
- - docker push backend:${VERSION}
191
- needs:
192
- - agileflow
193
-
194
- build-frontend:
195
- stage: build
196
- script:
197
- - docker build -t frontend:${VERSION} ./frontend
198
- - docker push frontend:${VERSION}
199
- needs:
200
- - agileflow
201
-
202
- deploy-staging:
203
- stage: deploy
204
- script:
205
- - kubectl set image deployment/backend backend=backend:${VERSION}
206
- - kubectl set image deployment/frontend frontend=frontend:${VERSION}
207
- environment:
208
- name: staging
209
- needs:
210
- - build-backend
211
- - build-frontend
212
-
213
- deploy-production:
214
- stage: deploy
215
- script:
216
- - kubectl set image deployment/backend backend=backend:${VERSION}
217
- - kubectl set image deployment/frontend frontend=frontend:${VERSION}
218
- environment:
219
- name: production
220
- when: manual
221
- needs:
222
- - build-backend
223
- - build-frontend
224
- ```
225
-
226
- ## Best Practices
227
-
228
- ### 1. Always Use the VERSION Variable
229
- ```yaml
230
- # ✅ Good - Uses VERSION from AgileFlow
231
- - docker build -t myapp:${VERSION} .
232
-
233
- # ❌ Bad - Hardcoded or branch-based tagging
234
- - docker build -t myapp:latest .
235
- - docker build -t myapp:${CI_COMMIT_REF_SLUG} .
236
- ```
237
-
238
- ### 2. Proper Stage Dependencies
239
- ```yaml
240
- # ✅ Good - Clear dependency chain
241
- deploy:
242
- stage: deploy
243
- needs:
244
- - build
245
-
246
- # ❌ Bad - No dependencies specified
247
- deploy:
248
- stage: deploy
249
- ```
250
-
251
- ### 3. Environment-Specific Deployments
252
- ```yaml
253
- # ✅ Good - Same version, different environments
254
- deploy-staging:
255
- environment:
256
- name: staging
257
-
258
- deploy-production:
259
- environment:
260
- name: production
261
- when: manual
262
- ```
263
-
264
- ### 4. Consistent Testing
265
- ```yaml
266
- # ✅ Good - Test against deployed version
267
- test:
268
- stage: test
269
- script:
270
- - ./run-tests.sh --version ${VERSION}
271
- needs:
272
- - deploy-staging
273
- ```
274
-
275
- ## Troubleshooting
276
-
277
- ### Common Issues
278
-
279
- **VERSION variable not available**
280
- - Ensure the `agileflow` job completed successfully
281
- - Check that the dotenv artifact is properly configured
282
- - Verify the job dependencies are set correctly
283
-
284
- **Build failures in later stages**
285
- - Check that the `VERSION` variable is being used correctly
286
- - Ensure all jobs have proper `needs` dependencies
287
- - Verify the artifact paths and variable names
288
-
289
- **Deployment inconsistencies**
290
- - Confirm that all deploy jobs use the same `${VERSION}` variable
291
- - Check that the same image tags are used across environments
292
- - Verify that the deployment scripts are identical
293
-
294
- ### Debug Commands
295
-
296
- ```yaml
297
- debug-version:
298
- stage: build
299
- script:
300
- - echo "VERSION: ${VERSION}"
301
- - echo "CI_COMMIT_REF_NAME: ${CI_COMMIT_REF_NAME}"
302
- - echo "CI_COMMIT_SHA: ${CI_COMMIT_SHA}"
303
- needs:
304
- - agileflow
305
- ```
306
-
307
- ## Migration from Traditional CI/CD
308
-
309
- If you're currently using a traditional branch-based approach:
310
-
311
- 1. **Include the template**: Add the include statement to your `.gitlab-ci.yml`
312
- 2. **Update build jobs**: Modify build scripts to use `${VERSION}` instead of branch names
313
- 3. **Consolidate deployments**: Deploy the same version to all environments
314
- 4. **Update testing**: Ensure tests run against the deployed version
315
- 5. **Remove branch logic**: Eliminate environment-specific branch handling
316
-
317
- ## Support
318
-
319
- For issues or questions about the GitLab CI template:
320
-
321
- - Check the [main documentation](../README.md)
322
- - Review the [version-centric CI/CD approach](./version-centric-cicd.md)
323
- - Open an issue in the project repository
324
- - Join community discussions
package/src/git-utils.js DELETED
@@ -1,57 +0,0 @@
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/local.js DELETED
@@ -1,17 +0,0 @@
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;
@@ -1,66 +0,0 @@
1
- # AgileFlow GitLab CI Template
2
- #
3
- # This template provides a simplified, version-centric CI/CD pipeline that focuses on
4
- # version management rather than environment-based deployments. The pipeline consists
5
- # of 6 stages that work together to create a streamlined release process.
6
- #
7
- # Key Benefits:
8
- # - Version-centric approach: All deployments, tests, and operations are performed
9
- # on well-identified versions rather than branch-based environments
10
- # - Simplified stages: Clear separation of concerns with minimal complexity
11
- # - Automated versioning: Integrates with AgileFlow to automatically generate
12
- # semantic versions based on commit history
13
- # - Consistent deployments: All environments use the same version artifacts
14
- #
15
- # Stages Overview:
16
- # 1. version - Generate semantic version and release notes
17
- # 2. test - Run tests against source code before building
18
- # 3. build - Build application artifacts and Docker images
19
- # 4. deploy - Deploy to various environments using the generated version
20
- # 5. e2e - Run end-to-end tests against deployed versions
21
- # 6. clean - Cleanup temporary resources and artifacts
22
- #
23
- # Usage:
24
- # Include this template in your .gitlab-ci.yml:
25
- # include:
26
- # - local: templates/AgileFlow.gitlab-ci.yml
27
- #
28
- # The agileflow job will automatically:
29
- # - Calculate the next semantic version based on commit history
30
- # - Generate comprehensive release notes from conventional commits
31
- # - Create and push version tags to the repository
32
- # - Make the VERSION variable available to subsequent stages
33
-
34
- stages:
35
- - version # Calculate the next semantic version based on commit history,
36
- # if there's a tag, it will use that as the version.
37
-
38
- # Although the version is available in the $VERSION variable in all scenarios,
39
- # the rest of the stages are recommended to run when there's a version tag pushed.
40
- # This way the deployment process is version-centric.
41
- - test # Run tests against source code before building.
42
- - build # Build the image, and push to the registry.
43
- - deploy # Automatically deploy to DEV, manual deploy to STG and to PROD.
44
- - e2e # Run end-to-end tests against the deployed version.
45
- - clean # Cleanup temporary resources and artifacts.
46
-
47
- # Example:
48
- # Run the job only when there's a version tag pushed. The version tags starts with v and semver.
49
- #
50
- # stage: build
51
- # rules:
52
- # - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/
53
-
54
- # Version Generation Stage
55
- # This stage uses the AgileFlow tool to automatically generate semantic versions
56
- # and release notes based on the main branch's commit history. The VERSION
57
- # variable is made available as an artifact for use in subsequent stages.
58
- agileflow:
59
- stage: version
60
- image: registry.logickernel.com/kernel/agileflow:0.9.0
61
- only:
62
- - main
63
- script:
64
- - agileflow gitlab-ci
65
- tags:
66
- - agileflow
@@ -1,64 +0,0 @@
1
- # AgileFlow GitLab CI Template
2
- #
3
- # This template provides a simplified, version-centric CI/CD pipeline that focuses on
4
- # version management rather than environment-based deployments. The pipeline consists
5
- # of 6 stages that work together to create a streamlined release process.
6
- #
7
- # Key Benefits:
8
- # - Version-centric approach: All deployments, tests, and operations are performed
9
- # on well-identified versions rather than branch-based environments
10
- # - Simplified stages: Clear separation of concerns with minimal complexity
11
- # - Automated versioning: Integrates with AgileFlow to automatically generate
12
- # semantic versions based on commit history
13
- # - Consistent deployments: All environments use the same version artifacts
14
- #
15
- # Stages Overview:
16
- # 1. version - Generate semantic version and release notes
17
- # 2. test - Run tests against source code before building
18
- # 3. build - Build application artifacts and Docker images
19
- # 4. deploy - Deploy to various environments using the generated version
20
- # 5. e2e - Run end-to-end tests against deployed versions
21
- # 6. clean - Cleanup temporary resources and artifacts
22
- #
23
- # Usage:
24
- # Include this template in your .gitlab-ci.yml:
25
- # include:
26
- # - local: templates/AgileFlow.gitlab-ci.yml
27
- #
28
- # The agileflow job will automatically:
29
- # - Calculate the next semantic version based on commit history
30
- # - Generate comprehensive release notes from conventional commits
31
- # - Create and push version tags to the repository
32
- # - Make the VERSION variable available to subsequent stages
33
-
34
- stages:
35
- - version # Calculate the next semantic version based on commit history,
36
- # if there's a tag, it will use that as the version.
37
-
38
- # Although the version is available in the $VERSION variable in all scenarios,
39
- # the rest of the stages are recommended to run when there's a version tag pushed.
40
- # This way the deployment process is version-centric.
41
- - test # Run tests against source code before building.
42
- - build # Build the image, and push to the registry.
43
- - deploy # Automatically deploy to DEV, manual deploy to STG and to PROD.
44
- - e2e # Run end-to-end tests against the deployed version.
45
- - clean # Cleanup temporary resources and artifacts.
46
-
47
- # Example:
48
- # Run the job only when there's a version tag pushed. The version tags starts with v and semver.
49
- #
50
- # stage: build
51
- # rules:
52
- # - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/
53
-
54
- # Version Generation Stage
55
- # This stage uses the AgileFlow tool to automatically generate semantic versions
56
- # and release notes based on the main branch's commit history. The VERSION
57
- # variable is made available as an artifact for use in subsequent stages.
58
- agileflow:
59
- stage: version
60
- image: registry.logickernel.com/kernel/agileflow:0.9.0
61
- only:
62
- - main
63
- script:
64
- - agileflow gitlab-ci