Skip to content

perf: consolidate git-cliff invocations behind a single install - #13

Merged
fiunchinho merged 1 commit into
mainfrom
consolidate-git-cliff-calls
Jun 3, 2026
Merged

perf: consolidate git-cliff invocations behind a single install#13
fiunchinho merged 1 commit into
mainfrom
consolidate-git-cliff-calls

Conversation

@fiunchinho

Copy link
Copy Markdown
Member

Summary

Replaces two orhun/git-cliff-action invocations with one install + one shell step. Saves ~5–8s per workflow run and removes a workaround for the action's flaky version output.

What changes

- - uses: orhun/git-cliff-action@SHA       # install + --bumped-version
- - uses: orhun/git-cliff-action@SHA       # install + --latest --strip all
+ - uses: giantswarm/install-binary-action@SHA   # install git-cliff once
+ - shell step:
+     git-cliff --bump --context > cliff-context.json   # ONE expensive call
+     jq -r '.[0].version' cliff-context.json           # extract version
+     git-cliff --from-context ... --output ...         # cheap render (no API)

Why this is correct

git-cliff --bump --context does all the expensive work — walks commits, queries the GitHub API per commit for PR lookups, emits a JSON context with everything baked in. --from-context then renders the configured template against that JSON with no further API calls and no git traversal. Local timing: 38ms.

Output is identical to the previous two-action flow because:

  • --bump uses the same bumped-version semantics as the old --bumped-version
  • The cached context already reflects what --latest would have seen after the tag push (both render the bumped release's commits)

Side benefits

  1. Removes the outputs.content trim hack. The previous flow read steps.cliff.outputs.content (the action's stdout capture) and trimmed whitespace, because the action's outputs.version was unreliable for --bumped-version (it parsed the wrong JSON field). Now we read the version straight from our own cliff-context.json via jq — no quirky action behavior to work around.
  2. Single source of truth. The same JSON drives both the bump decision and the rendered notes. Eliminates any risk of them diverging if cliff config or git state changes between the two action invocations.
  3. One less external action to trust/pin. install-binary-action is already in use elsewhere in the giantswarm fleet (e.g., for gitsemver).

Test plan

  • Verified locally: git-cliff --bump --context | jq '.[0].version' returns the correct bumped version; git-cliff --from-context ... --strip all renders the same body the old flow produced.
  • After squash-merge:
    • Workflow run completes faster (compare against the ~15s baseline of v1.4.0)
    • v1.5.0 (or whatever the bump produces, this is a perf: so no bump on its own — but the squash commit would be perf: ... (#13) which IS conventional and would bump per cliff.toml... wait, perf maps to Changed group but doesn't trigger a bump in git-cliff's default. So this PR might produce NO release. Worth noting.)

Heads-up about the bump: this is perf: which git-cliff's default bumper treats like docs/chore — no bump triggered. The merge of this PR may not produce a release. If you want to validate end-to-end, the next conventional fix: or feat: after this lands will validate everything.

Replaces two `orhun/git-cliff-action` invocations (one for --bumped-version,
one for --latest --strip all) with:
  1. One install step via giantswarm/install-binary-action
  2. One shell step that runs git-cliff twice: --bump --context to emit the
     JSON context (one set of GitHub API calls for PR lookups), then
     --from-context to render the body from that cached JSON (no API
     calls, no commit walk — ~40ms locally).

Savings per workflow run: avoids re-installing git-cliff (~1s × 2) and
re-doing the API PR-lookup pass (~3s × 2). Net ~5–8s shaved off a
~15-second run.

Side benefits:
- `steps.cliff.outputs.version` is now read straight from the JSON via
  `jq -r '.[0].version'`, which is what the older git-cliff-action's
  `version` output was trying (and silently failing) to do for
  --bumped-version. Removes the trim-content workaround we had to do in
  the decide step.
- Renders the body upfront (cheap) rather than only after the tag push.
  Result is identical because --bump uses the bumped version; the cached
  context already reflects what `--latest` would have seen post-push.

Local validation:
  $ git-cliff --bump --context > ctx.json
  $ jq -r '.[0].version' ctx.json
  v1.5.0
  $ time git-cliff --from-context ctx.json --strip all
  ... (rendered body) ...
  git-cliff --from-context  0.01s user 0.02s system 96% cpu  0.038 total
@fiunchinho fiunchinho self-assigned this Jun 3, 2026
@fiunchinho
fiunchinho merged commit 10dbc42 into main Jun 3, 2026
1 check passed
@fiunchinho
fiunchinho deleted the consolidate-git-cliff-calls branch June 3, 2026 13:44
fiunchinho added a commit that referenced this pull request Jun 3, 2026
Regression introduced in #13 (the consolidate-git-cliff-calls change).
The old workflow used `--latest --strip all` on the render step, where
`--latest` filtered the output to just the bumped release. When I
consolidated to `--bump --context` + `--from-context`, I kept
`--strip all` (whitespace handling) but dropped `--latest`, with the
result that the context JSON contained EVERY release since repo
inception and the render concatenated all of them into each new
release's notes body.

Symptom: v1.4.1 and v1.4.2 release pages have notes that include
v1.4.0, v1.3.2, v1.3.1, … all the way back to v1.0.0. v1.4.0 (created
before #13 landed) is clean.

Fix is a one-word addition: pass `--latest` alongside `--bump --context`
so the JSON only contains the bumped release. Render then has nothing
else to render. No need for --latest on the --from-context call (which
turns out to be ignored anyway — filtering has to happen at context
generation time).

Local verification: `git-cliff --latest --bump --context | jq 'length'`
returns 1 (one release in the JSON); rendering that JSON produces a body
with just the latest release's bullets + footer.

Cleanup of the already-broken v1.4.1 and v1.4.2 release bodies is a
separate, optional follow-up (gh release edit --notes-file).
fiunchinho added a commit that referenced this pull request Jun 3, 2026
…y bumps (#16)

PR #15's "fix" for the full-history regression was wrong. I added
`--latest` thinking it would filter the cliff context to just the bumped
release; what it actually does in combination with `--bump` is return
the latest EXISTING tag and silently drop the bump. Result: PR #15's
merge ran the workflow successfully but computed `next: v1.4.2` (the
existing tag), said "no releasable commits", and skipped tagging. We
never got the v1.4.3 release that should have validated #15 itself.

The right flag is `--unreleased --bump --context`:
  --unreleased : filter to commits not yet in any tag
  --bump       : compute the bumped version from those commits
  --context    : output as JSON

Together they produce a single-release JSON for just the bumped
version. Verified locally on a fresh clone at the PR #15 merge commit:
returns `v1.4.3` (correct), one element in the JSON, renders cleanly
with just the new release's bullets + Full Changelog footer.

Acknowledging: this is the second swing at the same regression
(originally introduced in #13, mis-fixed in #15). Lesson: end-to-end
local testing on a fresh clone with the real tag history would have
caught both issues immediately.
fiunchinho added a commit that referenced this pull request Jun 3, 2026
The header described a two-cliff-invocation design referencing
`auto-tag.yaml` (renamed to `auto-release.yaml`) and `--bumped-version`
(replaced by `--bump --context` + jq parsing). PR #13 consolidated the
two invocations into a single `--unreleased --bump --context` call that
emits JSON the workflow then re-renders with `--from-context`. The
comment never caught up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant