feat(cli): auto-enrich release descriptions with CI metadata#42
Merged
Conversation
When running inside a supported CI provider (GitHub Actions, GitLab CI, CircleCI, Jenkins), release/promote/patch now annotate their description with a parseable metadata bracket: [ci=github sha=abc1234 branch=main pr=42 run=<url>]. A user-provided --description is preserved and the bracket is appended after a blank line; an empty description is replaced by the bracket alone. Detection runs in priority order (github > gitlab > circleci > jenkins) off provider-specific env vars, not the universal CI=true, so behavior in act and other generic runners stays unchanged. Pass --no-ci-metadata to opt out. Useful for local emulators or teams that generate release notes from another source.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 4 of the CLI headless epic, the last in the 6A-5(d) headless chain. Auto-enriches
release,promote, andpatchdescriptions with CI metadata when running inside a supported provider.Detection runs off provider-specific env vars in priority order:
GITHUB_ACTIONS, thenGITLAB_CI, thenCIRCLECI, thenJENKINS_URL. The universalCI=true(used by Phase 2 for non-interactive auto-detect) is intentionally not a trigger here, so generic runners likeactkeep their current behavior.The bracket format is
[ci=<provider> sha=<short> branch=<branch> pr=<n> run=<url>], with empty fields dropped. PR numbers usepr=uniformly across providers, including GitLab MRs, for grep ergonomics in the dashboard.Three behaviors for the description field:
--description "Fix auth": the bracket is appended after a blank line. Result:Fix auth\n\n[ci=...]. User text is never mutated.--no-ci-metadata, or no provider env is set: description is left alone.The hook lives in
execute()right after the non-interactive resolver, gated on the four CommandTypes that carry a description. SincereleaseReactandreleaseshare the same command object reference, one call covers both.A new module at
script/utils/ci-metadata.tshouses the detection table, formatter, and enricher. It is pure, env-driven, and has no side effects beyond the optional mutation ofcommand.description.Tests
Unit suite at
__tests__/utils/ci-metadata.test.tscovers every provider (full env, sparse env, no trigger), the priority order (GitHub wins over GitLab when both signals are set), formatter shape (full, sparse, provider-only), and the four enrichment paths (append, autogen, opt-out, no provider).Integration cases in
command-executor.test.tssetGITHUB_ACTIONSand assertmockSdkMethods.promote/patchReleasereceive the enriched description on the packageInfo. The harness now neutralizes the full provider env surface (23 vars) inbeforeEachand restores inafterEach, so the suite stays deterministic regardless of where it runs.Parser tests cover the three states of
--ci-metadata(absent,--ci-metadata,--no-ci-metadata).Coverage on
ci-metadata.ts: 100% statements/functions/lines, 85% branches. The uncovered branches are theenv.X || undefinedshort-circuits on the sparse paths of GitLab, CircleCI, and Jenkins, which mirror branches already tested for GitHub. Suite total at 384 tests, all passing.Type of change
Checklist
npm run build)