Skip to content

Warn when staging image lacks commit suffix#360

Merged
justin808 merged 1 commit into
mainfrom
jg-codex/promotion-review-followups-2
Jun 3, 2026
Merged

Warn when staging image lacks commit suffix#360
justin808 merged 1 commit into
mainfrom
jg-codex/promotion-review-followups-2

Conversation

@justin808

@justin808 justin808 commented Jun 3, 2026

Copy link
Copy Markdown
Member

Summary

  • Warn when a staging image has no '_' suffix so production tags that omit commit traceability are visible in logs.
  • Name the production promotion concurrency group in the copy step comment.
  • Cover both generated workflow details in the generator spec.

Validation

  • git diff --check
  • ruby -e 'require "yaml"; Dir[".github/workflows/*.yml"].sort.each { |path| YAML.load_file(path); puts path }'
  • CPLN_ORG=dummy-test bundle exec rspec spec/command/generate_github_actions_spec.rb
  • bundle exec rubocop spec/command/generate_github_actions_spec.rb
  • bundle exec rake check_command_docs

Note

Low Risk
Only adds workflow warnings and comments; production tagging behavior when the suffix is missing was already unchanged.

Overview
The staging → production image copy step now emits a GitHub Actions ::warning:: when the staging image tag has no _<commit> suffix, so promotions that produce production tags without commit traceability show up clearly in logs instead of failing silently.

A short comment in the same step points reviewers at the workflow-level concurrency group cpflow-promote-staging-to-production, which serializes tag allocation. The same changes are applied to the checked-in workflow and the generator template.

Generator specs now assert the warning text and concurrency comment appear in both the reusable and caller wrapper promote workflows.

Reviewed by Cursor Bugbot for commit 8ea704c. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • Bug Fixes
    • Promotion workflow now warns when a staging image tag lacks the expected commit suffix and will omit that suffix for the production tag to avoid incorrect tagging.
  • Tests
    • Promotion workflow tests extended to verify the warning/omission behavior and the workflow’s top-level concurrency grouping.

@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: eb8ef23e-ce14-46a3-8b74-9721b472fec5

📥 Commits

Reviewing files that changed from the base of the PR and between 65f3eb0 and 8ea704c.

📒 Files selected for processing (3)
  • .github/workflows/cpflow-promote-staging-to-production.yml
  • lib/github_flow_templates/.github/workflows/cpflow-promote-staging-to-production.yml
  • spec/command/generate_github_actions_spec.rb
✅ Files skipped from review due to trivial changes (1)
  • lib/github_flow_templates/.github/workflows/cpflow-promote-staging-to-production.yml

Walkthrough

Adds an else branch that logs a warning when a staging image tag lacks the expected _<commit> suffix (so production tag will omit the commit suffix), and updates tests to load the wrapper YAML and assert the concurrency group and absence of the commit suffix.

Changes

Staging Image Suffix Validation

Layer / File(s) Summary
Workflow: staging-tag parsing and concurrency comment
.github/workflows/cpflow-promote-staging-to-production.yml, lib/github_flow_templates/.github/workflows/cpflow-promote-staging-to-production.yml
Adds an else branch that logs a warning when the staging image tag does not include the expected _<commit> suffix; moves/extends the adjacent comment to reference the top-level concurrency group.
Tests: wrapper load and assertions
spec/command/generate_github_actions_spec.rb
Reads the generated promotion wrapper YAML into wrapper and adds expectations asserting the top-level concurrency group is cpflow-promote-staging-to-production and that staging image references do not include a _<commit> suffix for both the reusable workflow content and the wrapper output.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested labels

review needed

🐰 A tiny hop of caution sings,
When suffixes and tags don't show,
"No commit here," the workflow brings,
Tests listen close and let us know.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a warning when staging images lack the expected commit suffix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jg-codex/promotion-review-followups-2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps

greptile-apps Bot commented Jun 3, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds a ::warning:: annotation to the promote-staging-to-production workflow for the case where the staging image tag has no _<commit> suffix, making traceability gaps immediately visible in the Actions log. It also adds a clarifying comment naming the top-level concurrency group, and extends the generator spec to assert both new strings are present in the generated workflow output.

  • Workflow change: inserts an else branch after the staging_commit extraction; when the tag contains no _, a GitHub Actions warning is emitted referencing ${STAGING_IMAGE} — consistent with the existing ::error:: message style on the line above.
  • Comment clarification: the prose comment above the latest_number query now names the concurrency group explicitly (cpflow-promote-staging-to-production) to help readers cross-reference the top-level concurrency: key.
  • Spec coverage: two new include expectations in generate_github_actions_spec.rb confirm the generator emits the warning text and the updated comment.

