Skip to content

Commit 9de0431

Browse files
poseclaude
andauthored
Fetch only the PR ref in the Renovate SDK commit step (#2450)
`build_sdk` (bridged) and `run-acceptance-tests` (native) have a step that commits regenerated SDKs back onto a Renovate PR. It ran a bare `git fetch` before checking out the PR branch. A bare fetch uses the remote's default refspec, so it pulls every branch in the repo rather than the single ref the next line checks out. `fetch.recurseSubmodules` defaults to `on-demand`, so git then walks all of those newly fetched commits, collects the submodule gitlink each one points at, and asks the submodule's remote for any sha it doesn't already have locally. A branch untouched for years can carry a gitlink that remote no longer serves; that fetch fails, and since the step runs under `bash -e` it dies before the `git push` that would land the regenerated SDK. Narrowing the refspec means only the PR's own commits are ever scanned. `--no-recurse-submodules` guards the same failure if the refspec is widened again later. It also drops the cost of fetching every branch and tag on each run. Regenerated the checked-in test providers; actionlint and the Go tests pass. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent c98abb6 commit 9de0431

16 files changed

Lines changed: 78 additions & 50 deletions

File tree

provider-ci/internal/pkg/templates/base/.github/workflows/build_sdk.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,13 @@ jobs:
118118
git config --global user.email "bot@pulumi.com"
119119
git config --global user.name "pulumi-bot"
120120
121-
# Stash local changes and check out the PR's branch directly.
121+
# Stash local changes and check out the PR's branch directly. Fetch
122+
# only that ref: a bare fetch pulls every branch in the repo, and
123+
# on-demand submodule recursion then tries to resolve the submodule
124+
# gitlink of every commit it pulls, including long-dead branches
125+
# pointing at commits the submodule's remote no longer serves.
122126
git stash
123-
git fetch
127+
git fetch --no-recurse-submodules origin "+refs/heads/$HEAD_REF:refs/remotes/origin/$HEAD_REF"
124128
git checkout "origin/$HEAD_REF"
125129
126130
# Apply and add our changes, but don't commit any files we expect to

provider-ci/internal/pkg/templates/native/.github/workflows/run-acceptance-tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,11 @@ jobs:
180180
181181
git config --global user.name "pulumi-bot"
182182
183-
# Stash local changes and check out the PR's branch directly.
183+
# Stash local changes and check out the PR's branch directly, fetching only that ref so submodule recursion never sees gitlinks from unrelated branches.
184184
185185
git stash
186186
187-
git fetch
187+
git fetch --no-recurse-submodules origin "+refs/heads/$HEAD_REF:refs/remotes/origin/$HEAD_REF"
188188
189189
git checkout "origin/$HEAD_REF"
190190
@@ -346,11 +346,11 @@ jobs:
346346
347347
git config --global user.name "pulumi-bot"
348348
349-
# Stash local changes and check out the PR's branch directly.
349+
# Stash local changes and check out the PR's branch directly, fetching only that ref so submodule recursion never sees gitlinks from unrelated branches.
350350
351351
git stash
352352
353-
git fetch
353+
git fetch --no-recurse-submodules origin "+refs/heads/$HEAD_REF:refs/remotes/origin/$HEAD_REF"
354354
355355
git checkout "origin/$HEAD_REF"
356356

provider-ci/test-providers/aws-native/.github/workflows/run-acceptance-tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,11 @@ jobs:
169169
170170
git config --global user.name "pulumi-bot"
171171
172-
# Stash local changes and check out the PR's branch directly.
172+
# Stash local changes and check out the PR's branch directly, fetching only that ref so submodule recursion never sees gitlinks from unrelated branches.
173173
174174
git stash
175175
176-
git fetch
176+
git fetch --no-recurse-submodules origin "+refs/heads/$HEAD_REF:refs/remotes/origin/$HEAD_REF"
177177
178178
git checkout "origin/$HEAD_REF"
179179
@@ -333,11 +333,11 @@ jobs:
333333
334334
git config --global user.name "pulumi-bot"
335335
336-
# Stash local changes and check out the PR's branch directly.
336+
# Stash local changes and check out the PR's branch directly, fetching only that ref so submodule recursion never sees gitlinks from unrelated branches.
337337
338338
git stash
339339
340-
git fetch
340+
git fetch --no-recurse-submodules origin "+refs/heads/$HEAD_REF:refs/remotes/origin/$HEAD_REF"
341341
342342
git checkout "origin/$HEAD_REF"
343343

provider-ci/test-providers/aws/.github/workflows/build_sdk.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,13 @@ jobs:
129129
git config --global user.email "bot@pulumi.com"
130130
git config --global user.name "pulumi-bot"
131131
132-
# Stash local changes and check out the PR's branch directly.
132+
# Stash local changes and check out the PR's branch directly. Fetch
133+
# only that ref: a bare fetch pulls every branch in the repo, and
134+
# on-demand submodule recursion then tries to resolve the submodule
135+
# gitlink of every commit it pulls, including long-dead branches
136+
# pointing at commits the submodule's remote no longer serves.
133137
git stash
134-
git fetch
138+
git fetch --no-recurse-submodules origin "+refs/heads/$HEAD_REF:refs/remotes/origin/$HEAD_REF"
135139
git checkout "origin/$HEAD_REF"
136140
137141
# Apply and add our changes, but don't commit any files we expect to

provider-ci/test-providers/cloudflare/.github/workflows/build_sdk.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,13 @@ jobs:
126126
git config --global user.email "bot@pulumi.com"
127127
git config --global user.name "pulumi-bot"
128128
129-
# Stash local changes and check out the PR's branch directly.
129+
# Stash local changes and check out the PR's branch directly. Fetch
130+
# only that ref: a bare fetch pulls every branch in the repo, and
131+
# on-demand submodule recursion then tries to resolve the submodule
132+
# gitlink of every commit it pulls, including long-dead branches
133+
# pointing at commits the submodule's remote no longer serves.
130134
git stash
131-
git fetch
135+
git fetch --no-recurse-submodules origin "+refs/heads/$HEAD_REF:refs/remotes/origin/$HEAD_REF"
132136
git checkout "origin/$HEAD_REF"
133137
134138
# Apply and add our changes, but don't commit any files we expect to

provider-ci/test-providers/command/.github/workflows/run-acceptance-tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,11 @@ jobs:
120120
121121
git config --global user.name "pulumi-bot"
122122
123-
# Stash local changes and check out the PR's branch directly.
123+
# Stash local changes and check out the PR's branch directly, fetching only that ref so submodule recursion never sees gitlinks from unrelated branches.
124124
125125
git stash
126126
127-
git fetch
127+
git fetch --no-recurse-submodules origin "+refs/heads/$HEAD_REF:refs/remotes/origin/$HEAD_REF"
128128
129129
git checkout "origin/$HEAD_REF"
130130
@@ -266,11 +266,11 @@ jobs:
266266
267267
git config --global user.name "pulumi-bot"
268268
269-
# Stash local changes and check out the PR's branch directly.
269+
# Stash local changes and check out the PR's branch directly, fetching only that ref so submodule recursion never sees gitlinks from unrelated branches.
270270
271271
git stash
272272
273-
git fetch
273+
git fetch --no-recurse-submodules origin "+refs/heads/$HEAD_REF:refs/remotes/origin/$HEAD_REF"
274274
275275
git checkout "origin/$HEAD_REF"
276276

provider-ci/test-providers/docker-build/.github/workflows/run-acceptance-tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,11 @@ jobs:
178178
179179
git config --global user.name "pulumi-bot"
180180
181-
# Stash local changes and check out the PR's branch directly.
181+
# Stash local changes and check out the PR's branch directly, fetching only that ref so submodule recursion never sees gitlinks from unrelated branches.
182182
183183
git stash
184184
185-
git fetch
185+
git fetch --no-recurse-submodules origin "+refs/heads/$HEAD_REF:refs/remotes/origin/$HEAD_REF"
186186
187187
git checkout "origin/$HEAD_REF"
188188
@@ -330,11 +330,11 @@ jobs:
330330
331331
git config --global user.name "pulumi-bot"
332332
333-
# Stash local changes and check out the PR's branch directly.
333+
# Stash local changes and check out the PR's branch directly, fetching only that ref so submodule recursion never sees gitlinks from unrelated branches.
334334
335335
git stash
336336
337-
git fetch
337+
git fetch --no-recurse-submodules origin "+refs/heads/$HEAD_REF:refs/remotes/origin/$HEAD_REF"
338338
339339
git checkout "origin/$HEAD_REF"
340340

provider-ci/test-providers/docker/.github/workflows/build_sdk.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,13 @@ jobs:
131131
git config --global user.email "bot@pulumi.com"
132132
git config --global user.name "pulumi-bot"
133133
134-
# Stash local changes and check out the PR's branch directly.
134+
# Stash local changes and check out the PR's branch directly. Fetch
135+
# only that ref: a bare fetch pulls every branch in the repo, and
136+
# on-demand submodule recursion then tries to resolve the submodule
137+
# gitlink of every commit it pulls, including long-dead branches
138+
# pointing at commits the submodule's remote no longer serves.
135139
git stash
136-
git fetch
140+
git fetch --no-recurse-submodules origin "+refs/heads/$HEAD_REF:refs/remotes/origin/$HEAD_REF"
137141
git checkout "origin/$HEAD_REF"
138142
139143
# Apply and add our changes, but don't commit any files we expect to

provider-ci/test-providers/eks/.github/workflows/build_sdk.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,13 @@ jobs:
128128
git config --global user.email "bot@pulumi.com"
129129
git config --global user.name "pulumi-bot"
130130
131-
# Stash local changes and check out the PR's branch directly.
131+
# Stash local changes and check out the PR's branch directly. Fetch
132+
# only that ref: a bare fetch pulls every branch in the repo, and
133+
# on-demand submodule recursion then tries to resolve the submodule
134+
# gitlink of every commit it pulls, including long-dead branches
135+
# pointing at commits the submodule's remote no longer serves.
132136
git stash
133-
git fetch
137+
git fetch --no-recurse-submodules origin "+refs/heads/$HEAD_REF:refs/remotes/origin/$HEAD_REF"
134138
git checkout "origin/$HEAD_REF"
135139
136140
# Apply and add our changes, but don't commit any files we expect to

provider-ci/test-providers/kubernetes-cert-manager/.github/workflows/run-acceptance-tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,11 @@ jobs:
173173
174174
git config --global user.name "pulumi-bot"
175175
176-
# Stash local changes and check out the PR's branch directly.
176+
# Stash local changes and check out the PR's branch directly, fetching only that ref so submodule recursion never sees gitlinks from unrelated branches.
177177
178178
git stash
179179
180-
git fetch
180+
git fetch --no-recurse-submodules origin "+refs/heads/$HEAD_REF:refs/remotes/origin/$HEAD_REF"
181181
182182
git checkout "origin/$HEAD_REF"
183183
@@ -322,11 +322,11 @@ jobs:
322322
323323
git config --global user.name "pulumi-bot"
324324
325-
# Stash local changes and check out the PR's branch directly.
325+
# Stash local changes and check out the PR's branch directly, fetching only that ref so submodule recursion never sees gitlinks from unrelated branches.
326326
327327
git stash
328328
329-
git fetch
329+
git fetch --no-recurse-submodules origin "+refs/heads/$HEAD_REF:refs/remotes/origin/$HEAD_REF"
330330
331331
git checkout "origin/$HEAD_REF"
332332

0 commit comments

Comments
 (0)