pipecraft 0.0.0-releaseit → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +126 -108
- package/dist/cli/index.d.ts +69 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +94 -22
- package/dist/cli/index.js.map +1 -1
- package/dist/generators/init.tpl.d.ts +70 -0
- package/dist/generators/init.tpl.d.ts.map +1 -1
- package/dist/generators/init.tpl.js +100 -8
- package/dist/generators/init.tpl.js.map +1 -1
- package/dist/generators/workflows.tpl.d.ts +86 -0
- package/dist/generators/workflows.tpl.d.ts.map +1 -1
- package/dist/generators/workflows.tpl.js +101 -9
- package/dist/generators/workflows.tpl.js.map +1 -1
- package/dist/templates/actions/calculate-version.yml.tpl.d.ts +47 -0
- package/dist/templates/actions/calculate-version.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/calculate-version.yml.tpl.js +72 -3
- package/dist/templates/actions/calculate-version.yml.tpl.js.map +1 -1
- package/dist/templates/actions/create-pr.yml.tpl.d.ts +14 -0
- package/dist/templates/actions/create-pr.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/create-pr.yml.tpl.js +22 -2
- package/dist/templates/actions/create-pr.yml.tpl.js.map +1 -1
- package/dist/templates/actions/create-release.yml.tpl.d.ts +18 -0
- package/dist/templates/actions/create-release.yml.tpl.d.ts.map +1 -0
- package/dist/templates/actions/create-release.yml.tpl.js +141 -0
- package/dist/templates/actions/create-release.yml.tpl.js.map +1 -0
- package/dist/templates/actions/create-tag.yml.tpl.d.ts +14 -0
- package/dist/templates/actions/create-tag.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/create-tag.yml.tpl.js +22 -2
- package/dist/templates/actions/create-tag.yml.tpl.js.map +1 -1
- package/dist/templates/actions/detect-changes.yml.tpl.d.ts +70 -0
- package/dist/templates/actions/detect-changes.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/detect-changes.yml.tpl.js +98 -2
- package/dist/templates/actions/detect-changes.yml.tpl.js.map +1 -1
- package/dist/templates/actions/manage-branch.yml.tpl.d.ts +14 -0
- package/dist/templates/actions/manage-branch.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/manage-branch.yml.tpl.js +22 -2
- package/dist/templates/actions/manage-branch.yml.tpl.js.map +1 -1
- package/dist/templates/actions/promote-branch.yml.tpl.d.ts +14 -0
- package/dist/templates/actions/promote-branch.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/promote-branch.yml.tpl.js +50 -7
- package/dist/templates/actions/promote-branch.yml.tpl.js.map +1 -1
- package/dist/templates/workflows/pipeline-path-based.yml.tpl.d.ts +114 -1
- package/dist/templates/workflows/pipeline-path-based.yml.tpl.d.ts.map +1 -1
- package/dist/templates/workflows/pipeline-path-based.yml.tpl.js +479 -74
- package/dist/templates/workflows/pipeline-path-based.yml.tpl.js.map +1 -1
- package/dist/types/index.d.ts +231 -8
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +9 -0
- package/dist/types/index.js.map +1 -1
- package/dist/utils/ast-path-operations.d.ts.map +1 -1
- package/dist/utils/ast-path-operations.js +24 -11
- package/dist/utils/ast-path-operations.js.map +1 -1
- package/dist/utils/config.d.ts +63 -0
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +71 -0
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/github-setup.d.ts +323 -2
- package/dist/utils/github-setup.d.ts.map +1 -1
- package/dist/utils/github-setup.js +551 -23
- package/dist/utils/github-setup.js.map +1 -1
- package/dist/utils/idempotency.d.ts +147 -7
- package/dist/utils/idempotency.d.ts.map +1 -1
- package/dist/utils/idempotency.js +143 -15
- package/dist/utils/idempotency.js.map +1 -1
- package/dist/utils/logger.d.ts +134 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +153 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/preflight.d.ts +223 -12
- package/dist/utils/preflight.d.ts.map +1 -1
- package/dist/utils/preflight.js +216 -16
- package/dist/utils/preflight.js.map +1 -1
- package/dist/utils/versioning.d.ts +160 -8
- package/dist/utils/versioning.d.ts.map +1 -1
- package/dist/utils/versioning.js +179 -15
- package/dist/utils/versioning.js.map +1 -1
- package/package.json +26 -5
- package/.claude/settings.local.json +0 -35
- package/.github/actions/calculate-version/action.yml +0 -106
- package/.github/actions/create-pr/action.yml +0 -122
- package/.github/actions/create-release/action.yml +0 -74
- package/.github/actions/create-tag/action.yml +0 -94
- package/.github/actions/detect-changes/action.yml +0 -62
- package/.github/actions/manage-branch/action.yml +0 -113
- package/.github/actions/promote-branch/action.yml +0 -352
- package/.github/example/workflows/job.analyze.code.yml +0 -26
- package/.github/example/workflows/job.analyze.docker.yml +0 -32
- package/.github/example/workflows/job.app.api.deploy.yml +0 -127
- package/.github/example/workflows/job.app.api.test.yml +0 -102
- package/.github/example/workflows/job.app.docs.deploy.yml +0 -40
- package/.github/example/workflows/job.app.docs.test.yml +0 -50
- package/.github/example/workflows/job.app.web.deploy.yml +0 -96
- package/.github/example/workflows/job.app.web.test.yml +0 -49
- package/.github/example/workflows/job.changes.yml +0 -82
- package/.github/example/workflows/job.create-pr.yml +0 -96
- package/.github/example/workflows/job.env-check.yml +0 -43
- package/.github/example/workflows/job.fast-forward.yml +0 -103
- package/.github/example/workflows/job.lint.yml +0 -64
- package/.github/example/workflows/job.pr-name.yml +0 -70
- package/.github/example/workflows/job.pr-squash-name.yml +0 -27
- package/.github/example/workflows/job.tag.yml +0 -38
- package/.github/example/workflows/job.version.yml +0 -99
- package/.github/example/workflows/lib.plugin-base.publish.yml +0 -59
- package/.github/example/workflows/pipe.yml +0 -178
- package/.github/example/workflows/scripts/fastforward.sh +0 -51
- package/.github/example/workflows/scripts/pipe-cleaner.sh +0 -70
- package/.github/scripts/fastforward.sh +0 -51
- package/.github/scripts/pipe-cleaner.sh +0 -70
- package/.github/workflows/pipeline.yml +0 -220
- package/.github/workflows/pr-title-check.yml +0 -70
- package/.github/workflows/publish.yml +0 -39
- package/.pipecraftrc.json +0 -78
- package/.release-it.cjs +0 -71
- package/PIPELINE_TESTING_PLAN.md +0 -499
- package/TRUNK_FLOW_PLAN.md +0 -401
- package/assets/logo_banner.png +0 -0
- package/assets/logo_banner.webp +0 -0
- package/docs/USER_JOURNEY_ERRORS.md +0 -352
- package/eslint.config.js +0 -77
- package/examples/basic-config.json +0 -41
- package/examples/monorepo-config.json +0 -49
- package/examples/usage.md +0 -289
- package/scripts/debug-workflows.sh +0 -339
- package/scripts/parse-pipeline.js +0 -29
- package/scripts/test-job-order.cjs +0 -140
- package/scripts/validate-pipeline.cjs +0 -379
- package/scripts/verify-job-order.sh +0 -30
- package/src/cli/index.ts +0 -414
- package/src/generators/init.tpl.ts +0 -126
- package/src/generators/workflows.tpl.ts +0 -80
- package/src/templates/actions/calculate-version.yml.tpl.ts +0 -124
- package/src/templates/actions/create-pr.yml.tpl.ts +0 -147
- package/src/templates/actions/create-tag.yml.tpl.ts +0 -112
- package/src/templates/actions/detect-changes.yml.tpl.ts +0 -87
- package/src/templates/actions/manage-branch.yml.tpl.ts +0 -132
- package/src/templates/actions/promote-branch.yml.tpl.ts +0 -364
- package/src/templates/workflows/pipeline-path-based.yml.tpl.ts +0 -706
- package/src/types/index.ts +0 -64
- package/src/utils/README-ast-path-operations.md +0 -390
- package/src/utils/ast-path-operations.ts +0 -581
- package/src/utils/config.ts +0 -64
- package/src/utils/github-setup.ts +0 -558
- package/src/utils/idempotency.ts +0 -215
- package/src/utils/preflight.ts +0 -306
- package/src/utils/versioning.ts +0 -244
- package/tests/README.md +0 -229
- package/tests/TEST_STRUCTURE.md +0 -256
- package/tests/act/run-act-tests.sh +0 -345
- package/tests/debugging/debug-utils.ts +0 -538
- package/tests/debugging/debug-workflow.test.ts +0 -339
- package/tests/debugging/debug-workflows.sh +0 -339
- package/tests/debugging/iterative-debug.ts +0 -652
- package/tests/debugging/run-debug-tests.sh +0 -431
- package/tests/fixtures/basic-config.json +0 -51
- package/tests/fixtures/invalid-config.json +0 -9
- package/tests/fixtures/pipeline-generated.yml +0 -235
- package/tests/fixtures/pipeline-preserve-comments.yml +0 -245
- package/tests/fixtures/pipeline-user-modified.yml +0 -245
- package/tests/fixtures/test-config.json +0 -58
- package/tests/github-live/README.md +0 -250
- package/tests/github-local/JOB_WORKFLOW_TESTS.md +0 -296
- package/tests/github-local/README.md +0 -240
- package/tests/github-local/run-all-tests.sh +0 -422
- package/tests/github-local/test-job-workflows.sh +0 -631
- package/tests/github-local/test-pipeline-workflow.sh +0 -440
- package/tests/integration/generators.test.ts +0 -578
- package/tests/integration/path-based-template.test.ts +0 -510
- package/tests/integration/simple-path-based.test.ts +0 -415
- package/tests/setup.ts +0 -56
- package/tests/unit/ast-path-operations-extended.test.ts +0 -302
- package/tests/unit/cli.test.ts +0 -541
- package/tests/unit/config-extended.test.ts +0 -412
- package/tests/unit/config.test.ts +0 -152
- package/tests/unit/github-setup.test.ts +0 -189
- package/tests/unit/idempotency-isolated.test.ts +0 -297
- package/tests/unit/job-order.test.ts +0 -157
- package/tests/unit/pipeline-path-based.test.ts +0 -511
- package/tests/unit/validate-pipeline.test.ts +0 -384
- package/tests/unit/versioning-extended.test.ts +0 -279
- package/tests/unit/versioning.test.ts +0 -241
- package/tsconfig.debug.json +0 -17
- package/tsconfig.json +0 -28
- package/vitest.config.ts +0 -51
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manage Branch Action Template
|
|
3
|
+
*
|
|
4
|
+
* Generates a composite action for branch operations including fast-forward merges,
|
|
5
|
+
* branch creation, and deletion. Core utility for trunk-based development workflows.
|
|
6
|
+
*
|
|
7
|
+
* @module templates/actions/manage-branch.yml.tpl
|
|
8
|
+
*/
|
|
1
9
|
import { PinionContext } from '@featherscloud/pinion';
|
|
10
|
+
/**
|
|
11
|
+
* Generator entry point for manage-branch composite action.
|
|
12
|
+
*
|
|
13
|
+
* @param {PinionContext} ctx - Pinion generator context
|
|
14
|
+
* @returns {Promise<PinionContext>} Updated context after file generation
|
|
15
|
+
*/
|
|
2
16
|
export declare const generate: (ctx: PinionContext) => Promise<any>;
|
|
3
17
|
//# sourceMappingURL=manage-branch.yml.tpl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manage-branch.yml.tpl.d.ts","sourceRoot":"","sources":["../../../src/templates/actions/manage-branch.yml.tpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA0B,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"manage-branch.yml.tpl.d.ts","sourceRoot":"","sources":["../../../src/templates/actions/manage-branch.yml.tpl.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAA0B,MAAM,uBAAuB,CAAA;AA+H7E;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,KAAK,aAAa,iBAUwD,CAAA"}
|
|
@@ -1,7 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manage Branch Action Template
|
|
3
|
+
*
|
|
4
|
+
* Generates a composite action for branch operations including fast-forward merges,
|
|
5
|
+
* branch creation, and deletion. Core utility for trunk-based development workflows.
|
|
6
|
+
*
|
|
7
|
+
* @module templates/actions/manage-branch.yml.tpl
|
|
8
|
+
*/
|
|
1
9
|
import { toFile, renderTemplate } from '@featherscloud/pinion';
|
|
2
10
|
import fs from 'fs';
|
|
3
11
|
import dedent from 'dedent';
|
|
4
|
-
|
|
12
|
+
import { logger } from '../../utils/logger.js';
|
|
13
|
+
/**
|
|
14
|
+
* Generates the manage-branch composite action YAML content.
|
|
15
|
+
*
|
|
16
|
+
* @param {any} ctx - Context (not currently used)
|
|
17
|
+
* @returns {string} YAML content for the composite action
|
|
18
|
+
*/
|
|
5
19
|
const branchActionTemplate = (ctx) => {
|
|
6
20
|
return dedent `name: 'Branch Management'
|
|
7
21
|
description: 'Manage branches (fast-forward, create, delete)'
|
|
@@ -117,13 +131,19 @@ const branchActionTemplate = (ctx) => {
|
|
|
117
131
|
echo "❌ \${{ steps.branch-action.outputs.message }}"
|
|
118
132
|
fi`;
|
|
119
133
|
};
|
|
134
|
+
/**
|
|
135
|
+
* Generator entry point for manage-branch composite action.
|
|
136
|
+
*
|
|
137
|
+
* @param {PinionContext} ctx - Pinion generator context
|
|
138
|
+
* @returns {Promise<PinionContext>} Updated context after file generation
|
|
139
|
+
*/
|
|
120
140
|
export const generate = (ctx) => Promise.resolve(ctx)
|
|
121
141
|
.then((ctx) => {
|
|
122
142
|
// Check if file exists to determine merge status
|
|
123
143
|
const filePath = '.github/actions/manage-branch/action.yml';
|
|
124
144
|
const exists = fs.existsSync(filePath);
|
|
125
145
|
const status = exists ? '🔄 Merged with existing' : '📝 Created new';
|
|
126
|
-
|
|
146
|
+
logger.verbose(`${status} ${filePath}`);
|
|
127
147
|
return ctx;
|
|
128
148
|
})
|
|
129
149
|
.then(renderTemplate(branchActionTemplate, toFile('.github/actions/manage-branch/action.yml')));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manage-branch.yml.tpl.js","sourceRoot":"","sources":["../../../src/templates/actions/manage-branch.yml.tpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,MAAM,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC7E,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,MAAM,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"manage-branch.yml.tpl.js","sourceRoot":"","sources":["../../../src/templates/actions/manage-branch.yml.tpl.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAiB,MAAM,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC7E,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAE9C;;;;;GAKG;AACH,MAAM,oBAAoB,GAAG,CAAC,GAAQ,EAAE,EAAE;IACxC,OAAO,MAAM,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAgHA,CAAA;AACf,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAkB,EAAE,EAAE,CAC7C,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC;KACjB,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;IACZ,iDAAiD;IACjD,MAAM,QAAQ,GAAG,0CAA0C,CAAA;IAC3D,MAAM,MAAM,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;IACtC,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,gBAAgB,CAAA;IACpE,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,IAAI,QAAQ,EAAE,CAAC,CAAA;IACvC,OAAO,GAAG,CAAA;AACZ,CAAC,CAAC;KACD,IAAI,CAAC,cAAc,CAAC,oBAAoB,EAAE,MAAM,CAAC,0CAA0C,CAAC,CAAC,CAAC,CAAA"}
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Promote Branch Action Template
|
|
3
|
+
*
|
|
4
|
+
* Generates a composite action that promotes code from one branch to another via
|
|
5
|
+
* temporary branch and pull request. Handles auto-merge and cleanup for trunk flow.
|
|
6
|
+
*
|
|
7
|
+
* @module templates/actions/promote-branch.yml.tpl
|
|
8
|
+
*/
|
|
1
9
|
import { PinionContext } from '@featherscloud/pinion';
|
|
10
|
+
/**
|
|
11
|
+
* Generator entry point for promote-branch composite action.
|
|
12
|
+
*
|
|
13
|
+
* @param {PinionContext} ctx - Pinion generator context
|
|
14
|
+
* @returns {Promise<PinionContext>} Updated context after file generation
|
|
15
|
+
*/
|
|
2
16
|
export declare const generate: (ctx: PinionContext) => Promise<any>;
|
|
3
17
|
//# sourceMappingURL=promote-branch.yml.tpl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promote-branch.yml.tpl.d.ts","sourceRoot":"","sources":["../../../src/templates/actions/promote-branch.yml.tpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA0B,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"promote-branch.yml.tpl.d.ts","sourceRoot":"","sources":["../../../src/templates/actions/promote-branch.yml.tpl.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAA0B,MAAM,uBAAuB,CAAA;AA8X7E;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,KAAK,aAAa,iBAUgE,CAAA"}
|
|
@@ -1,8 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Promote Branch Action Template
|
|
3
|
+
*
|
|
4
|
+
* Generates a composite action that promotes code from one branch to another via
|
|
5
|
+
* temporary branch and pull request. Handles auto-merge and cleanup for trunk flow.
|
|
6
|
+
*
|
|
7
|
+
* @module templates/actions/promote-branch.yml.tpl
|
|
8
|
+
*/
|
|
1
9
|
import { toFile, renderTemplate } from '@featherscloud/pinion';
|
|
2
10
|
import fs from 'fs';
|
|
3
11
|
import dedent from 'dedent';
|
|
4
|
-
|
|
5
|
-
|
|
12
|
+
import { logger } from '../../utils/logger.js';
|
|
13
|
+
/**
|
|
14
|
+
* Generates the promote-branch composite action YAML content.
|
|
15
|
+
*
|
|
16
|
+
* @param {any} ctx - Context (not currently used)
|
|
17
|
+
* @returns {string} YAML content for the composite action
|
|
18
|
+
*/
|
|
6
19
|
const promoteBranchActionTemplate = (ctx) => {
|
|
7
20
|
return dedent `name: 'Promote Branch'
|
|
8
21
|
description: 'Promote code from source to target branch via temporary branch + PR'
|
|
@@ -17,6 +30,10 @@ const promoteBranchActionTemplate = (ctx) => {
|
|
|
17
30
|
description: 'Version being promoted (e.g., v1.2.3, auto-detected from git tags if not provided)'
|
|
18
31
|
required: false
|
|
19
32
|
default: ''
|
|
33
|
+
run_number:
|
|
34
|
+
description: 'The original run number from develop branch for traceability'
|
|
35
|
+
required: false
|
|
36
|
+
default: ''
|
|
20
37
|
configPath:
|
|
21
38
|
description: 'Path to .pipecraftrc.json config file'
|
|
22
39
|
required: false
|
|
@@ -296,6 +313,14 @@ const promoteBranchActionTemplate = (ctx) => {
|
|
|
296
313
|
echo "✅ Fast-forwarded \$TARGET to \$COMMIT_SHA"
|
|
297
314
|
echo "📝 PR will be closed automatically for audit trail"
|
|
298
315
|
|
|
316
|
+
- name: Wait for Branch to Propagate
|
|
317
|
+
if: steps.read-config.outputs.autoMerge == 'true'
|
|
318
|
+
shell: bash
|
|
319
|
+
run: |
|
|
320
|
+
echo "⏳ Waiting 5 seconds for branch update to propagate..."
|
|
321
|
+
sleep 5
|
|
322
|
+
echo "✅ Branch should be fully propagated"
|
|
323
|
+
|
|
299
324
|
- name: Trigger Pipeline Workflow on Target Branch
|
|
300
325
|
if: steps.read-config.outputs.autoMerge == 'true'
|
|
301
326
|
shell: bash
|
|
@@ -304,15 +329,27 @@ const promoteBranchActionTemplate = (ctx) => {
|
|
|
304
329
|
run: |
|
|
305
330
|
TARGET="\${{ steps.read-config.outputs.targetBranch }}"
|
|
306
331
|
VERSION="\${{ steps.get-version.outputs.version }}"
|
|
332
|
+
RUN_NUMBER="\${{ inputs.run_number }}"
|
|
307
333
|
|
|
308
|
-
|
|
334
|
+
# Get the exact commit SHA that was just pushed to target branch
|
|
335
|
+
COMMIT_SHA=$(git rev-parse \$TARGET)
|
|
336
|
+
echo "🔄 Triggering pipeline workflow on \$TARGET branch"
|
|
337
|
+
echo " Version: \$VERSION"
|
|
338
|
+
echo " Commit SHA: \$COMMIT_SHA"
|
|
309
339
|
|
|
310
340
|
# Trigger the pipeline workflow on the target branch
|
|
311
341
|
# This is necessary because GITHUB_TOKEN pushes don't trigger workflows by default
|
|
312
|
-
# Pass the
|
|
313
|
-
|
|
342
|
+
# Pass the exact commit SHA to ensure the workflow checks out the correct commit
|
|
343
|
+
# (avoids race conditions from GitHub's eventual consistency)
|
|
344
|
+
WORKFLOW_ARGS=(--ref "\$TARGET" --field version="\$VERSION" --field commitSha="\$COMMIT_SHA")
|
|
345
|
+
if [ -n "\$RUN_NUMBER" ]; then
|
|
346
|
+
WORKFLOW_ARGS+=(--field run_number="\$RUN_NUMBER")
|
|
347
|
+
echo " Run number: \$RUN_NUMBER (for traceability)"
|
|
348
|
+
fi
|
|
349
|
+
|
|
350
|
+
gh workflow run pipeline.yml "\${WORKFLOW_ARGS[@]}"
|
|
314
351
|
|
|
315
|
-
echo "✅ Pipeline workflow triggered on \$TARGET with version \$VERSION"
|
|
352
|
+
echo "✅ Pipeline workflow triggered on \$TARGET with version \$VERSION at commit \$COMMIT_SHA"
|
|
316
353
|
|
|
317
354
|
- name: Close PR and Delete Branch
|
|
318
355
|
if: steps.read-config.outputs.autoMerge == 'true'
|
|
@@ -349,13 +386,19 @@ const promoteBranchActionTemplate = (ctx) => {
|
|
|
349
386
|
# Note: Fast-forward merge happens in separate step if autoMerge is enabled
|
|
350
387
|
`;
|
|
351
388
|
};
|
|
389
|
+
/**
|
|
390
|
+
* Generator entry point for promote-branch composite action.
|
|
391
|
+
*
|
|
392
|
+
* @param {PinionContext} ctx - Pinion generator context
|
|
393
|
+
* @returns {Promise<PinionContext>} Updated context after file generation
|
|
394
|
+
*/
|
|
352
395
|
export const generate = (ctx) => Promise.resolve(ctx)
|
|
353
396
|
.then((ctx) => {
|
|
354
397
|
// Check if file exists to determine merge status
|
|
355
398
|
const filePath = '.github/actions/promote-branch/action.yml';
|
|
356
399
|
const exists = fs.existsSync(filePath);
|
|
357
400
|
const status = exists ? '🔄 Merged with existing' : '📝 Created new';
|
|
358
|
-
|
|
401
|
+
logger.verbose(`${status} ${filePath}`);
|
|
359
402
|
return ctx;
|
|
360
403
|
})
|
|
361
404
|
.then(renderTemplate(promoteBranchActionTemplate, toFile('.github/actions/promote-branch/action.yml')));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promote-branch.yml.tpl.js","sourceRoot":"","sources":["../../../src/templates/actions/promote-branch.yml.tpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,MAAM,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC7E,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,MAAM,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"promote-branch.yml.tpl.js","sourceRoot":"","sources":["../../../src/templates/actions/promote-branch.yml.tpl.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAiB,MAAM,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC7E,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAE9C;;;;;GAKG;AACH,MAAM,2BAA2B,GAAG,CAAC,GAAQ,EAAE,EAAE;IAC/C,OAAO,MAAM,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+WZ,CAAA;AACH,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAkB,EAAE,EAAE,CAC7C,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC;KACjB,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;IACZ,iDAAiD;IACjD,MAAM,QAAQ,GAAG,2CAA2C,CAAA;IAC5D,MAAM,MAAM,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;IACtC,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,gBAAgB,CAAA;IACpE,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,IAAI,QAAQ,EAAE,CAAC,CAAA;IACvC,OAAO,GAAG,CAAA;AACZ,CAAC,CAAC;KACD,IAAI,CAAC,cAAc,CAAC,2BAA2B,EAAE,MAAM,CAAC,2CAA2C,CAAC,CAAC,CAAC,CAAA"}
|
|
@@ -1,3 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path-Based Pipeline Template Generator
|
|
3
|
+
*
|
|
4
|
+
* The core template that generates the main CI/CD pipeline workflow for PipeCraft.
|
|
5
|
+
* This is the most complex template in the system, responsible for creating a
|
|
6
|
+
* GitHub Actions workflow that orchestrates the entire trunk-based development flow.
|
|
7
|
+
*
|
|
8
|
+
* ## Key Responsibilities
|
|
9
|
+
*
|
|
10
|
+
* 1. **Change Detection**: Generates jobs to detect which domains (api, web, libs, etc.) changed
|
|
11
|
+
* 2. **Test Execution**: Creates domain-specific test jobs based on changes
|
|
12
|
+
* 3. **Version Management**: Integrates semantic versioning for staging/production branches
|
|
13
|
+
* 4. **Branch Promotion**: Auto-promotes code through branch flow (develop → staging → main)
|
|
14
|
+
* 5. **User Job Preservation**: Maintains user-added custom jobs during regeneration
|
|
15
|
+
* 6. **Comment Preservation**: Retains user comments when updating workflows
|
|
16
|
+
*
|
|
17
|
+
* ## Intelligent Merging
|
|
18
|
+
*
|
|
19
|
+
* The generator distinguishes between:
|
|
20
|
+
* - **Pipecraft-owned jobs**: `changes`, `version`, `tag`, `promote`, `release`, `test-*`, `deploy-*`
|
|
21
|
+
* - **User jobs**: Any jobs not owned by Pipecraft
|
|
22
|
+
*
|
|
23
|
+
* During regeneration:
|
|
24
|
+
* - Pipecraft jobs are completely replaced with template versions
|
|
25
|
+
* - User jobs are preserved exactly as-is
|
|
26
|
+
* - User comments are maintained
|
|
27
|
+
* - Job order is intelligently managed (Pipecraft jobs first, then user jobs)
|
|
28
|
+
*
|
|
29
|
+
* ## Architecture
|
|
30
|
+
*
|
|
31
|
+
* Uses AST-based path operations for surgical YAML manipulation:
|
|
32
|
+
* - Parse existing workflow into AST
|
|
33
|
+
* - Apply precise path-based operations
|
|
34
|
+
* - Preserve formatting and comments
|
|
35
|
+
* - Rebuild YAML maintaining structure
|
|
36
|
+
*
|
|
37
|
+
* @module templates/workflows/pipeline-path-based.yml.tpl
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* import { generate } from './templates/workflows/pipeline-path-based.yml.tpl.js'
|
|
42
|
+
*
|
|
43
|
+
* // Initial generation
|
|
44
|
+
* await generate({
|
|
45
|
+
* cwd: '/path/to/project',
|
|
46
|
+
* branchFlow: ['develop', 'staging', 'main'],
|
|
47
|
+
* domains: {
|
|
48
|
+
* api: { paths: ['src/api/**'], test: true },
|
|
49
|
+
* web: { paths: ['src/web/**'], test: true }
|
|
50
|
+
* }
|
|
51
|
+
* })
|
|
52
|
+
*
|
|
53
|
+
* // Incremental update (preserves user jobs)
|
|
54
|
+
* await generate({
|
|
55
|
+
* cwd: '/path/to/project',
|
|
56
|
+
* existingPipeline: parsedYAML,
|
|
57
|
+
* existingPipelineContent: rawYAMLString,
|
|
58
|
+
* branchFlow: ['develop', 'staging', 'main'],
|
|
59
|
+
* domains: { ... }
|
|
60
|
+
* })
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @see {@link module:utils/ast-path-operations} for YAML manipulation details
|
|
64
|
+
*/
|
|
1
65
|
import { PinionContext } from '@featherscloud/pinion';
|
|
2
66
|
/**
|
|
3
67
|
* Create path-based pipeline content
|
|
@@ -7,7 +71,56 @@ export declare const createPathBasedPipeline: (ctx: any) => {
|
|
|
7
71
|
mergeStatus: string;
|
|
8
72
|
};
|
|
9
73
|
/**
|
|
10
|
-
* Main
|
|
74
|
+
* Main pipeline generator entry point.
|
|
75
|
+
*
|
|
76
|
+
* Generates the complete GitHub Actions pipeline workflow with intelligent
|
|
77
|
+
* merging of existing user customizations.
|
|
78
|
+
*
|
|
79
|
+
* @param {PinionContext & { existingPipeline?: any, outputPipelinePath?: string }} ctx - Generator context
|
|
80
|
+
* @param {any} [ctx.existingPipeline] - Parsed existing pipeline YAML for merging
|
|
81
|
+
* @param {string} [ctx.existingPipelineContent] - Raw existing pipeline content for comment preservation
|
|
82
|
+
* @param {string} [ctx.outputPipelinePath] - Custom output path (default: .github/workflows/pipeline.yml)
|
|
83
|
+
* @param {string[]} ctx.branchFlow - Branch flow sequence (e.g., ['develop', 'staging', 'main'])
|
|
84
|
+
* @param {Record<string, DomainConfig>} ctx.domains - Domain configurations for change detection
|
|
85
|
+
* @param {string} [ctx.ciProvider] - CI provider ('github' or 'gitlab')
|
|
86
|
+
* @param {string} [ctx.mergeStrategy] - Merge strategy ('fast-forward' or 'merge')
|
|
87
|
+
* @returns {Promise<PinionContext>} Updated context with generated YAML
|
|
88
|
+
*
|
|
89
|
+
* @throws {Error} If pipeline file cannot be written
|
|
90
|
+
* @throws {Error} If existing pipeline cannot be parsed
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* // Generate new pipeline
|
|
95
|
+
* await generate({
|
|
96
|
+
* cwd: '/path/to/project',
|
|
97
|
+
* branchFlow: ['develop', 'main'],
|
|
98
|
+
* domains: {
|
|
99
|
+
* api: { paths: ['src/api/**'], test: true }
|
|
100
|
+
* }
|
|
101
|
+
* })
|
|
102
|
+
*
|
|
103
|
+
* // Update existing pipeline (preserves user jobs)
|
|
104
|
+
* const existing = parseDocument(readFileSync('pipeline.yml', 'utf8'))
|
|
105
|
+
* await generate({
|
|
106
|
+
* cwd: '/path/to/project',
|
|
107
|
+
* existingPipeline: existing,
|
|
108
|
+
* existingPipelineContent: readFileSync('pipeline.yml', 'utf8'),
|
|
109
|
+
* branchFlow: ['develop', 'staging', 'main'],
|
|
110
|
+
* domains: { ... }
|
|
111
|
+
* })
|
|
112
|
+
* ```
|
|
113
|
+
*
|
|
114
|
+
* @note The generator performs these steps:
|
|
115
|
+
* 1. Calls `createPathBasedPipeline()` to build the workflow
|
|
116
|
+
* 2. Logs merge status (new vs. merged)
|
|
117
|
+
* 3. Writes the final YAML to the output path
|
|
118
|
+
*
|
|
119
|
+
* The heavy lifting is done by `createPathBasedPipeline()` which handles:
|
|
120
|
+
* - Job generation based on domains and branch flow
|
|
121
|
+
* - User job preservation and merging
|
|
122
|
+
* - Comment preservation from existing pipeline
|
|
123
|
+
* - Intelligent job ordering
|
|
11
124
|
*/
|
|
12
125
|
export declare const generate: (ctx: PinionContext & {
|
|
13
126
|
existingPipeline?: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline-path-based.yml.tpl.d.ts","sourceRoot":"","sources":["../../../src/templates/workflows/pipeline-path-based.yml.tpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA0B,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"pipeline-path-based.yml.tpl.d.ts","sourceRoot":"","sources":["../../../src/templates/workflows/pipeline-path-based.yml.tpl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AAEH,OAAO,EAAE,aAAa,EAA0B,MAAM,uBAAuB,CAAA;AAsD7E;;GAEG;AACH,eAAO,MAAM,uBAAuB,GAAI,KAAK,GAAG;;;CAm5B/C,CAAA;AAcD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,eAAO,MAAM,QAAQ,GAAI,KAAK,aAAa,GAAG;IAAE,gBAAgB,CAAC,EAAE,GAAG,CAAC;IAAC,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAAE,iBAoB/F,CAAA"}
|