Skip to content

Commit 58f44dc

Browse files
committed
fix: address upstream monitor review
1 parent e6dd23a commit 58f44dc

4 files changed

Lines changed: 44 additions & 4 deletions

‎docs/plans/2026-07-02-upstream-release-monitor.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# GitHub Upstream Release Monitor Plan
22

3-
**Status:** Locked 2026-07-02T21:56:54Z
43
**Date:** 2026-07-02
54
**Design:** docs/plans/2026-07-02-upstream-release-monitor-design.md
65

@@ -21,7 +20,7 @@
2120
|------|-------|-------|--------|
2221
| 1 | Add upstream release monitor step | Task 1, Task 2, Task 3, Task 4 | feat/upstream-release-monitor |
2322

24-
**Status:** Draft
23+
**Status:** Locked 2026-07-02T21:56:54Z
2524

2625
### Task 1: Record Boundary
2726

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
de155f0cc3a5e9387586eb759425075e12bb50bf06c18614ee5d5aa7b05e8f67
1+
e1ce0cd7375029d9cd689119fbce94210e632829de2c024a1876b19012a2875f

‎internal/step_upstream_release_monitor.go‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ func (githubUpstreamReleaseClient) LatestRelease(ctx context.Context, owner, rep
109109
client = client.WithAuthToken(token)
110110
}
111111

112-
release, _, err := client.Repositories.GetLatestRelease(ctx, owner, repo)
112+
requestCtx, cancel := githubReleaseLookupContext(ctx)
113+
defer cancel()
114+
115+
release, _, err := client.Repositories.GetLatestRelease(requestCtx, owner, repo)
113116
if err != nil {
114117
return upstreamReleaseInfo{}, err
115118
}
@@ -128,3 +131,10 @@ func (githubUpstreamReleaseClient) LatestRelease(ctx context.Context, owner, rep
128131
PublishedAt: publishedAt,
129132
}, nil
130133
}
134+
135+
func githubReleaseLookupContext(ctx context.Context) (context.Context, context.CancelFunc) {
136+
if _, ok := ctx.Deadline(); ok {
137+
return ctx, func() {}
138+
}
139+
return context.WithTimeout(ctx, 30*time.Second)
140+
}

‎internal/step_upstream_release_monitor_test.go‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,34 @@ func TestGitHubPluginCreateStep_UpstreamReleaseMonitor(t *testing.T) {
193193
t.Fatalf("CreateStep returned %T, want *upstreamReleaseMonitorStep", step)
194194
}
195195
}
196+
197+
func TestGitHubReleaseLookupContextAddsDefaultTimeout(t *testing.T) {
198+
ctx, cancel := githubReleaseLookupContext(context.Background())
199+
defer cancel()
200+
201+
deadline, ok := ctx.Deadline()
202+
if !ok {
203+
t.Fatal("expected deadline")
204+
}
205+
remaining := time.Until(deadline)
206+
if remaining <= 0 || remaining > 30*time.Second {
207+
t.Fatalf("deadline remaining = %s, want within 30s", remaining)
208+
}
209+
}
210+
211+
func TestGitHubReleaseLookupContextPreservesCallerDeadline(t *testing.T) {
212+
callerDeadline := time.Now().Add(5 * time.Second)
213+
parent, parentCancel := context.WithDeadline(context.Background(), callerDeadline)
214+
defer parentCancel()
215+
216+
ctx, cancel := githubReleaseLookupContext(parent)
217+
defer cancel()
218+
219+
deadline, ok := ctx.Deadline()
220+
if !ok {
221+
t.Fatal("expected deadline")
222+
}
223+
if !deadline.Equal(callerDeadline) {
224+
t.Fatalf("deadline = %s, want caller deadline %s", deadline, callerDeadline)
225+
}
226+
}

0 commit comments

Comments
 (0)