Skip to content

Testing that Review App Deployment Workflow only redeploys on Pull Request Trigger #645

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 1, 2025

Conversation

Judahmeek
Copy link
Collaborator

@Judahmeek Judahmeek commented Apr 30, 2025

This change is Reviewable

Summary by CodeRabbit

  • Style

    • Updated the link text to display "Rails On Maui on Twitter" for improved clarity.
  • Chores

    • Simplified deployment workflow to streamline app setup and restrict deployment actions to confirmed app existence.

Copy link

coderabbitai bot commented Apr 30, 2025

"""

Walkthrough

This change updates the text label of a hyperlink in the Footer component, specifically within the file Footer/Footer.jsx. The anchor text is modified from "Rails On Maui on X" to "Rails On Maui on Twitter". Additionally, the GitHub Actions workflow file deploy-to-control-plane-review-app.yml has been simplified by removing the entire "Validate Deployment Request" step and restructuring the deployment control flow. The workflow now only sets up a new Control Plane app if it does not exist and the event is not a pull request, sets APP_EXISTS=true after setup, and gates all deployment steps behind the condition that the app exists. On pull request events where the app does not exist, the workflow prints a cancellation message instead of exiting early. These changes remove prior complex validation logic and prevent deployment attempts when the app is missing on pull requests.

Changes

File(s) Change Summary
client/app/bundles/comments/components/Footer/Footer.jsx Changed anchor text from "Rails On Maui on X" to "Rails On Maui on Twitter".
.github/workflows/deploy-to-control-plane-review-app.yml Removed "Validate Deployment Request" step; modified review app existence check to no longer exit early on PR events; added condition gating all deployment steps on app existence; set APP_EXISTS=true after app setup; streamlined deployment control flow to prevent deployment if app does not exist on PR events.

Possibly related PRs

Poem

A rabbit hopped through code today,
Changed a link to show the way.
From "X" to "Twitter," clear and bright,
And workflows now deploy just right.
No more steps when apps are gone,
Builds wait patient, dusk to dawn!
🐇🌿✨
"""


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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

🚀 Quick Review App Commands

Welcome! Here are the commands you can use in this PR:

/deploy-review-app

Deploy your PR branch for testing

/delete-review-app

Remove the review app when done

/help

Show detailed instructions, environment setup, and configuration options.


Copy link

github-actions bot commented Apr 30, 2025

🚀 Deploying to Control Plane...

⏳ Waiting for deployment to be ready...

📝 View Deploy Logs

🎮 Control Plane Console

@github-actions github-actions bot requested a deployment to review-app April 30, 2025 23:41 In progress
Copy link

github-actions bot commented Apr 30, 2025

🚀 Deploying to Control Plane...

⏳ Waiting for deployment to be ready...

📝 View Deploy Logs

🎮 Control Plane Console

@github-actions github-actions bot requested a deployment to review-app April 30, 2025 23:54 In progress
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c90a2d8 and abd2530.

📒 Files selected for processing (2)
  • .github/workflows/deploy-to-control-plane-review-app.yml (1 hunks)
  • client/app/bundles/comments/components/Footer/Footer.jsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • client/app/bundles/comments/components/Footer/Footer.jsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: test (22.x, 3.3.4)
  • GitHub Check: deploy

Comment on lines 114 to 119
if cpflow exists -a ${{ env.APP_NAME }}; then
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
exit 0
echo "Canceling job as review app has not been previously deployed."; sleep inf
fi
echo "APP_EXISTS=false" >> $GITHUB_ENV
else
echo "APP_EXISTS=true" >> $GITHUB_ENV
fi
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Incorrect APP_EXISTS flag handling & invalid sleep invocation.

  • The script currently sets APP_EXISTS=false when the app exists, which inverts the intended semantics for the “Setup Control Plane App if Not Existing” step. There’s also no branch for when the app does not exist, so APP_EXISTS remains undefined in that case.
  • Using sleep inf is invalid as the sleep command does not accept “inf” and will error instead of pausing indefinitely. To gracefully skip further deployment steps on PRs, use exit 0 (or a proper infinite loop) after setting the flag.

Apply this diff to correct the existence check and early-exit behavior:

-          if cpflow exists -a ${{ env.APP_NAME }}; then
-            if [[ "${{ github.event_name }}" == "pull_request" ]]; then
-              echo "Canceling job as review app has not been previously deployed."; sleep inf
-            fi
-            echo "APP_EXISTS=false" >> $GITHUB_ENV
-          fi
+          if cpflow exists -a ${{ env.APP_NAME }}; then
+            # App already exists
+            echo "APP_EXISTS=true" >> $GITHUB_ENV
+            if [[ "${{ github.event_name }}" == "pull_request" ]]; then
+              echo "Review app for PR #${{ env.PR_NUMBER }} already deployed; skipping redeployment."
+              exit 0
+            fi
+          else
+            # App does not exist
+            echo "APP_EXISTS=false" >> $GITHUB_ENV
+          fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if cpflow exists -a ${{ env.APP_NAME }}; then
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
exit 0
echo "Canceling job as review app has not been previously deployed."; sleep inf
fi
echo "APP_EXISTS=false" >> $GITHUB_ENV
else
echo "APP_EXISTS=true" >> $GITHUB_ENV
fi
if cpflow exists -a ${{ env.APP_NAME }}; then
# App already exists
echo "APP_EXISTS=true" >> $GITHUB_ENV
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "Review app for PR #${{ env.PR_NUMBER }} already deployed; skipping redeployment."
exit 0
fi
else
# App does not exist
echo "APP_EXISTS=false" >> $GITHUB_ENV
fi

Copy link

github-actions bot commented May 1, 2025

🚀 Deploying to Control Plane...

⏳ Waiting for deployment to be ready...

📝 View Deploy Logs

🎮 Control Plane Console

@github-actions github-actions bot requested a deployment to review-app May 1, 2025 00:14 In progress
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (2)
.github/workflows/deploy-to-control-plane-review-app.yml (2)

119-119: 🛠️ Refactor suggestion

⚠️ Potential issue

Replace invalid sleep inf with an early exit.

sleep inf is not a valid invocation of sleep and will error out. To skip redeployment on pull requests, exit the script gracefully:

-              echo "Canceling job as review app has not been previously deployed."; sleep inf
+              echo "Review app not deployed yet; skipping redeployment for PR." 
+              exit 0

121-123: 🛠️ Refactor suggestion

Handle both existence cases and remove duplicate ENV export.

Currently there’s no else branch to set APP_EXISTS=true, and the APP_EXISTS=false export is printed twice. Recommend consolidating into a two-branch check:

-          if cpflow exists -a "${{ env.APP_NAME }}"; then
-            # ...
-            echo "APP_EXISTS=false"
-            echo "APP_EXISTS=false" >> $GITHUB_ENV
-          fi
+          if cpflow exists -a "${{ env.APP_NAME }}"; then
+            echo "APP_EXISTS=true" >> $GITHUB_ENV
+            if [[ "${{ github.event_name }}" == "pull_request" ]]; then
+              echo "Review app already deployed; skipping redeploy on PR."
+              exit 0
+            fi
+          else
+            echo "APP_EXISTS=false" >> $GITHUB_ENV
+          fi

This sets the flag correctly in both scenarios and removes the duplicated export.

🧹 Nitpick comments (1)
.github/workflows/deploy-to-control-plane-review-app.yml (1)

114-115: Remove extraneous debugging statements.

The echo "apple", echo "$(cpflow exists -a ${{ env.APP_NAME }})" and echo "bananas" lines are leftover debug noise. They should be removed to keep the workflow logs concise and clear.

Also applies to: 124-124

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between abd2530 and 78b497d.

📒 Files selected for processing (1)
  • .github/workflows/deploy-to-control-plane-review-app.yml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test (22.x, 3.3.4)

Copy link

github-actions bot commented May 1, 2025

🚀 Deploying to Control Plane...

⏳ Waiting for deployment to be ready...

📝 View Deploy Logs

🎮 Control Plane Console

@github-actions github-actions bot requested a deployment to review-app May 1, 2025 00:27 In progress
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
.github/workflows/deploy-to-control-plane-review-app.yml (1)

123-131: Gating new Control Plane app setup and setting APP_EXISTS
The setup-app step now only runs when APP_EXISTS is false and github.event_name is not a pull request, then correctly sets APP_EXISTS=true afterward so downstream steps proceed. This aligns with the goal to avoid redeployment on PR triggers. Consider quoting the app name argument ("${{ env.APP_NAME }}") for added safety.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 78b497d and bb2f1c0.

📒 Files selected for processing (1)
  • .github/workflows/deploy-to-control-plane-review-app.yml (7 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test (22.x, 3.3.4)
🔇 Additional comments (10)
.github/workflows/deploy-to-control-plane-review-app.yml (10)

114-121: Confirm pull request cancellation behavior without exit
The step echoes a cancellation message for PR events when the app doesn’t exist but does not terminate the job. Subsequent steps are correctly gated on APP_EXISTS, so no deployment runs—but the runner still processes the entire workflow. Please verify if you intend to keep the job alive to the end or explicitly exit (e.g., exit 0) immediately after the echo to shorten logs and runtime.


132-136: Gate initial deployment comment on APP_EXISTS
Adding if: env.APP_EXISTS == 'true' ensures the initial GitHub comment is only created when a review app exists or has just been set up—preventing unnecessary comments on PR workflows without an app.


146-151: Gate setting of deployment URLs on APP_EXISTS
By gating this step, you avoid exporting WORKFLOW_URL and CONSOLE_LINK when no review app exists, ensuring downstream steps that rely on these variables won’t error out.


178-183: Gate GitHub deployment initialization on APP_EXISTS
Conditioning the create-deployment call on APP_EXISTS prevents unnecessary API requests when there’s no app, aligning with the intended behavior.


208-212: Gate 'Building' status update on APP_EXISTS
Ensures the "Building" comment update only runs when an initial comment exists, avoiding API errors from updating a non-existent comment.


228-233: Gate Docker image build on APP_EXISTS
Prevents starting a Docker build for non‐existent review apps, satisfying the PR objective to restrict deployments on PR triggers without apps.


238-243: Gate 'Deploying' status update on APP_EXISTS
The gating ensures that only valid deployments update the issue comment, preventing misleading messages when no deployment occurs.


260-263: Gate actual image deployment on APP_EXISTS
Checking env.APP_EXISTS here blocks cpflow deploy-image from running when there’s no app, fully preventing redeployment on pull_request events.


264-268: Gate retrieval of app URL on APP_EXISTS
Conditioning the WORKLOAD_URL extraction on APP_EXISTS avoids running the cpln workload get command for non-existent apps, keeping the workflow clean.


269-273: Gate final deployment status update on APP_EXISTS
The final status update is now correctly gated, so you only post a "deployment complete" comment when a deployment actually occurred, avoiding confusion on PRs without apps.

@Judahmeek Judahmeek merged commit a588346 into master May 1, 2025
4 checks passed
@Judahmeek Judahmeek deleted the judahmeek/test branch May 1, 2025 02:20
Copy link

github-actions bot commented May 1, 2025

✅ Review app for PR #645 was successfully deleted

View Completed Delete Logs

Control Plane Organization

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