fix(deploy): use server group's last_revision for incremental deploys#19
Conversation
Deploying to a server group via `dhq deploy -s "Group Name"` always performed a full deploy from the first commit, ignoring the group's prior deployment history. When the `-s` value resolved to a group, the code set `resolvedServer = nil` and never captured the group, so `resolveStartRevision` (which only looked at `Server.LastRevision`) returned `""`. The API treats an empty `start_revision` as "deploy entire branch from the first commit" — exactly the fresh-deploy behaviour the customer reported. Capture `resolvedGroup *sdk.ServerGroup` alongside `resolvedServer` so both name- and UUID-based group resolution flow into the same incremental path used for individual servers. `ServerGroup.LastRevision` is the `end_revision` of the most recent group-targeted deployment (Rails: `ServerGroup#last_revision`), which is the correct incremental baseline. Newly-created groups have an empty value so the first group deploy still falls through to a full deploy. Also use `ServerGroup.PreferredBranch` when no server is resolved, so group deploys honour the group's configured branch instead of silently deploying the repository default branch's tip. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughDeploy command extended to support both Server and ServerGroup targets. Branch and start-revision resolution functions now accept pre-resolved groups. Command flow tracks and resolves group identifiers, fetching missing data eagerly. Test infrastructure and coverage updated to validate group-aware branch selection, incremental baselines, and resolution precedence. ChangesServer group deployment support
Possibly related PRs
🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/commands/deploy_test.go (1)
429-454: ⚡ Quick winConsider adding
branchesCalledassertion for consistency.The equivalent server test (
TestResolveBranchAndRevision_UsesServerPreferredBranchat line 118) explicitly verifiesbranchesCalledis true. Adding the same assertion here would improve test explicitness and pattern consistency.Proposed assertion to add
After line 453, add:
assert.Equal(t, "sha-of-release", revision, "must be release's tip, not main's") + assert.True(t, mux.branchesCalled, "should query /branches to map branch→sha") assert.False(t, mux.latestRevCalled, "should NOT fall back to repo default")🤖 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 `@internal/commands/deploy_test.go` around lines 429 - 454, Add an assertion to verify the branches endpoint was called by asserting the branchEndpointMux instance's branchesCalled flag is true; in TestResolveBranchAndRevision_UsesGroupPreferredBranch (where mux is the branchEndpointMux) add something like assert.True(t, mux.branchesCalled, "should call branches endpoint") just before or after the existing latestRevCalled assertion to match the pattern used in TestResolveBranchAndRevision_UsesServerPreferredBranch.
🤖 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 `@internal/commands/deploy_test.go`:
- Around line 429-454: Add an assertion to verify the branches endpoint was
called by asserting the branchEndpointMux instance's branchesCalled flag is
true; in TestResolveBranchAndRevision_UsesGroupPreferredBranch (where mux is the
branchEndpointMux) add something like assert.True(t, mux.branchesCalled, "should
call branches endpoint") just before or after the existing latestRevCalled
assertion to match the pattern used in
TestResolveBranchAndRevision_UsesServerPreferredBranch.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1ecc05ff-df65-4711-9958-37df4d53d6b5
📒 Files selected for processing (2)
internal/commands/deploy.gointernal/commands/deploy_test.go
Mirrors the equivalent assertion in TestResolveBranchAndRevision_UsesServerPreferredBranch so the test explicitly verifies the branch→sha lookup path was taken, not only that the repo-default fallback was skipped. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
dhq deploy -s "Group Name"always did a fresh full deploy from the first commit, ignoring the group's prior deployment history.-sresolved to a server group,resolvedServerwas set toniland the group was never captured, soresolveStartRevisionreturned""— which the API interprets as "deploy entire branch from the first commit".resolvedGroup *sdk.ServerGroupalongsideresolvedServerfor both name- and UUID-based group resolution, and useServerGroup.LastRevision/ServerGroup.PreferredBranchwhen no server is resolved. Matches the Rails-sideServerGroup#last_revisionsemantics (end_revision of the most recent group-targeted deployment).LastRevisionis empty — preserving the expected first-deploy behaviour.Reported by
Customer follow-up to #11 / DHQ-586: name resolution now works, but the resulting deploy ignores the previous commit and starts fresh.
Test plan
go vet ./...cleangolangci-lint run ./...— 0 issuesgo test ./...— full suite passesTestResolveStartRevision_GroupLastRevisionUsedWhenNoServerTestResolveStartRevision_GroupIgnoredWhenServerHasLastRevisionTestResolveStartRevision_FreshGroupReturnsEmptyTestResolveStartRevision_FullClearsGroupLastRevisionTestResolveBranchAndRevision_UsesGroupPreferredBranchTestResolveBranchAndRevision_FetchesGroupWhenServerFailsTestResolveBranchAndRevision_ServerPreferredBranchBeatsGroupdhq deploy -p <project> -s "<group name>"— verify the new deployment'sstart_revisionmatches the group's previousend_revision.🤖 Generated with Claude Code
Summary by CodeRabbit