Skip to content

Commit 350b016

Browse files
authored
improvement(ci): check out same-repo pull requests through a git mirror (#8768)
A clone from GitHub took a minute or more for 1 in 10 checks jobs (up to 4 min), and with ~19 parallel jobs per run one slow clone set the run's pace. Same-repo pull requests now check out with useblacksmith/checkout, which keeps a git mirror on a sticky disk and fetches only new objects. Fork pull requests and pushes keep actions/checkout: the mirror is one disk per repository that job steps can write to, and Git does not re-hash objects read through alternates, so only runs that already share the pull_request caches share it.
1 parent 7b287b2 commit 350b016

1 file changed

Lines changed: 38 additions & 14 deletions

File tree

‎.github/workflows/checks.yml‎

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,18 @@ jobs:
7171
ENCRYPTION_KEY: '0000000000000000000000000000000000000000000000000000000000000000'
7272

7373
steps:
74-
- name: Checkout code
74+
# A same-repository pull request checks out through a git mirror on a sticky disk, so a slow
75+
# clone from GitHub (1 in 10 took a minute or more, up to 4) no longer sets the run's pace.
76+
# The mirror is one disk per repository that job steps can write to, so fork pull requests
77+
# and pushes, whose checks gate a deploy, keep the plain checkout: same trust split as the
78+
# setup action's caches.
79+
- &checkout-mirror
80+
name: Checkout code (mirror)
81+
if: github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork
82+
uses: useblacksmith/checkout@25227e61ff9dafe400e22fa487b673eac4e4409a # v1.8.1
83+
- &checkout-plain
84+
name: Checkout code
85+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork
7586
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
7687

7788
- name: Setup workspace
@@ -175,8 +186,8 @@ jobs:
175186
ENCRYPTION_KEY: '0000000000000000000000000000000000000000000000000000000000000000'
176187

177188
steps:
178-
- name: Checkout code
179-
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
189+
- *checkout-mirror
190+
- *checkout-plain
180191

181192
- name: Setup workspace
182193
uses: ./.github/actions/setup
@@ -213,8 +224,14 @@ jobs:
213224
outputs:
214225
changed: ${{ github.event_name != 'pull_request' || steps.diff.outputs.changed != 'false' }}
215226
steps:
216-
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
217-
if: github.event_name == 'pull_request'
227+
- name: Checkout code (mirror)
228+
if: github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork
229+
uses: useblacksmith/checkout@25227e61ff9dafe400e22fa487b673eac4e4409a # v1.8.1
230+
with:
231+
fetch-depth: 2
232+
- name: Checkout code
233+
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork
234+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
218235
with:
219236
fetch-depth: 2
220237
- name: Diff against the pull request's base
@@ -261,8 +278,8 @@ jobs:
261278
ENCRYPTION_KEY: '0000000000000000000000000000000000000000000000000000000000000000'
262279

263280
steps:
264-
- name: Checkout code
265-
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
281+
- *checkout-mirror
282+
- *checkout-plain
266283

267284
- name: Setup workspace
268285
uses: ./.github/actions/setup
@@ -423,7 +440,16 @@ jobs:
423440
# Worth stating because the failure was invisible for so long: the migration
424441
# audit read the resulting `git diff` failure as "no migrations changed" and
425442
# exited 0, so it had never actually run on a push build.
426-
- name: Checkout code
443+
# Same mirror/plain split as the integration job's checkout.
444+
- &checkout-mirror-depth2
445+
name: Checkout code (mirror)
446+
if: github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork
447+
uses: useblacksmith/checkout@25227e61ff9dafe400e22fa487b673eac4e4409a # v1.8.1
448+
with:
449+
fetch-depth: 2
450+
- &checkout-plain-depth2
451+
name: Checkout code
452+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork
427453
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
428454
with:
429455
fetch-depth: 2
@@ -573,10 +599,8 @@ jobs:
573599
shard: [1, 2]
574600

575601
steps:
576-
- name: Checkout code
577-
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
578-
with:
579-
fetch-depth: 2
602+
- *checkout-mirror-depth2
603+
- *checkout-plain-depth2
580604

581605
- name: Setup workspace
582606
uses: ./.github/actions/setup
@@ -627,8 +651,8 @@ jobs:
627651
timeout-minutes: 25
628652

629653
steps:
630-
- name: Checkout code
631-
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
654+
- *checkout-mirror
655+
- *checkout-plain
632656

633657
- name: Setup workspace
634658
uses: ./.github/actions/setup

0 commit comments

Comments
 (0)