Skip to content

Commit 73e8a82

Browse files
dennisamelingdscho
authored andcommitted
git-artifacts: cache the build-installers artifact
It is a bit expensive to fetch just the git-sdk-64-build-installers artifact from Azure Pipelines and then to unpack it (takes some 6-7 minutes, typically). Let's cache it if possible. Signed-off-by: Dennis Ameling <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 00efb21 commit 73e8a82

File tree

1 file changed

+79
-10
lines changed

1 file changed

+79
-10
lines changed

.github/workflows/git-artifacts.yml

+79-10
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ env:
2424
jobs:
2525
bundle-artifacts:
2626
runs-on: windows-latest
27+
outputs:
28+
latest-sdk64-extra-build-id: ${{ steps.determine-latest-sdk64-extra-build-id.outputs.id }}
2729
steps:
2830
- name: Configure user
2931
shell: bash
@@ -34,15 +36,31 @@ jobs:
3436
git config --global user.name "$USER_NAME" &&
3537
git config --global user.email "$USER_EMAIL" &&
3638
echo "PACKAGER=$USER_NAME <$USER_EMAIL>" >>$GITHUB_ENV
39+
- name: Determine latest git-sdk-64-extra-artifacts build ID
40+
id: determine-latest-sdk64-extra-build-id
41+
shell: bash
42+
run: |
43+
urlbase=https://dev.azure.com/git-for-windows/git/_apis/build/builds
44+
id=$(curl "$urlbase?definitions=29&statusFilter=completed&resultFilter=succeeded&\$top=1" |
45+
jq -r '.value[0].id')
46+
47+
echo "Latest ID is ${id}"
48+
echo "::set-output name=id::$id"
49+
- name: Cache git-sdk-64-build-installers
50+
id: cache-sdk-build-installers
51+
uses: actions/cache@v2
52+
with:
53+
path: git-sdk-64-build-installers
54+
key: build-installers-64-${{ steps.determine-latest-sdk64-extra-build-id.outputs.id }}
3755
- name: Download git-sdk-64-build-installers
56+
if: steps.cache-sdk-build-installers.outputs.cache-hit != 'true'
3857
shell: bash
3958
run: |
4059
# Use Git Bash to download and unpack the artifact
4160
4261
## Get artifact
4362
urlbase=https://dev.azure.com/git-for-windows/git/_apis/build/builds
44-
id=$(curl "$urlbase?definitions=29&statusFilter=completed&resultFilter=succeeded&\$top=1" |
45-
jq -r '.value[0].id')
63+
id=${{ steps.determine-latest-sdk64-extra-build-id.outputs.id }}
4664
download_url=$(curl "$urlbase/$id/artifacts" |
4765
jq -r '.value[] | select(.name == "git-sdk-64-build-installers").resource.downloadUrl')
4866
@@ -54,7 +72,13 @@ jobs:
5472
shell: bash
5573
run: |
5674
d=git-sdk-64-build-installers/usr/src/build-extra &&
57-
git clone --single-branch -b main https://github.com/git-for-windows/build-extra $d
75+
if test ! -d $d/.git
76+
then
77+
git clone --single-branch -b main https://github.com/git-for-windows/build-extra $d
78+
else
79+
git -C $d fetch https://github.com/git-for-windows/build-extra main &&
80+
git -C $d switch -C main FETCH_HEAD
81+
fi
5882
- name: Prepare home directory for GPG signing
5983
if: env.GPGKEY != ''
6084
shell: bash
@@ -104,6 +128,8 @@ jobs:
104128
pkg:
105129
runs-on: windows-latest
106130
needs: bundle-artifacts
131+
outputs:
132+
latest-sdk64-extra-build-id: ${{ needs.bundle-artifacts.outputs.latest-sdk64-extra-build-id }}
107133
strategy:
108134
matrix:
109135
arch:
@@ -264,8 +290,15 @@ jobs:
264290
with:
265291
name: bundle-artifacts
266292
path: bundle-artifacts
267-
- name: Download git-sdk-64-build-installers
293+
- name: Cache git-sdk-64-build-installers
268294
if: env.SKIP != 'true' && matrix.arch.bitness == '64'
295+
id: cache-sdk64-build-installers
296+
uses: actions/cache@v2
297+
with:
298+
path: git-sdk-64-build-installers
299+
key: build-installers-64-${{ needs.pkg.outputs.latest-sdk64-extra-build-id }}
300+
- name: Download git-sdk-64-build-installers
301+
if: env.SKIP != 'true' && matrix.arch.bitness == '64' && steps.cache-sdk64-build-installers.outputs.cache-hit != 'true'
269302
shell: bash
270303
run: |
271304
# Use Git Bash to download and unpack the artifact
@@ -280,16 +313,33 @@ jobs:
280313
281314
## Unpack artifact
282315
unzip artifacts.zip
283-
- name: Download git-sdk-32-build-installers
316+
- name: Determine latest git-sdk-32-extra-artifacts build ID
284317
if: env.SKIP != 'true' && matrix.arch.bitness == '32'
318+
id: determine-latest-sdk32-extra-build-id
319+
shell: bash
320+
run: |
321+
urlbase=https://dev.azure.com/git-for-windows/git/_apis/build/builds
322+
id=$(curl "$urlbase?definitions=30&statusFilter=completed&resultFilter=succeeded&\$top=1" |
323+
jq -r '.value[0].id')
324+
325+
echo "Latest ID is ${id}"
326+
echo "::set-output name=id::$id"
327+
- name: Cache git-sdk-32-build-installers
328+
if: env.SKIP != 'true' && matrix.arch.bitness == '32'
329+
id: cache-sdk32-build-installers
330+
uses: actions/cache@v2
331+
with:
332+
path: git-sdk-32-build-installers
333+
key: build-installers-32-${{ steps.determine-latest-sdk32-extra-build-id.outputs.id }}
334+
- name: Download git-sdk-32-build-installers
335+
if: env.SKIP != 'true' && matrix.arch.bitness == '32' && steps.cache-sdk32-build-installers.outputs.cache-hit != 'true'
285336
shell: bash
286337
run: |
287338
# Use Git Bash to download and unpack the artifact
288339
289340
## Get artifact
290341
urlbase=https://dev.azure.com/git-for-windows/git/_apis/build/builds
291-
id=$(curl "$urlbase?definitions=30&statusFilter=completed&resultFilter=succeeded&\$top=1" |
292-
jq -r '.value[0].id')
342+
id=${{ steps.determine-latest-sdk32-extra-build-id.outputs.id }}
293343
download_url=$(curl "$urlbase/$id/artifacts" |
294344
jq -r '.value[] | select(.name == "git-sdk-32-build-installers").resource.downloadUrl')
295345
@@ -302,7 +352,13 @@ jobs:
302352
shell: bash
303353
run: |
304354
d=git-sdk-${{matrix.arch.bitness}}-build-installers/usr/src/build-extra &&
305-
git clone --single-branch -b main https://github.com/git-for-windows/build-extra $d &&
355+
if test ! -d $d/.git
356+
then
357+
git clone --single-branch -b main https://github.com/git-for-windows/build-extra $d
358+
else
359+
git -C $d fetch https://github.com/git-for-windows/build-extra main &&
360+
git -C $d switch -C main FETCH_HEAD
361+
fi &&
306362
git -C $d pull "$PWD"/bundle-artifacts/build-extra.bundle main
307363
- name: Prepare home directory for code-signing
308364
env:
@@ -376,8 +432,15 @@ jobs:
376432
with:
377433
name: bundle-artifacts
378434
path: bundle-artifacts
379-
- name: Download git-sdk-64-build-installers
435+
- name: Cache git-sdk-64-build-installers
380436
if: env.SKIP != 'true'
437+
id: cache-sdk-build-installers
438+
uses: actions/cache@v2
439+
with:
440+
path: git-sdk-64-build-installers
441+
key: build-installers-64-${{ needs.pkg.outputs.latest-sdk64-extra-build-id }}
442+
- name: Download git-sdk-64-build-installers
443+
if: env.SKIP != 'true' && steps.cache-sdk-build-installers.outputs.cache-hit != 'true'
381444
shell: bash
382445
run: |
383446
# Use Git Bash to download and unpack the artifact
@@ -397,7 +460,13 @@ jobs:
397460
shell: bash
398461
run: |
399462
d=git-sdk-64-build-installers/usr/src/build-extra &&
400-
git clone --single-branch -b main https://github.com/git-for-windows/build-extra $d &&
463+
if test ! -d $d/.git
464+
then
465+
git clone --single-branch -b main https://github.com/git-for-windows/build-extra $d
466+
else
467+
git -C $d fetch https://github.com/git-for-windows/build-extra main &&
468+
git -C $d switch -C main FETCH_HEAD
469+
fi &&
401470
git -C $d pull "$PWD"/bundle-artifacts/build-extra.bundle main
402471
- uses: nuget/setup-nuget@v1
403472
if: env.SKIP != 'true'

0 commit comments

Comments
 (0)