Add mr-skipped outcome to batch mode #259
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Teach pi-loop's batch mode (
src/batch/) to represent and handle the new mr-skipped pipeline outcome as a successful, non-blocking result — batch continuation must not stop or treat "nothing to ship" as a failure.Background
Depends on: Wire MR-skip outcome into runPipeline
Batch mode processes multiple issues serially in one invocation (
npm start -- ISSUE-A ISSUE-B --auto-merge, or--scan --auto-merge). It already has an established pattern for a similar "not a normal MR" outcome:NoCodeChangeOutcomeinsrc/batch/services/batchManifest.ts, detected inbuildBatchOutcomesvia a'noCodeChange' in result.pipelineResultcheck, and handled specially insrc/batch/services/runBatch.ts(skipsrefreshMainAfterMerge, logs a distinct status line, still counts ascompleted).This step adds the parallel
mr-skippedoutcome, mirroring that exact pattern, using the pipeline-result discriminant added in the "Wire MR-skip outcome into runPipeline" step.Implementation Details
src/batch/services/batchManifest.ts:MrSkippedOutcometo theBatchIssueOutcomeunion (alongside the existing'completed',NoCodeChangeOutcome,'failed','skipped'members).validateBatchManifest'svalidateOutcomefunction, add a branch acceptingstatus === 'mr-skipped': validatereasonequals'no-changes'andrunDiris a non-empty string, mirroring the existing'no-code-change'branch's validation shape exactly.buildBatchOutcomes, add a branch (alongside the existingif ('noCodeChange' in result.pipelineResult)check) that detects the mr-skipped pipeline-result shape (from the earlierrunPipelinestep — check whatever discriminant/field name that step actually used, e.g.mrSkippedon the pipeline result) and emits{ status: 'mr-skipped', reason: 'no-changes', runDir: result.runDir ?? '' }.src/batch/services/runBatch.ts:refreshMainAfterMergegate (currentlyif (!('noCodeChange' in pipelineResult)) { ... await refreshMainAfterMerge(...) }) — extend the condition to also skip when the mr-skipped variant is present:if (!('noCodeChange' in pipelineResult) && !('mrSkipped' in pipelineResult))(adjust the exact property-existence check to match whatever discriminant therunPipelinestep actually produced — the point is: nomrResult.branch/targetBranchexists to check out, pull, or delete on the mr-skipped path, exactly as is already true fornoCodeChange).'noCodeChange' in pipelineResultblock (which logs something like a "no code changes" status line), logging a distinct line for this case, e.g.`Batch [${issueNumber}/${total}]: ✓ ${ref.provider}:${ref.key} (nothing to ship)`. Match the existing log-line format/style exactly (look at the currentnoCodeChangestatus line for the precise template).git.isClean+git.pullpreflight already handles pulling on an empty feature branch with no divergence correctly (this is an explicit non-change per the feature's design; do not add any extra checkout-to-target step for the mr-skipped case).Acceptance Criteria
validateBatchManifestaccepts a manifest containing an'mr-skipped'outcome entry with validreason/runDir, and rejects malformed variants (missingreason, wrongreasonvalue, missing/emptyrunDir) with descriptive errors.buildBatchOutcomesmaps aBatchIssueResultwhosepipelineResultcarries the mr-skipped shape to{ status: 'mr-skipped', reason: 'no-changes', runDir }.runBatchnever callsrefreshMainAfterMerge(or any of itscheckout/pull/deleteBranchgit-seam calls) for an mr-skipped issue.runBatchlogs a distinct, recognizable status line for the mr-skipped case (not the same text asnoCodeChangeorcompleted).completedfor batch purposes — it does not stop the batch and is not treated as a failure.noCodeChange/completed/failedbatch tests continue to pass unchanged.npm run buildandnpm run lintpass with no new errors/warnings.Test Plan
batchManifest.test.ts:validateBatchManifest— a manifest containing a well-formed'mr-skipped'outcome entry validates successfully; entries missingreasonorrunDir, or with the wrongreasonvalue, fail with descriptive errors.buildBatchOutcomes— aBatchIssueResultwhosepipelineResultcarries the mr-skipped shape maps to the new outcome variant with the correctrunDir.runBatch.test.ts:gitseam'scheckout/pull/deleteBranch(used byrefreshMainAfterMerge) are never called, the issue's outcome is recorded as completed (not failed), and the distinct mr-skipped status line is logged.Run
npm test -- batchManifest runBatchto confirm the updated/new suites pass, thennpm testfor the full suite to confirm no regressions.