Skip to content

Commit d8c117a

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 f4e2a00 commit d8c117a

File tree

1 file changed

+79
-10
lines changed

1 file changed

+79
-10
lines changed

.github/workflows/git-artifacts.yml

Lines changed: 79 additions & 10 deletions
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:
@@ -262,8 +288,15 @@ jobs:
262288
with:
263289
name: bundle-artifacts
264290
path: bundle-artifacts
265-
- name: Download git-sdk-64-build-installers
291+
- name: Cache git-sdk-64-build-installers
266292
if: env.SKIP != 'true' && matrix.arch.bitness == '64'
293+
id: cache-sdk64-build-installers
294+
uses: actions/cache@v2
295+
with:
296+
path: git-sdk-64-build-installers
297+
key: build-installers-64-${{ needs.pkg.outputs.latest-sdk64-extra-build-id }}
298+
- name: Download git-sdk-64-build-installers
299+
if: env.SKIP != 'true' && matrix.arch.bitness == '64' && steps.cache-sdk64-build-installers.outputs.cache-hit != 'true'
267300
shell: bash
268301
run: |
269302
# Use Git Bash to download and unpack the artifact
@@ -278,16 +311,33 @@ jobs:
278311
279312
## Unpack artifact
280313
unzip artifacts.zip
281-
- name: Download git-sdk-32-build-installers
314+
- name: Determine latest git-sdk-32-extra-artifacts build ID
282315
if: env.SKIP != 'true' && matrix.arch.bitness == '32'
316+
id: determine-latest-sdk32-extra-build-id
317+
shell: bash
318+
run: |
319+
urlbase=https://dev.azure.com/git-for-windows/git/_apis/build/builds
320+
id=$(curl "$urlbase?definitions=30&statusFilter=completed&resultFilter=succeeded&\$top=1" |
321+
jq -r '.value[0].id')
322+
323+
echo "Latest ID is ${id}"
324+
echo "::set-output name=id::$id"
325+
- name: Cache git-sdk-32-build-installers
326+
if: env.SKIP != 'true' && matrix.arch.bitness == '32'
327+
id: cache-sdk32-build-installers
328+
uses: actions/cache@v2
329+
with:
330+
path: git-sdk-32-build-installers
331+
key: build-installers-32-${{ steps.determine-latest-sdk32-extra-build-id.outputs.id }}
332+
- name: Download git-sdk-32-build-installers
333+
if: env.SKIP != 'true' && matrix.arch.bitness == '32' && steps.cache-sdk32-build-installers.outputs.cache-hit != 'true'
283334
shell: bash
284335
run: |
285336
# Use Git Bash to download and unpack the artifact
286337
287338
## Get artifact
288339
urlbase=https://dev.azure.com/git-for-windows/git/_apis/build/builds
289-
id=$(curl "$urlbase?definitions=30&statusFilter=completed&resultFilter=succeeded&\$top=1" |
290-
jq -r '.value[0].id')
340+
id=${{ steps.determine-latest-sdk32-extra-build-id.outputs.id }}
291341
download_url=$(curl "$urlbase/$id/artifacts" |
292342
jq -r '.value[] | select(.name == "git-sdk-32-build-installers").resource.downloadUrl')
293343
@@ -300,7 +350,13 @@ jobs:
300350
shell: bash
301351
run: |
302352
d=git-sdk-${{matrix.arch.bitness}}-build-installers/usr/src/build-extra &&
303-
git clone --single-branch -b main https://github.com/git-for-windows/build-extra $d &&
353+
if test ! -d $d/.git
354+
then
355+
git clone --single-branch -b main https://github.com/git-for-windows/build-extra $d
356+
else
357+
git -C $d fetch https://github.com/git-for-windows/build-extra main &&
358+
git -C $d switch -C main FETCH_HEAD
359+
fi &&
304360
git -C $d pull "$PWD"/bundle-artifacts/build-extra.bundle main
305361
- name: Prepare home directory for code-signing
306362
env:
@@ -374,8 +430,15 @@ jobs:
374430
with:
375431
name: bundle-artifacts
376432
path: bundle-artifacts
377-
- name: Download git-sdk-64-build-installers
433+
- name: Cache git-sdk-64-build-installers
378434
if: env.SKIP != 'true'
435+
id: cache-sdk-build-installers
436+
uses: actions/cache@v2
437+
with:
438+
path: git-sdk-64-build-installers
439+
key: build-installers-64-${{ needs.pkg.outputs.latest-sdk64-extra-build-id }}
440+
- name: Download git-sdk-64-build-installers
441+
if: env.SKIP != 'true' && steps.cache-sdk-build-installers.outputs.cache-hit != 'true'
379442
shell: bash
380443
run: |
381444
# Use Git Bash to download and unpack the artifact
@@ -395,7 +458,13 @@ jobs:
395458
shell: bash
396459
run: |
397460
d=git-sdk-64-build-installers/usr/src/build-extra &&
398-
git clone --single-branch -b main https://github.com/git-for-windows/build-extra $d &&
461+
if test ! -d $d/.git
462+
then
463+
git clone --single-branch -b main https://github.com/git-for-windows/build-extra $d
464+
else
465+
git -C $d fetch https://github.com/git-for-windows/build-extra main &&
466+
git -C $d switch -C main FETCH_HEAD
467+
fi &&
399468
git -C $d pull "$PWD"/bundle-artifacts/build-extra.bundle main
400469
- uses: nuget/setup-nuget@v1
401470
if: env.SKIP != 'true'

0 commit comments

Comments
 (0)