pipecraft 0.36.2 → 0.36.14
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 +30 -20
- package/dist/cli/index.js +4 -3
- package/dist/cli/index.js.map +1 -1
- package/dist/generators/init.tpl.d.ts.map +1 -1
- package/dist/generators/init.tpl.js +7 -128
- package/dist/generators/init.tpl.js.map +1 -1
- package/dist/generators/workflows.tpl.d.ts.map +1 -1
- package/dist/generators/workflows.tpl.js +3 -15
- package/dist/generators/workflows.tpl.js.map +1 -1
- package/dist/templates/actions/calculate-version.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/calculate-version.yml.tpl.js +38 -19
- package/dist/templates/actions/calculate-version.yml.tpl.js.map +1 -1
- package/dist/templates/actions/create-pr.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/create-pr.yml.tpl.js +9 -6
- package/dist/templates/actions/create-pr.yml.tpl.js.map +1 -1
- package/dist/templates/actions/create-release.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/create-release.yml.tpl.js +11 -9
- package/dist/templates/actions/create-release.yml.tpl.js.map +1 -1
- package/dist/templates/actions/create-tag.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/create-tag.yml.tpl.js +8 -7
- package/dist/templates/actions/create-tag.yml.tpl.js.map +1 -1
- package/dist/templates/actions/detect-changes.yml.tpl.d.ts +7 -13
- package/dist/templates/actions/detect-changes.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/detect-changes.yml.tpl.js +62 -215
- package/dist/templates/actions/detect-changes.yml.tpl.js.map +1 -1
- package/dist/templates/actions/manage-branch.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/manage-branch.yml.tpl.js +8 -7
- package/dist/templates/actions/manage-branch.yml.tpl.js.map +1 -1
- package/dist/templates/actions/promote-branch.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/promote-branch.yml.tpl.js +25 -29
- package/dist/templates/actions/promote-branch.yml.tpl.js.map +1 -1
- package/dist/templates/release-it.cjs.tpl.d.ts.map +1 -1
- package/dist/templates/release-it.cjs.tpl.js +14 -3
- package/dist/templates/release-it.cjs.tpl.js.map +1 -1
- package/dist/templates/workflows/pipeline.yml.tpl.d.ts.map +1 -1
- package/dist/templates/workflows/pipeline.yml.tpl.js +28 -48
- package/dist/templates/workflows/pipeline.yml.tpl.js.map +1 -1
- package/dist/templates/workflows/shared/index.d.ts +1 -0
- package/dist/templates/workflows/shared/index.d.ts.map +1 -1
- package/dist/templates/workflows/shared/index.js +1 -0
- package/dist/templates/workflows/shared/index.js.map +1 -1
- package/dist/templates/workflows/shared/managed-workflow.d.ts +32 -0
- package/dist/templates/workflows/shared/managed-workflow.d.ts.map +1 -0
- package/dist/templates/workflows/shared/managed-workflow.js +51 -0
- package/dist/templates/workflows/shared/managed-workflow.js.map +1 -0
- package/dist/templates/workflows/shared/operations-changes.d.ts +0 -1
- package/dist/templates/workflows/shared/operations-changes.d.ts.map +1 -1
- package/dist/templates/workflows/shared/operations-changes.js +1 -6
- package/dist/templates/workflows/shared/operations-changes.js.map +1 -1
- package/dist/templates/workflows/shared/operations-gate.d.ts +4 -30
- package/dist/templates/workflows/shared/operations-gate.d.ts.map +1 -1
- package/dist/templates/workflows/shared/operations-gate.js +110 -71
- package/dist/templates/workflows/shared/operations-gate.js.map +1 -1
- package/dist/templates/workflows/shared/operations-header.d.ts +10 -0
- package/dist/templates/workflows/shared/operations-header.d.ts.map +1 -1
- package/dist/templates/workflows/shared/operations-header.js +22 -3
- package/dist/templates/workflows/shared/operations-header.js.map +1 -1
- package/dist/templates/workflows/shared/operations-tag-promote.d.ts +1 -4
- package/dist/templates/workflows/shared/operations-tag-promote.d.ts.map +1 -1
- package/dist/templates/workflows/shared/operations-tag-promote.js +21 -17
- package/dist/templates/workflows/shared/operations-tag-promote.js.map +1 -1
- package/dist/templates/workflows/shared/operations-version.d.ts +0 -1
- package/dist/templates/workflows/shared/operations-version.d.ts.map +1 -1
- package/dist/templates/workflows/shared/operations-version.js +4 -11
- package/dist/templates/workflows/shared/operations-version.js.map +1 -1
- package/dist/templates/yaml-format-utils.d.ts.map +1 -1
- package/dist/templates/yaml-format-utils.js +1 -5
- package/dist/templates/yaml-format-utils.js.map +1 -1
- package/dist/types/index.d.ts +16 -57
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/action-reference.d.ts +1 -1
- package/dist/utils/action-reference.js +2 -2
- package/dist/utils/action-reference.js.map +1 -1
- package/dist/utils/config.d.ts +5 -0
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +36 -4
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/github-setup.d.ts +4 -4
- package/dist/utils/github-setup.js +28 -28
- package/dist/utils/github-setup.js.map +1 -1
- package/dist/utils/messaging.d.ts +2 -2
- package/dist/utils/messaging.d.ts.map +1 -1
- package/dist/utils/messaging.js +5 -5
- package/dist/utils/messaging.js.map +1 -1
- package/dist/utils/preflight.js +2 -2
- package/dist/utils/preflight.js.map +1 -1
- package/dist/utils/workflow-semantics.d.ts +61 -0
- package/dist/utils/workflow-semantics.d.ts.map +1 -0
- package/dist/utils/workflow-semantics.js +230 -0
- package/dist/utils/workflow-semantics.js.map +1 -0
- package/package.json +6 -5
- package/src/generators/init.tpl.ts +7 -132
- package/src/generators/workflows.tpl.ts +3 -15
- package/dist/templates/actions/run-nx-affected.yml.tpl.d.ts +0 -33
- package/dist/templates/actions/run-nx-affected.yml.tpl.d.ts.map +0 -1
- package/dist/templates/actions/run-nx-affected.yml.tpl.js +0 -346
- package/dist/templates/actions/run-nx-affected.yml.tpl.js.map +0 -1
- package/dist/templates/workflows/pipeline-nx.yml.tpl.d.ts +0 -22
- package/dist/templates/workflows/pipeline-nx.yml.tpl.d.ts.map +0 -1
- package/dist/templates/workflows/pipeline-nx.yml.tpl.js +0 -403
- package/dist/templates/workflows/pipeline-nx.yml.tpl.js.map +0 -1
|
@@ -52,11 +52,9 @@ import { generate as generateTagWorkflow } from '../templates/actions/create-tag
|
|
|
52
52
|
import { generate as generateChangesWorkflow } from '../templates/actions/detect-changes.yml.tpl.js'
|
|
53
53
|
import { generate as generateBranchWorkflow } from '../templates/actions/manage-branch.yml.tpl.js'
|
|
54
54
|
import { generate as generatePromoteBranchWorkflow } from '../templates/actions/promote-branch.yml.tpl.js'
|
|
55
|
-
import { generate as generateRunNxAffectedWorkflow } from '../templates/actions/run-nx-affected.yml.tpl.js'
|
|
56
55
|
import { generate as generateReleaseItConfig } from '../templates/release-it.cjs.tpl.js'
|
|
57
56
|
import { generate as generateEnforcePRTarget } from '../templates/workflows/enforce-pr-target.yml.tpl.js'
|
|
58
|
-
import { generate as
|
|
59
|
-
import { generate as generateNxPipeline } from '../templates/workflows/pipeline-nx.yml.tpl.js'
|
|
57
|
+
import { generate as generatePipeline } from '../templates/workflows/pipeline.yml.tpl.js'
|
|
60
58
|
import { generate as generatePRTitleCheck } from '../templates/workflows/pr-title-check.yml.tpl.js'
|
|
61
59
|
import { PipecraftConfig } from '../types/index.js'
|
|
62
60
|
import { logger } from '../utils/logger.js'
|
|
@@ -180,21 +178,11 @@ export const generate = (
|
|
|
180
178
|
generateReleaseItConfig(ctx)
|
|
181
179
|
]
|
|
182
180
|
|
|
183
|
-
// Add Nx-specific action if Nx is enabled
|
|
184
|
-
if (ctx.config?.nx?.enabled) {
|
|
185
|
-
generators.push(generateRunNxAffectedWorkflow(ctx))
|
|
186
|
-
}
|
|
187
|
-
|
|
188
181
|
return Promise.all(generators).then(() => ctx)
|
|
189
182
|
})
|
|
190
183
|
.then(ctx => {
|
|
191
|
-
// Generate the main pipeline (
|
|
192
|
-
|
|
193
|
-
logger.info('🔧 Generating Nx-optimized pipeline...')
|
|
194
|
-
return generateNxPipeline(ctx as any)
|
|
195
|
-
} else {
|
|
196
|
-
return generatePathBasedPipeline(ctx)
|
|
197
|
-
}
|
|
184
|
+
// Generate the main pipeline (path-based change detection)
|
|
185
|
+
return generatePipeline(ctx)
|
|
198
186
|
})
|
|
199
187
|
.then(ctx => {
|
|
200
188
|
// Generate the enforce PR target workflow
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Run Nx Affected Action Template
|
|
3
|
-
*
|
|
4
|
-
* Generates a reusable GitHub composite action that runs Nx affected commands
|
|
5
|
-
* with caching, reporting, and proper error handling.
|
|
6
|
-
*
|
|
7
|
-
* ## Purpose
|
|
8
|
-
*
|
|
9
|
-
* This action encapsulates all the complexity of running Nx affected tasks:
|
|
10
|
-
* - Sets up package manager caching (pnpm store)
|
|
11
|
-
* - Configures Nx workspace caching
|
|
12
|
-
* - Runs multiple Nx targets with proper comparison base
|
|
13
|
-
* - Reports results as PR comments
|
|
14
|
-
* - Handles failures gracefully with continue-on-error
|
|
15
|
-
*
|
|
16
|
-
* ## Generated Action Location
|
|
17
|
-
*
|
|
18
|
-
* `actions/run-nx-affected/action.yml`
|
|
19
|
-
*
|
|
20
|
-
* @module templates/actions/run-nx-affected.yml.tpl
|
|
21
|
-
*/
|
|
22
|
-
import { type PinionContext } from '@featherscloud/pinion';
|
|
23
|
-
import type { PipecraftConfig } from '../../types/index.js';
|
|
24
|
-
/**
|
|
25
|
-
* Generator entry point for run-nx-affected composite action.
|
|
26
|
-
*
|
|
27
|
-
* @param {PinionContext} ctx - Pinion generator context
|
|
28
|
-
* @returns {Promise<PinionContext>} Updated context after file generation
|
|
29
|
-
*/
|
|
30
|
-
export declare const generate: (ctx: PinionContext & {
|
|
31
|
-
config?: Partial<PipecraftConfig>;
|
|
32
|
-
}) => Promise<PinionContext>;
|
|
33
|
-
//# sourceMappingURL=run-nx-affected.yml.tpl.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-nx-affected.yml.tpl.d.ts","sourceRoot":"","sources":["../../../src/templates/actions/run-nx-affected.yml.tpl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,KAAK,aAAa,EAA0B,MAAM,uBAAuB,CAAA;AAIlF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAkT3D;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,KAAK,aAAa,GAAG;IAAE,MAAM,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAA;CAAE,2BAgB9E,CAAA"}
|
|
@@ -1,346 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Run Nx Affected Action Template
|
|
3
|
-
*
|
|
4
|
-
* Generates a reusable GitHub composite action that runs Nx affected commands
|
|
5
|
-
* with caching, reporting, and proper error handling.
|
|
6
|
-
*
|
|
7
|
-
* ## Purpose
|
|
8
|
-
*
|
|
9
|
-
* This action encapsulates all the complexity of running Nx affected tasks:
|
|
10
|
-
* - Sets up package manager caching (pnpm store)
|
|
11
|
-
* - Configures Nx workspace caching
|
|
12
|
-
* - Runs multiple Nx targets with proper comparison base
|
|
13
|
-
* - Reports results as PR comments
|
|
14
|
-
* - Handles failures gracefully with continue-on-error
|
|
15
|
-
*
|
|
16
|
-
* ## Generated Action Location
|
|
17
|
-
*
|
|
18
|
-
* `actions/run-nx-affected/action.yml`
|
|
19
|
-
*
|
|
20
|
-
* @module templates/actions/run-nx-affected.yml.tpl
|
|
21
|
-
*/
|
|
22
|
-
import { renderTemplate, toFile } from '@featherscloud/pinion';
|
|
23
|
-
import fs from 'fs';
|
|
24
|
-
import { logger } from '../../utils/logger.js';
|
|
25
|
-
import { getActionOutputDir } from '../../utils/action-reference.js';
|
|
26
|
-
/**
|
|
27
|
-
* Generates the run-nx-affected composite action YAML content.
|
|
28
|
-
*/
|
|
29
|
-
/* eslint-disable no-useless-escape */
|
|
30
|
-
function runNxAffectedActionTemplate(ctx) {
|
|
31
|
-
return `name: 'Run Nx Affected'
|
|
32
|
-
description: 'Runs Nx affected commands with caching and reporting'
|
|
33
|
-
|
|
34
|
-
inputs:
|
|
35
|
-
targets:
|
|
36
|
-
description: 'Comma-separated list of Nx targets to run (e.g., "lint,test,build")'
|
|
37
|
-
required: true
|
|
38
|
-
baseRef:
|
|
39
|
-
description: 'Base reference for comparison'
|
|
40
|
-
required: false
|
|
41
|
-
default: 'origin/main'
|
|
42
|
-
commitSha:
|
|
43
|
-
description: 'Commit SHA to test'
|
|
44
|
-
required: false
|
|
45
|
-
default: \${{ github.sha }}
|
|
46
|
-
packageManager:
|
|
47
|
-
description: 'Package manager to use (npm, pnpm, yarn)'
|
|
48
|
-
required: false
|
|
49
|
-
default: 'pnpm'
|
|
50
|
-
enableCache:
|
|
51
|
-
description: 'Enable caching for dependencies and Nx'
|
|
52
|
-
required: false
|
|
53
|
-
default: 'true'
|
|
54
|
-
reportResults:
|
|
55
|
-
description: 'Post results as PR comment (only works on pull_request events)'
|
|
56
|
-
required: false
|
|
57
|
-
default: 'true'
|
|
58
|
-
exclude:
|
|
59
|
-
description: 'Comma-separated list of Nx projects to exclude (e.g., "@mf/app1,@mf/lib2")'
|
|
60
|
-
required: false
|
|
61
|
-
default: ''
|
|
62
|
-
node-version:
|
|
63
|
-
description: 'Node.js version to use'
|
|
64
|
-
required: false
|
|
65
|
-
default: '20'
|
|
66
|
-
pnpm-version:
|
|
67
|
-
description: 'pnpm version to use'
|
|
68
|
-
required: false
|
|
69
|
-
default: '9'
|
|
70
|
-
verbose:
|
|
71
|
-
description: 'Enable verbose logging for debugging affected detection'
|
|
72
|
-
required: false
|
|
73
|
-
default: 'false'
|
|
74
|
-
|
|
75
|
-
runs:
|
|
76
|
-
using: composite
|
|
77
|
-
steps:
|
|
78
|
-
- name: Setup Node.js
|
|
79
|
-
uses: actions/setup-node@v4
|
|
80
|
-
with:
|
|
81
|
-
node-version: \${{ inputs.node-version }}
|
|
82
|
-
|
|
83
|
-
- name: Enable Corepack
|
|
84
|
-
if: inputs.packageManager == 'pnpm'
|
|
85
|
-
shell: bash
|
|
86
|
-
run: corepack enable
|
|
87
|
-
|
|
88
|
-
- name: Get pnpm store directory
|
|
89
|
-
if: inputs.packageManager == 'pnpm' && inputs.enableCache == 'true'
|
|
90
|
-
id: pnpm-cache
|
|
91
|
-
shell: bash
|
|
92
|
-
run: |
|
|
93
|
-
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
|
|
94
|
-
|
|
95
|
-
- name: Cache Package Manager
|
|
96
|
-
if: inputs.enableCache == 'true'
|
|
97
|
-
uses: actions/cache@v4
|
|
98
|
-
with:
|
|
99
|
-
path: \${{ inputs.packageManager == 'pnpm' && steps.pnpm-cache.outputs.STORE_PATH || '~/.npm' }}
|
|
100
|
-
key: \${{ inputs.packageManager }}-\${{ runner.os }}-\${{ hashFiles(inputs.packageManager == 'pnpm' && 'pnpm-lock.yaml' || inputs.packageManager == 'yarn' && 'yarn.lock' || 'package-lock.json') }}
|
|
101
|
-
restore-keys: |
|
|
102
|
-
\${{ inputs.packageManager }}-\${{ runner.os }}-
|
|
103
|
-
|
|
104
|
-
- name: Install Dependencies
|
|
105
|
-
shell: bash
|
|
106
|
-
run: |
|
|
107
|
-
case "\${{ inputs.packageManager }}" in
|
|
108
|
-
pnpm)
|
|
109
|
-
pnpm install --frozen-lockfile || pnpm install
|
|
110
|
-
;;
|
|
111
|
-
yarn)
|
|
112
|
-
yarn install --frozen-lockfile || yarn install
|
|
113
|
-
;;
|
|
114
|
-
npm)
|
|
115
|
-
npm ci || npm install
|
|
116
|
-
;;
|
|
117
|
-
*)
|
|
118
|
-
npm install
|
|
119
|
-
;;
|
|
120
|
-
esac
|
|
121
|
-
|
|
122
|
-
- name: Cache Nx
|
|
123
|
-
if: inputs.enableCache == 'true'
|
|
124
|
-
uses: actions/cache@v4
|
|
125
|
-
with:
|
|
126
|
-
path: .nx/cache
|
|
127
|
-
key: nx-\${{ runner.os }}-\${{ hashFiles(inputs.packageManager == 'pnpm' && 'pnpm-lock.yaml' || inputs.packageManager == 'yarn' && 'yarn.lock' || 'package-lock.json') }}-\${{ github.ref_name }}-\${{ github.run_number }}
|
|
128
|
-
restore-keys: |
|
|
129
|
-
nx-\${{ runner.os }}-\${{ hashFiles(inputs.packageManager == 'pnpm' && 'pnpm-lock.yaml' || inputs.packageManager == 'yarn' && 'yarn.lock' || 'package-lock.json') }}-\${{ github.ref_name }}-
|
|
130
|
-
nx-\${{ runner.os }}-\${{ hashFiles(inputs.packageManager == 'pnpm' && 'pnpm-lock.yaml' || inputs.packageManager == 'yarn' && 'yarn.lock' || 'package-lock.json') }}-
|
|
131
|
-
nx-\${{ runner.os }}-
|
|
132
|
-
|
|
133
|
-
- name: Show Nx Comparison Info
|
|
134
|
-
if: inputs.verbose == 'true'
|
|
135
|
-
shell: bash
|
|
136
|
-
run: |
|
|
137
|
-
echo "=========================================="
|
|
138
|
-
echo "🔍 Nx Affected Analysis Configuration"
|
|
139
|
-
echo "=========================================="
|
|
140
|
-
echo ""
|
|
141
|
-
echo "📌 Current HEAD:"
|
|
142
|
-
echo " Commit: \${{ inputs.commitSha }}"
|
|
143
|
-
git log -1 --oneline \${{ inputs.commitSha }} || echo " (commit details unavailable)"
|
|
144
|
-
echo ""
|
|
145
|
-
echo "📌 Base for comparison:"
|
|
146
|
-
BASE_REF="\${{ inputs.baseRef }}"
|
|
147
|
-
echo " Base ref: $BASE_REF"
|
|
148
|
-
git log -1 --oneline $BASE_REF || echo " (base ref details unavailable)"
|
|
149
|
-
echo ""
|
|
150
|
-
echo "📊 Commits being analyzed:"
|
|
151
|
-
git log --oneline $BASE_REF..\${{ inputs.commitSha }} || echo " (unable to show commit range)"
|
|
152
|
-
echo ""
|
|
153
|
-
echo "🎯 Targets to run: \${{ inputs.targets }}"
|
|
154
|
-
if [ -n "\${{ inputs.exclude }}" ]; then
|
|
155
|
-
echo "🚫 Excluding projects: \${{ inputs.exclude }}"
|
|
156
|
-
fi
|
|
157
|
-
echo "=========================================="
|
|
158
|
-
|
|
159
|
-
- name: Run Nx Affected Targets
|
|
160
|
-
id: nx-run
|
|
161
|
-
shell: bash
|
|
162
|
-
run: |
|
|
163
|
-
# Parse targets into array
|
|
164
|
-
IFS=',' read -ra TARGETS <<< "\${{ inputs.targets }}"
|
|
165
|
-
|
|
166
|
-
# Get the command prefix based on package manager
|
|
167
|
-
if [ "\${{ inputs.packageManager }}" = "pnpm" ]; then
|
|
168
|
-
NX_CMD="pnpm exec nx"
|
|
169
|
-
else
|
|
170
|
-
NX_CMD="npx nx"
|
|
171
|
-
fi
|
|
172
|
-
|
|
173
|
-
# Build exclude flag if provided (strip spaces for comma-separated list)
|
|
174
|
-
EXCLUDE_FLAG=""
|
|
175
|
-
if [ -n "\${{ inputs.exclude }}" ]; then
|
|
176
|
-
EXCLUDE_LIST=$(echo "\${{ inputs.exclude }}" | tr -d ' ')
|
|
177
|
-
EXCLUDE_FLAG="--exclude=$EXCLUDE_LIST"
|
|
178
|
-
fi
|
|
179
|
-
|
|
180
|
-
# Track overall success
|
|
181
|
-
OVERALL_SUCCESS=true
|
|
182
|
-
RESULTS_JSON="{"
|
|
183
|
-
FAILED_LOGS_JSON="{"
|
|
184
|
-
|
|
185
|
-
# Run each target
|
|
186
|
-
for target in "\${TARGETS[@]}"; do
|
|
187
|
-
# Trim whitespace
|
|
188
|
-
target=$(echo "$target" | xargs)
|
|
189
|
-
|
|
190
|
-
echo ""
|
|
191
|
-
echo "=========================================="
|
|
192
|
-
echo "🎯 Running target: $target"
|
|
193
|
-
echo "=========================================="
|
|
194
|
-
|
|
195
|
-
# Capture output to a temp file
|
|
196
|
-
LOG_FILE=$(mktemp)
|
|
197
|
-
|
|
198
|
-
# Run the target and capture result
|
|
199
|
-
if $NX_CMD affected --target=$target --base=\${{ inputs.baseRef }} --head=\${{ inputs.commitSha }} $EXCLUDE_FLAG 2>&1 | tee "$LOG_FILE"; then
|
|
200
|
-
echo "✅ $target passed"
|
|
201
|
-
RESULTS_JSON+="\"$target\":\"success\","
|
|
202
|
-
else
|
|
203
|
-
echo "❌ $target failed"
|
|
204
|
-
RESULTS_JSON+="\"$target\":\"failure\","
|
|
205
|
-
OVERALL_SUCCESS=false
|
|
206
|
-
|
|
207
|
-
# Extract and store the failure log (last 100 lines, strip ANSI codes, escape for JSON)
|
|
208
|
-
FAILURE_LOG=$(tail -n 100 "$LOG_FILE" | sed 's/\\x1b\\[[0-9;]*m//g' | sed 's/\\\\/\\\\\\\\/g' | sed 's/"/\\\\"/g' | sed ':a;N;$!ba;s/\\n/\\\\n/g')
|
|
209
|
-
FAILED_LOGS_JSON+="\"$target\":\"$FAILURE_LOG\","
|
|
210
|
-
fi
|
|
211
|
-
|
|
212
|
-
rm -f "$LOG_FILE"
|
|
213
|
-
done
|
|
214
|
-
|
|
215
|
-
# Close JSON and save to output
|
|
216
|
-
RESULTS_JSON="\${RESULTS_JSON%,}}"
|
|
217
|
-
echo "results=$RESULTS_JSON" >> $GITHUB_OUTPUT
|
|
218
|
-
|
|
219
|
-
FAILED_LOGS_JSON="\${FAILED_LOGS_JSON%,}}"
|
|
220
|
-
if [ "$FAILED_LOGS_JSON" != "{" ]; then
|
|
221
|
-
FAILED_LOGS_JSON+="}"
|
|
222
|
-
fi
|
|
223
|
-
# Use delimiter for multiline output
|
|
224
|
-
echo "failed_logs<<EOF" >> $GITHUB_OUTPUT
|
|
225
|
-
echo "$FAILED_LOGS_JSON" >> $GITHUB_OUTPUT
|
|
226
|
-
echo "EOF" >> $GITHUB_OUTPUT
|
|
227
|
-
|
|
228
|
-
# Set overall success
|
|
229
|
-
if [ "$OVERALL_SUCCESS" = "false" ]; then
|
|
230
|
-
echo "overall_success=false" >> $GITHUB_OUTPUT
|
|
231
|
-
exit 1
|
|
232
|
-
else
|
|
233
|
-
echo "overall_success=true" >> $GITHUB_OUTPUT
|
|
234
|
-
fi
|
|
235
|
-
|
|
236
|
-
- name: Report Results to PR
|
|
237
|
-
if: always() && inputs.reportResults == 'true' && github.event_name == 'pull_request'
|
|
238
|
-
uses: actions/github-script@v7
|
|
239
|
-
with:
|
|
240
|
-
script: |
|
|
241
|
-
const results = \${{ steps.nx-run.outputs.results || '{}' }};
|
|
242
|
-
const failedLogs = \${{ steps.nx-run.outputs.failed_logs || '{}' }};
|
|
243
|
-
const targets = '\${{ inputs.targets }}'.split(',').map(t => t.trim());
|
|
244
|
-
const exclude = '\${{ inputs.exclude }}';
|
|
245
|
-
|
|
246
|
-
let report = '## 🔍 Nx Affected Test Results\\n\\n';
|
|
247
|
-
let hasFailures = false;
|
|
248
|
-
const failedTargets = [];
|
|
249
|
-
|
|
250
|
-
for (const target of targets) {
|
|
251
|
-
const status = results[target];
|
|
252
|
-
if (status === 'failure') {
|
|
253
|
-
report += \`❌ **\${target}** - Failed\\n\`;
|
|
254
|
-
hasFailures = true;
|
|
255
|
-
failedTargets.push(target);
|
|
256
|
-
} else if (status === 'success') {
|
|
257
|
-
report += \`✅ **\${target}** - Passed\\n\`;
|
|
258
|
-
} else {
|
|
259
|
-
report += \`⚠️ **\${target}** - Unknown\\n\`;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// Add failure details with collapsible sections
|
|
264
|
-
if (failedTargets.length > 0) {
|
|
265
|
-
report += \`\\n### ❌ Failure Details\\n\\n\`;
|
|
266
|
-
|
|
267
|
-
for (const target of failedTargets) {
|
|
268
|
-
const log = failedLogs[target];
|
|
269
|
-
|
|
270
|
-
// Link to full logs for this specific target
|
|
271
|
-
report += \`#### \${target}\\n\`;
|
|
272
|
-
report += \`[View full logs for \${target}](\${context.serverUrl}/\${context.repo.owner}/\${context.repo.repo}/actions/runs/\${context.runId})\\n\\n\`;
|
|
273
|
-
|
|
274
|
-
// Collapsible section with error output
|
|
275
|
-
if (log) {
|
|
276
|
-
report += \`<details>\\n\`;
|
|
277
|
-
report += \`<summary>Show error output</summary>\\n\\n\`;
|
|
278
|
-
report += \`\\\`\\\`\\\`\\n\`;
|
|
279
|
-
report += log;
|
|
280
|
-
report += \`\\n\\\`\\\`\\\`\\n\`;
|
|
281
|
-
report += \`</details>\\n\\n\`;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
if (exclude) {
|
|
287
|
-
report += \`\\n### Excluded Projects\\n\`;
|
|
288
|
-
const excludedProjects = exclude.split(',').map(p => p.trim());
|
|
289
|
-
report += \`The following projects were skipped from the affected analysis:\\n\`;
|
|
290
|
-
excludedProjects.forEach(project => {
|
|
291
|
-
report += \`- \\\`\${project}\\\`\\n\`;
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
report += \`\\n---\\n[View full workflow run](\${context.serverUrl}/\${context.repo.owner}/\${context.repo.repo}/actions/runs/\${context.runId})\\n\`;
|
|
296
|
-
|
|
297
|
-
// Find existing comment
|
|
298
|
-
const { data: comments } = await github.rest.issues.listComments({
|
|
299
|
-
owner: context.repo.owner,
|
|
300
|
-
repo: context.repo.repo,
|
|
301
|
-
issue_number: context.issue.number,
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
const botComment = comments.find(comment =>
|
|
305
|
-
comment.user.type === 'Bot' &&
|
|
306
|
-
comment.body.includes('🔍 Nx Affected Test Results')
|
|
307
|
-
);
|
|
308
|
-
|
|
309
|
-
if (botComment) {
|
|
310
|
-
// Update existing comment
|
|
311
|
-
await github.rest.issues.updateComment({
|
|
312
|
-
owner: context.repo.owner,
|
|
313
|
-
repo: context.repo.repo,
|
|
314
|
-
comment_id: botComment.id,
|
|
315
|
-
body: report
|
|
316
|
-
});
|
|
317
|
-
} else {
|
|
318
|
-
// Create new comment
|
|
319
|
-
await github.rest.issues.createComment({
|
|
320
|
-
owner: context.repo.owner,
|
|
321
|
-
repo: context.repo.repo,
|
|
322
|
-
issue_number: context.issue.number,
|
|
323
|
-
body: report
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
`;
|
|
327
|
-
}
|
|
328
|
-
/* eslint-enable no-useless-escape */
|
|
329
|
-
/**
|
|
330
|
-
* Generator entry point for run-nx-affected composite action.
|
|
331
|
-
*
|
|
332
|
-
* @param {PinionContext} ctx - Pinion generator context
|
|
333
|
-
* @returns {Promise<PinionContext>} Updated context after file generation
|
|
334
|
-
*/
|
|
335
|
-
export const generate = (ctx) => Promise.resolve(ctx)
|
|
336
|
-
.then(ctx => {
|
|
337
|
-
const config = ctx.config || {};
|
|
338
|
-
const outputDir = getActionOutputDir(config);
|
|
339
|
-
const filePath = `${outputDir}/run-nx-affected/action.yml`;
|
|
340
|
-
const exists = fs.existsSync(filePath);
|
|
341
|
-
const status = exists ? '🔄 Merged with existing' : '📝 Created new';
|
|
342
|
-
logger.verbose(`${status} ${filePath}`);
|
|
343
|
-
return { ...ctx, actionOutputPath: filePath };
|
|
344
|
-
})
|
|
345
|
-
.then(ctx => renderTemplate(runNxAffectedActionTemplate, toFile(ctx.actionOutputPath || 'actions/run-nx-affected/action.yml'))(ctx));
|
|
346
|
-
//# sourceMappingURL=run-nx-affected.yml.tpl.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-nx-affected.yml.tpl.js","sourceRoot":"","sources":["../../../src/templates/actions/run-nx-affected.yml.tpl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAsB,cAAc,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAClF,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AAGpE;;GAEG;AACH,sCAAsC;AACtC,SAAS,2BAA2B,CAAC,GAAkB;IACrD,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuSR,CAAA;AACD,CAAC;AACD,qCAAqC;AAErC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAA0D,EAAE,EAAE,CACrF,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC;KACjB,IAAI,CAAC,GAAG,CAAC,EAAE;IACV,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,IAAI,EAAE,CAAA;IAC/B,MAAM,SAAS,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAA;IAC5C,MAAM,QAAQ,GAAG,GAAG,SAAS,6BAA6B,CAAA;IAC1D,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,EAAE,GAAG,GAAG,EAAE,gBAAgB,EAAE,QAAQ,EAAE,CAAA;AAC/C,CAAC,CAAC;KACD,IAAI,CAAC,GAAG,CAAC,EAAE,CACV,cAAc,CACZ,2BAA2B,EAC3B,MAAM,CAAC,GAAG,CAAC,gBAAgB,IAAI,oCAAoC,CAAC,CACrE,CAAC,GAAG,CAAC,CACP,CAAA"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Nx Pipeline Template
|
|
3
|
-
*
|
|
4
|
-
* Generates an Nx-optimized workflow that uses `nx affected` to intelligently test
|
|
5
|
-
* only changed projects. Runs all Nx tasks sequentially in a single job, leveraging
|
|
6
|
-
* Nx's built-in caching and parallel execution.
|
|
7
|
-
*
|
|
8
|
-
* This is Option 1 (Sequential Strategy) - simple, fast, and leverages Nx's intelligence.
|
|
9
|
-
*/
|
|
10
|
-
import { type PinionContext } from '@featherscloud/pinion';
|
|
11
|
-
import type { PipecraftConfig } from '../../types/index.js';
|
|
12
|
-
interface NxPipelineContext extends PinionContext {
|
|
13
|
-
config: PipecraftConfig;
|
|
14
|
-
branchFlow: string[];
|
|
15
|
-
outputPipelinePath?: string;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Main generator that handles merging with existing workflow
|
|
19
|
-
*/
|
|
20
|
-
export declare const generate: (ctx: NxPipelineContext) => Promise<any>;
|
|
21
|
-
export {};
|
|
22
|
-
//# sourceMappingURL=pipeline-nx.yml.tpl.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline-nx.yml.tpl.d.ts","sourceRoot":"","sources":["../../../src/templates/workflows/pipeline-nx.yml.tpl.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,KAAK,aAAa,EAA0B,MAAM,uBAAuB,CAAA;AAGlF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAoB3D,UAAU,iBAAkB,SAAQ,aAAa;IAC/C,MAAM,EAAE,eAAe,CAAA;IACvB,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B;AAgHD;;GAEG;AACH,eAAO,MAAM,QAAQ,GAAI,KAAK,iBAAiB,iBA2U1C,CAAA"}
|