fix: wait for new PipelineRun before reporting build complete#51
Conversation
The -d flag would immediately download artifacts from a previous run if the BuildJob was already in Succeeded phase. Now the CLI records the PipelineRun at trigger time and waits until it changes (indicating the operator started the new run) before considering terminal phases. Falls back after a 2-minute timeout if no new run appears. Co-authored-by: Cursor <cursoragent@cursor.com>
📝 WalkthroughWalkthroughThe change modifies the build wait logic in ChangesBuild startup polling control
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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: 86c2768c2a
ℹ️ 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".
| if build.PipelineRun != previousRun { | ||
| buildStarted = true | ||
| fmt.Printf(" New PipelineRun: %s\n", build.PipelineRun) | ||
| } else if build.Phase == "Succeeded" || build.Phase == "Failed" { | ||
| if time.Since(start) > buildStartupTimeout { |
There was a problem hiding this comment.
Detect already-switched PipelineRun as build start
In waitAndDownload, startup is only recognized when build.PipelineRun != previousRun, but previousRun is captured from an immediate Get done after triggering. If the controller has already switched CurrentPipelineRun by that first read, the new run's name equals previousRun, so buildStarted never flips until a terminal phase plus the 2-minute timeout. In that case successful/failed builds are reported at least 2 minutes late (and the fallback path is taken unnecessarily), which regresses the normal bob build ... -d flow from cmd/bob/build.go.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@cmd/bob/wait.go`:
- Around line 35-39: The polling logic in waitAndDownload captures previousRun
once (previousRun := initial.PipelineRun) so if initial already has the new
PipelineRun the loop never sees a change and buildStarted stays false until
buildStartupTimeout elapses; fix by initializing previousRun to nil/empty and/or
immediately detecting a non-nil current PipelineRun on the first poll: in
waitAndDownload, after the initial c.Get(ctx, name) and inside the polling loop
re-read build := c.Get(...) (or use the existing variable) and set buildStarted
= true when build.PipelineRun != nil && build.PipelineRun != previousRun (or
when previousRun is nil and build.PipelineRun != nil), update previousRun each
iteration, and ensure the logic that prints phase output and triggers download
uses the updated buildStarted and current build state instead of relying on a
single captured previousRun variable.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 092516cd-bc9b-4871-a834-d0385dc98848
📒 Files selected for processing (1)
cmd/bob/wait.go
If the operator updates PipelineRun before our initial Get, previousRun already matches the new run. Treat Running/Pending phases as proof the build has started, avoiding a 2-minute stall before downloading. Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
bob build -dwould immediately download artifacts from a stale build when the BuildJob was already inSucceededphase from a previous runReproduction
Test plan
go build ./cmd/bob/compilesgo test ./cmd/bob/all tests passbob build <name> -d ./outwaits for the new PipelineRun to completeMade with Cursor
Summary by CodeRabbit