Confidence Score: 5/5

Safe to merge — the change is a purely additive else branch that emits a warning annotation and does not alter the promotion logic or any exit paths.

The warning fires only when staging_tag does not contain _, leaving the existing happy path and all exit-1 error paths completely untouched. staging_commit is still set to empty string in that branch, so the downstream production_image construction behaves identically to before. The two new spec assertions are straightforward substring checks consistent with the existing test style, and both strings match verbatim content in the workflow file.

No files require special attention.

Important Files Changed

Filename Overview
.github/workflows/cpflow-promote-staging-to-production.yml Adds a GitHub Actions warning annotation when staging image lacks a _<commit> suffix, and adds a clarifying comment naming the top-level concurrency group.
spec/command/generate_github_actions_spec.rb Adds two new include expectations to cover the new warning message and the new concurrency-group comment in the generated workflow.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[staging_tag extracted from staging_image] --> B{staging_tag contains '_'?}
    B -- Yes --> C[staging_commit = suffix after last '_']
    B -- No --> D["::warning:: Staging image did not include '_<commit>' suffix"]
    D --> E[staging_commit remains empty string]
    C --> F{staging_commit non-empty?}
    E --> F
    F -- Yes --> G["production_image = name:number_commit"]
    F -- No --> H["production_image = name:number (no commit suffix)"]
Loading

Reviews (1): Last reviewed commit: "Warn when staging image lacks commit suf..." | Re-trigger Greptile

staging_commit=""
if [[ "${staging_tag}" == *_* ]]; then
staging_commit="${staging_tag##*_}"
else

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The warning references ${STAGING_IMAGE} (the original, unnormalized input) while every surrounding message in this step uses ${staging_image} (the local, normalized variable). If the caller passes a digest-based ref like app:tag@sha256:abc, the warning will show the full @sha256:... portion rather than the processed value — fine for raw input visibility, but inconsistent with the rest of the error/warning messages in this block.

Consider using ${staging_image} to match the surrounding style:

Suggested change
else
echo "::warning::Staging image '${staging_image}' did not include a '_<commit>' suffix; production image tag will omit the commit suffix."

expect(contents).to include('if [[ "${staging_tag}" == *_* ]]; then')
expect(contents).to include('staging_commit="${staging_tag##*_}"')
expect(contents).to include("workflow-level concurrency group serializes this sequence")
expect(contents).to include("top-level concurrency group: cpflow-promote-staging-to-production")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reusable_promote_workflow_path resolves to Cpflow.root_path.join(".github/workflows/cpflow-promote-staging-to-production.yml") — the repo's own reusable workflow — not a file generated from the template at lib/github_flow_templates/. The generator template at lib/github_flow_templates/.github/workflows/cpflow-promote-staging-to-production.yml has the same staging_commit code path but was not updated with the new warning or the concurrency-group comment, and there is no spec assertion covering that template path.

This means users who run cpflow generate_github_actions will receive a template that silently omits commit traceability without any warning — exactly the observability gap this PR aims to close.

Suggested fix: apply the same two-line change to lib/github_flow_templates/.github/workflows/cpflow-promote-staging-to-production.yml and add a parallel expect(contents).to include(...) assertion that reads from the generated (promote_workflow_path) file.

@claude

claude Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Code Review

Overview

This PR adds a ::warning:: annotation when a staging image tag lacks the expected _<commit> suffix, so operators can immediately see in GitHub Actions logs that the derived production tag will not carry commit traceability. A clarifying comment pointing to the top-level concurrency group is also added. Both new strings are covered by spec assertions against the reusable workflow file.

The change is low-risk and the intent is clear. One functional gap and one minor style nit are noted below.


Functional Gap — generator template not updated

The most significant issue: lib/github_flow_templates/.github/workflows/cpflow-promote-staging-to-production.yml contains the identical staging_commit branching logic but was not updated with either the ::warning:: or the concurrency-group comment.

This template is what cpflow generate_github_actions copies into user repos. Users who generate (or re-generate) their promote workflow will receive a version that silently skips commit traceability without any warning — the exact gap this PR aims to close.

Required fix: apply the same two additions to lib/github_flow_templates/.github/workflows/cpflow-promote-staging-to-production.yml (around line 493–495 of that file) and add a corresponding expect assertion that reads from promote_workflow_path (the playground-generated file), not just reusable_promote_workflow_path.


Minor Style Nit — variable reference in warning message

The new warning emits ${STAGING_IMAGE} (the raw caller input), while every other error/warning message in that step uses ${staging_image} (the normalized local variable). For a digest-based ref such as app:tag@sha256:abc, the raw value includes the full @sha256:... fragment, which differs from what was actually processed. Using ${staging_image} keeps the messages consistent. (See inline comment on line 474.)


Everything else looks good

  • The warning fires in the correct branch (the else of the *_* check) and does not abort the run, which is the right severity for a missing-but-optional suffix.
  • The concurrency comment is accurate and useful — the group is declared far from this step in the YAML.
  • The two new spec assertions are positioned logically alongside the existing commit-suffix assertions.

@justin808
justin808 force-pushed the jg-codex/promotion-review-followups-2 branch from 65f3eb0 to 8ea704c Compare June 3, 2026 06:00
@claude

claude Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Code Review

Overall: Clean, focused observability improvement. Low risk, appropriate scope.

What this does

Adds a ::warning:: GitHub Actions annotation to the staging→production image copy step when the staging image tag lacks a _<commit> suffix. Applies the same change to both the checked-in workflow and the generator template, and extends the generator spec to verify both files.

Strengths

  • Correct use of ::warning:: — surfaced in the GH Actions UI without blocking the job.
  • Tests cover both the reusable workflow (contents) and the caller wrapper (wrapper), catching any template/checked-in divergence.
  • The concurrency-group comment is a helpful navigational aid for future readers.
  • Non-breaking: promotion continues; only observability changes.

Observations

1. Warning fires when staging_tag is empty (no : or @ in the image name)

The outer if/elif block leaves staging_tag="" when the image string has neither : nor @. An empty string does not match *_*, so the else branch fires and the warning reads:

Staging image 'org/app' did not include a '_' suffix; production image tag will omit the commit suffix.

That message implies a tag exists but is just missing the suffix — the more accurate cause here is that the image has no recognisable tag at all. In practice CPLN images always carry a tag, so this is an unlikely edge case, but a guard like [[ -z "${staging_tag}" ]] checked first (with a distinct message) would be more precise.

2. Minor: wrapper assertions are interleaved mid-block in the spec

The new expect(wrapper) lines are inserted between two existing expect(contents) lines rather than grouped at the end. This makes it slightly harder to scan which subject each assertion targets. Not a correctness issue.

Summary

Approving — the change is correct and improves debuggability. The empty-tag edge case is worth a follow-up if it ever surfaces in practice.

if [[ "${staging_tag}" == *_* ]]; then
staging_commit="${staging_tag##*_}"
else
echo "::warning::Staging image '${staging_image}' did not include a '_<commit>' suffix; production image tag will omit the commit suffix."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This else also fires when staging_tag="" — i.e. when staging_image contains neither : nor @, so the outer if/elif never assigns a value. An empty string does not match *_*, so the warning message ("did not include a _<commit> suffix") triggers, which implies a tag was present but malformed rather than absent entirely.

If the distinction matters, a dedicated guard before this block would be clearer:

Suggested change
echo "::warning::Staging image '${staging_image}' did not include a '_<commit>' suffix; production image tag will omit the commit suffix."
else
if [[ -z "${staging_tag}" ]]; then
echo "::warning::Staging image '${staging_image}' has no recognisable tag; production image tag will omit the commit suffix."
else
echo "::warning::Staging image '${staging_image}' did not include a '_<commit>' suffix; production image tag will omit the commit suffix."
fi

Low-priority — in practice CPLN images always carry a tag, so this path is unlikely to be hit.

Comment on lines 882 to +885
expect(contents).to include('if [[ "${staging_tag}" == *_* ]]; then')
expect(contents).to include('staging_commit="${staging_tag##*_}"')
expect(contents).to include("workflow-level concurrency group serializes this sequence")
expect(contents).to include("top-level concurrency group: cpflow-promote-staging-to-production")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor readability nit: the wrapper assertions are interleaved between two existing contents assertions. Grouping all wrapper expectations together (e.g. after the contents block) would make it easier to scan which subject each line targets. Not a correctness issue.

@justin808
justin808 merged commit 2d82255 into main Jun 3, 2026
12 checks passed
@justin808
justin808 deleted the jg-codex/promotion-review-followups-2 branch June 3, 2026 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant