Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(cli): auto-enrich release descriptions with CI metadata#42

Merged
Monoradioactivo merged 1 commit into
mainfrom
feat/cli-ci-metadata-enrich
May 28, 2026
Merged

feat(cli): auto-enrich release descriptions with CI metadata#42
Monoradioactivo merged 1 commit into
mainfrom
feat/cli-ci-metadata-enrich

Conversation

@Monoradioactivo

Copy link
Copy Markdown
Owner

Summary

Phase 4 of the CLI headless epic, the last in the 6A-5(d) headless chain. Auto-enriches release, promote, and patch descriptions with CI metadata when running inside a supported provider.

Detection runs off provider-specific env vars in priority order: GITHUB_ACTIONS, then GITLAB_CI, then CIRCLECI, then JENKINS_URL. The universal CI=true (used by Phase 2 for non-interactive auto-detect) is intentionally not a trigger here, so generic runners like act keep their current behavior.

The bracket format is [ci=<provider> sha=<short> branch=<branch> pr=<n> run=<url>], with empty fields dropped. PR numbers use pr= uniformly across providers, including GitLab MRs, for grep ergonomics in the dashboard.

Three behaviors for the description field:

  • User passed --description "Fix auth": the bracket is appended after a blank line. Result: Fix auth\n\n[ci=...]. User text is never mutated.
  • User passed nothing: the bracket becomes the description.
  • User passed --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. Since releaseReact and release share the same command object reference, one call covers both.

A new module at script/utils/ci-metadata.ts houses the detection table, formatter, and enricher. It is pure, env-driven, and has no side effects beyond the optional mutation of command.description.

Tests

Unit suite at __tests__/utils/ci-metadata.test.ts covers 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.ts set GITHUB_ACTIONS and assert mockSdkMethods.promote/patchRelease receive the enriched description on the packageInfo. The harness now neutralizes the full provider env surface (23 vars) in beforeEach and restores in afterEach, 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 the env.X || undefined short-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

  • feat
  • fix
  • refactor
  • chore
  • docs

Checklist

  • Build and typecheck pass locally (npm run build)
  • Tests added or updated (when test infrastructure is wired up)
  • Relevant docs updated

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.
@Monoradioactivo Monoradioactivo self-assigned this May 28, 2026
@Monoradioactivo Monoradioactivo added the enhancement New feature or request label May 28, 2026
@Monoradioactivo Monoradioactivo merged commit 41d4d19 into main May 28, 2026
7 checks passed
@Monoradioactivo Monoradioactivo deleted the feat/cli-ci-metadata-enrich branch May 28, 2026 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant