Validate selected setup templates and review-app health#363
Conversation
|
Warning Review limit reached
Next review available in: 39 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
WalkthroughThis PR makes template selection depend on CLI args or configured setup templates, refactors image-variable replacement, and adds review-app health-check workflow wiring with matching docs and tests. ChangesTemplate selection and parsing
Review-app health checks
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5c0e1617b4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Code ReviewOverviewThis PR fixes a real bug: the duplicate-template validator was scanning every The change is well-scoped and the core logic is correct. A few findings below. Issues1. When 2.
3. Test coverage gap: deprecated The Minor / Positive Notes
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
spec/command/doctor_spec.rb (1)
36-77: ⚡ Quick winAdd explicit regression coverage for fallback-to-all template validation.
The updated tests now focus on selected-template behavior, but there’s no direct example asserting the fallback path when
setup_app_templatesis unset. Since that fallback is a stated objective, adding one case here would guard against regressions.Proposed spec addition
it "passes if selected templates have no issues" do result = run_cpflow_command("doctor", "--validations", "templates", "-a", app) expect(result[:status]).to eq(0) expect(result[:stderr]).to include("[PASS] templates") expect(result[:stderr]).not_to include("DEPRECATED") end + + it "falls back to validating all templates when setup_app_templates is not configured" do + app = dummy_test_app("nothing") + + result = run_cpflow_command("doctor", "--validations", "templates", "-a", app) + + expect(result[:status]).not_to eq(0) + expect(result[:stderr]).to include("[FAIL] templates") + expect(result[:stderr]).to include("- kind: gvc, name: #{app}") + end🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@spec/command/doctor_spec.rb` around lines 36 - 77, Add a regression spec that verifies the fallback-to-all template validation when setup_app_templates is unset: create a new example in the doctor_spec that uses run_cpflow_command("doctor", "--validations", "templates", "-a", app) (or without -a to emulate unset setup_app_templates) against a dummy_test_app that relies on the fallback (e.g., "default" or a new fixture) and assert the command exits with success or failure as expected and that stderr contains the fallback behavior markers (e.g., "[PASS] templates" or expected failure messages); specifically reference setup_app_templates being nil/unset and ensure the test checks that templates validation runs over all templates rather than only selected ones to guard the fallback path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@spec/command/doctor_spec.rb`:
- Around line 36-77: Add a regression spec that verifies the fallback-to-all
template validation when setup_app_templates is unset: create a new example in
the doctor_spec that uses run_cpflow_command("doctor", "--validations",
"templates", "-a", app) (or without -a to emulate unset setup_app_templates)
against a dummy_test_app that relies on the fallback (e.g., "default" or a new
fixture) and assert the command exits with success or failure as expected and
that stderr contains the fallback behavior markers (e.g., "[PASS] templates" or
expected failure messages); specifically reference setup_app_templates being
nil/unset and ensure the test checks that templates validation runs over all
templates rather than only selected ones to guard the fallback path.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ef8ae8ec-721e-4119-8bac-9b1f8d39bf8e
📒 Files selected for processing (7)
lib/core/doctor_service.rblib/core/template_parser.rbspec/command/doctor_spec.rbspec/core/template_parser_spec.rbspec/dummy/.controlplane/controlplane.ymlspec/dummy/.controlplane/templates/app-review.ymlspec/dummy/.controlplane/templates/app-with-deprecated-variables-no-image.yml
Greptile SummaryThis PR fixes a false-positive duplicate-template validation error triggered when an app's
Confidence Score: 4/5Safe to merge; the core validation logic is correct and the two-phase missing-template flow for apply-template is intentional. The selected-template filtering, the lazy image fetch, and the lib/core/doctor_service.rb — the Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[DoctorService#validate_templates] --> B[template_filenames]
B --> C{config.args.any?}
C -- Yes\napply-template path --> D[existing_arg_template_filenames]
D --> E{All files exist?}
E -- No --> F[return empty array\nlet apply-template handle error]
E -- Yes --> G[return filenames]
C -- No\ndoctor / setup-app path --> H{setup_app_templates\nconfigured?}
H -- No --> I[Dir.glob all *.yml\nfull fallback]
H -- Yes --> J[map names to filenames]
J --> K[ensure_templates_exist!]
K --> L{Any missing?}
L -- Yes --> M[raise ValidationError\nMissing templates]
L -- No --> G
G --> N[TemplateParser#parse filenames]
I --> N
F --> N
N --> O[replace_variables per file]
O --> P{includes APP_IMAGE\nor APP_IMAGE_LINK?}
P -- Yes --> Q[cp.latest_image\nreplace image vars]
P -- No --> R[skip image fetch]
Q --> S[check_for_duplicate_templates]
R --> S
S --> T{Duplicates?}
T -- Yes --> U[raise ValidationError\nDuplicate templates]
T -- No --> V[warn_deprecated_template_variables]
Reviews (1): Last reviewed commit: "Validate selected setup templates" | Re-trigger Greptile |
Code ReviewOverviewThis PR scopes template validation in Bug:
|
Code ReviewOverviewThis PR fixes a real-world bug (TanStack review apps failing cpflow 5.1.1 duplicate-template validation) and closes a CI gap (review-app deploys marking success before the workload was actually healthy). The two changes are independent and well-scoped. What's Good
IssuesThree inline comments were posted; summaries below:
Minor Notes
|
ReviewThis PR scopes template validation to the The CI/health-check wiring is solid — the finalize step reads Bug: explicit-arg template path silently passes validation when a named template is missing
When The non-args path (when Suggested fix — replace the silent empty-list return with the same guard used on the other path: def existing_arg_template_filenames
filenames = config.args.map { |name| @template_parser.template_filename(name) }
ensure_templates_exist!(config.args, filenames)
filenames
endThis raises a Maintenance: health-check defaults are hardcoded in two places
The four fallback literals ( Simpler approach — pass the repo variable directly and let the action's declared defaults serve as the single source of truth: REVIEW_APP_HEALTH_CHECK_RETRIES: ${{ vars.REVIEW_APP_HEALTH_CHECK_RETRIES }}
REVIEW_APP_HEALTH_CHECK_INTERVAL: ${{ vars.REVIEW_APP_HEALTH_CHECK_INTERVAL }}
REVIEW_APP_HEALTH_CHECK_ACCEPTED_STATUSES: ${{ vars.REVIEW_APP_HEALTH_CHECK_ACCEPTED_STATUSES }}
REVIEW_APP_HEALTH_CHECK_CURL_MAX_TIME: ${{ vars.REVIEW_APP_HEALTH_CHECK_CURL_MAX_TIME }}When the repo variable is unset the env var is an empty string; the action receives |
10e246f to
1962536
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
spec/core/template_parser_spec.rb (1)
7-25: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winStub
Config#image_linkwith the expected argument.
TemplateParsercallsconfig.image_link(latest_image), but this double treatsimage_linklike a fixed attribute. That makes these examples insensitive to passing the wrong tag intoimage_link.Proposed change
let(:config) do instance_double( Config, org: "test-org", app: "test-review-123", location: "aws-us-east-2", location_link: "/org/test-org/location/aws-us-east-2", - image_link: "/org/test-org/image/test-review-123:1", identity: "test-review-123-identity", identity_link: "/org/test-org/gvc/test-review-123/identity/test-review-123-identity", secrets: "test-review-secrets", secrets_policy: "test-review-secrets-policy", shared_secret_placeholders: { "{{SHARED_SECRET_DATABASE}}" => "test-shared-database-secrets" } - ) + ).tap do |config| + allow(config).to receive(:image_link) + .with("test-review-123:1") + .and_return("/org/test-org/image/test-review-123:1") + end end🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@spec/core/template_parser_spec.rb` around lines 7 - 25, `TemplateParser` is calling `config.image_link` with a tag argument, but the spec stubs `image_link` as a no-arg attribute, so the example won’t catch a wrong value being passed. Update the `config` double in `template_parser_spec` to expect `image_link` with the `latest_image` argument from `cp` (via `Command::ApplyTemplate`), and verify the returned link is based on that argument so the spec exercises the real call shape.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@spec/core/template_parser_spec.rb`:
- Around line 7-25: `TemplateParser` is calling `config.image_link` with a tag
argument, but the spec stubs `image_link` as a no-arg attribute, so the example
won’t catch a wrong value being passed. Update the `config` double in
`template_parser_spec` to expect `image_link` with the `latest_image` argument
from `cp` (via `Command::ApplyTemplate`), and verify the returned link is based
on that argument so the spec exercises the real call shape.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d0fbe39c-9228-4635-9eae-8101a7eb17dd
📒 Files selected for processing (5)
.github/workflows/cpflow-deploy-review-app.ymllib/core/doctor_service.rblib/core/template_parser.rbspec/command/doctor_spec.rbspec/core/template_parser_spec.rb
🚧 Files skipped from review as they are similar to previous changes (3)
- .github/workflows/cpflow-deploy-review-app.yml
- lib/core/template_parser.rb
- spec/command/doctor_spec.rb
Review: Validate selected setup templates and review-app healthThis PR fixes a real user-facing bug (duplicate-template validation against all templates instead of the selected set) and closes a deploy-status gap (review-app marking success before the workload is healthy). The Ruby changes are well-structured; the GitHub Actions integration is clean. Four findings below, ranging from a dead guard to a DRY violation. Finding 1 — Dead guard clause in
|
|
Code review posted via inline comments — see thread below. |
|
Review summary: two inline comments posted. (1) Medium — latent health-check bypass on the Retrieve app URL step condition in cpflow-deploy-review-app.yml: GHA implicit step-skipping is correct today, but adding continue-on-error: true to health-check in the future would allow a false-success deployment status. Suggest adding steps.health-check.outcome == success to the if: guard. (2) Low/cleanup — existing_arg_template_filenames in doctor_service.rb is called once and is structurally identical to the configured-template branch; a shared resolve_template_filenames(names) helper would remove the duplication. No correctness regressions found in the template-variable substitution refactor — the word-boundary regex and find_deprecated_variables ordering are both correct. |
7241699 to
3034329
Compare
Review: Validate selected setup templates and review-app healthThis PR fixes two distinct issues cleanly: the TanStack duplicate-template false-positive (by scoping doctor's template validation to the app's Two maintenance findings survived verification: 1. Health-check defaults are duplicated between workflow and actionThe four The defaults belong in one place. The simplest fix is to drop the workflow-level env vars and write the repo-var fallback inline at the with:
max_retries: ${{ vars.REVIEW_APP_HEALTH_CHECK_RETRIES || '24' }}
interval_seconds: ${{ vars.REVIEW_APP_HEALTH_CHECK_INTERVAL || '15' }}
accepted_statuses: ${{ vars.REVIEW_APP_HEALTH_CHECK_ACCEPTED_STATUSES || '200 301 302' }}
curl_max_time: ${{ vars.REVIEW_APP_HEALTH_CHECK_CURL_MAX_TIME || '10' }}2.
|
3034329 to
881be74
Compare
Review: Validate selected setup templates and review-app healthThis PR does three things: narrows template validation to the Three findings worth addressing: 1.
Fix: scan the raw file content before any substitution, or apply the same 2.
Suggestion: add a comment explaining 3.
|
Address-review summaryScan scope: full PR review data for the two current unresolved template parser threads, after Mattered
Validation
Workflow Change Audit: existing PR workflow diff, unchanged by
Skipped
Next default scan starts after this comment. Say |
Review summaryThis PR does two things: (1) makes Left inline comments on a few lower-severity items:
Two other notes not tied to a single diff line:
Nothing found that looks like a release blocker. |
ReviewThis PR (1) narrows the doctor "templates" validation to only parse the templates selected via I traced the new/changed code line by line, checked every caller of the changed methods (
One low-severity item survived as worth a mention (posted inline on
No correctness, security, or performance bugs found in this diff. |
Summary
setup_app_templatesfor doctor/setup-appsetup_app_templatesare configuredapply-template's existing missing-template handling for explicit argsWhy
TanStack review apps hit cpflow 5.1.1 duplicate-template validation because the app intentionally has
app.ymlandapp-review.ymlthat both render the same GVC name, but only one is selected for a review app setup. The validator was parsing every template file instead of the selected set.While validating the rollout, the legacy review app also exposed a deploy-status gap: the reusable review-app deploy workflow could mark a deployment successful after updating the image and finding an endpoint, even if the primary workload was crash-looping. Review-app deploys now reuse the existing
cpflow-wait-for-healthaction, withREVIEW_APP_HEALTH_CHECK_*repo-variable overrides.Verification
CPLN_ORG=dummy-test-org bundle exec rspec spec/command/doctor_spec.rb spec/core/template_parser_spec.rb spec/command/apply_template_spec.rb:8bundle exec rubocop lib/core/doctor_service.rb lib/core/template_parser.rb spec/command/doctor_spec.rb spec/core/template_parser_spec.rb spec/command/apply_template_spec.rbruby -c lib/core/doctor_service.rb && ruby -c lib/core/template_parser.rbCPLN_ORG=dummy-test-org bundle exec rspec spec/command/generate_github_actions_spec.rb spec/command/deploy_image_unit_spec.rbbundle exec rubocop spec/command/generate_github_actions_spec.rb.github/workflows/cpflow-*.ymland.github/actions/cpflow-*/*.ymlgit diff --checkNotes
actionlint .github/workflows/cpflow-deploy-review-app.ymlstill reports pre-existing false positives for GitHub'sjob.workflow_repository,job.workflow_sha, andjob.workflow_refcontext fields; it did not report issues for the new health-check expressions.Summary by CodeRabbit
APP_IMAGE/APP_IMAGE_LINKplaceholder replacement, including legacy backward-compatible behavior.