Wire MR-skip outcome into runPipeline #256
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
Make
runPipeline(src/orchestrator/services/runPipeline.ts) branch on the newRunMrStageResult.skippeddiscriminant: skip write-back entirely and return a dedicated "nothing to ship" summary when the MR stage skipped, leaving the normal path unchanged otherwise.Background
Depends on: Wire "nothing to ship" skip into runMrStage
runMrStagenow returns a discriminated union ({ skipped: true, reason: 'no-changes', resultPath }or{ skipped: false, resultPath, result, degraded }) instead of a single shape.runPipelinecurrently callsrunMrand immediately assumes the old single shape — it destructuresmrResult.resultunconditionally, then always runscloseIssueAfterAutoMerge,computeWritebackOutcome, andrunWritebackNonFatal.This step teaches
runPipelineto checkmrResult.skippedand take a different path when it'strue: no write-back (there's no MR URL to comment with — mirrors exactly how the existingnoCodeChangeupfront-skip path in this same file already skips write-back for the same reason), and a dedicated summary via a newbuildMrSkippedSummaryhelper (modeled directly on the existingbuildNoCodeChangeSummaryfunction already in this file).There is also a resume fallthrough path to handle:
runPipelinehas ashouldSkipStage('mr', resumeFromStage)branch (used when resuming a run that already completed its MR stage in a prior attempt) that currently readsmr-result.jsonviareadMrResult(runDir). This must be updated to also recognizemr-skipped.json— read it first viareadMrSkippedSignal, falling back toreadMrResult— so a resumed-and-already-skipped run reports the dedicated summary correctly instead of throwing whenmr-result.jsondoesn't exist on disk.Implementation Details
src/orchestrator/helpers/buildFinalSummary.ts(or a new adjacent helper file, whichever matches wherebuildNoCodeChangeSummary-equivalent logic best fits —buildNoCodeChangeSummaryitself currently lives directly inrunPipeline.ts, so placing the new helper alongside it in the same file is also acceptable and keeps the change localized) — add:src/orchestrator/services/runPipeline.ts— in the MR stage section (thecurrentStage = 'mr'block that currently doesconst mrResult = await runWithFixerRetry('mr', () => runMr(...))then unconditionally proceeds tocloseIssueAfterAutoMerge/computeWritebackOutcome/runWritebackNonFatal/buildFinalSummary):runMrresolves, branch onmrResult.skipped.true: push'mr'and'write-back'ontoskippedStages; skipcloseIssueAfterAutoMerge,computeWritebackOutcome, andrunWritebackNonFatalentirely; recompute the friction aggregate the same way the normal path does (recomputeFrictionAggregate()); build the summary viabuildMrSkippedSummary(context.key, artifact, frictionAggregate)(read the artifact viareadMrSkippedSignal(runDir)sincemrResultin the skip branch only carriesresultPath, not the parsed artifact — or thread the artifact through fromrunMrStageif that's cleaner; either is fine as long as the summary gets a realMrSkippedArtifact); callemitPipelineFinish()as the normal path does; return the pipeline's success result shape with the mr-skipped variant (see the type change below).false: existing behavior, completely unchanged — narrow tomrResult.result/mrResult.resultPathexactly as today's code already does (this is now just an explicit type-narrow rather than an implicit assumption).shouldSkipStage('mr', resumeFromStage)branch): change it to tryreadMrSkippedSignal(runDir)first; if that returns a value, build and return the mr-skipped summary/result the same way as the fresh-run skip path; otherwise fall back to the existingreadMrResult(runDir)-based behavior.src/orchestrator/types/orchestrator.ts— add a new success-variant to whateverRunPipelineResult-shaped return type this file/module defines (search for where the existingnoCodeChangevariant is defined, since this should be modeled the same way — e.g. a discriminated union member carryingmrSkipped: MrSkippedArtifactfor downstream batch/manifest consumption, added in "Add mr-skipped outcome to batch mode" below).Acceptance Criteria
runMrreturns{ skipped: true, ... },runPipelinenever callscloseIssueAfterAutoMerge,computeWritebackOutcome, orrunWritebackNonFatal.skippedStagesincludes both'mr'and'write-back'on the skip path.buildMrSkippedSummary's output shape (three lines: completion line, "no changes to ship" line, friction line).mrSkipped: MrSkippedArtifactfield or discriminant) that a caller (batch mode) can detect.shouldSkipStage('mr', ...)branch) checksmr-skipped.jsonfirst viareadMrSkippedSignal, and only falls back toreadMrResultif that returnsundefined.skipped: falseshape and continue to pass with no behavior change.npm run buildandnpm run lintpass with no new errors/warnings.Test Plan
Extend
src/orchestrator/services/runPipeline.test.ts(or the equivalent existing suite):runMrreturning{ skipped: true, reason: 'no-changes', resultPath }→ verify write-back functions are never invoked,skippedStagescontains'mr'and'write-back', the summary text matchesbuildMrSkippedSummary's shape, and the result carries the mr-skipped variant.mr-skipped.jsonexists on disk andresumeFromStagecauses the MR stage to be skipped-on-resume → verify the fallthrough readsmr-skipped.json(notmr-result.json) and produces the same dedicated summary as the fresh-run skip path.skipped: falseand otherwise pass unchanged.Run
npm test -- runPipelineto confirm the updated/new suite passes, thennpm testfor the full suite to confirm no regressions.pi-loop opened and merged a pull request for this issue: #263