Skip to content

Commit cc5904f

Browse files
committed
github: make cache key more precise
1 parent c2c90da commit cc5904f

File tree

1 file changed

+41
-26
lines changed

1 file changed

+41
-26
lines changed

.github/workflows/build.yml

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -70,82 +70,97 @@ jobs:
7070
shell: bash
7171
run: |
7272
[[ "$(xcode-select -p)" == "${{ env.BUILD_XCODE_PATH }}"* ]] || sudo xcode-select -s "${{ env.BUILD_XCODE_PATH }}"
73-
- name: Cache Sysroot
73+
- name: Check Cache
7474
id: cache-sysroot
75-
uses: actions/cache@v4
75+
uses: actions/cache/restore@v4
7676
with:
77-
path: sysroot-${{ matrix.platform }}-${{ matrix.arch }}
78-
key: ${{ matrix.platform }}-${{ matrix.arch }}-${{ hashFiles('scripts/build_dependencies.sh') }}-${{ hashFiles('patches/**') }}
79-
upload-chunk-size: 1048576 # 1 MiB
77+
path: ./sysroot-${{ matrix.platform }}-${{ matrix.arch }}
78+
key: ${{ matrix.platform }}-${{ matrix.arch }}-${{ hashFiles('scripts/build_dependencies.sh') }}-${{ hashFiles('patches/**') }}-${{ github.sha }}
79+
restore-keys: ${{ matrix.platform }}-${{ matrix.arch }}-${{ hashFiles('scripts/build_dependencies.sh') }}-${{ hashFiles('patches/**') }}
8080
lookup-only: true
8181
- name: Setup Path
8282
shell: bash
8383
run: |
8484
echo "/usr/local/opt/bison/bin:/opt/homebrew/opt/bison/bin" >> $GITHUB_PATH
8585
- name: Install Requirements
86-
if: (steps.cache-sysroot.outputs.cache-hit != 'true' || github.event.inputs.rebuild_sysroot == 'true') && needs.configuration.outputs.runner == env.RUNNER_IMAGE
86+
if: (steps.cache-sysroot.outputs.cache-matched-key == '' || github.event.inputs.rebuild_sysroot == 'true') && needs.configuration.outputs.runner == env.RUNNER_IMAGE
8787
run: |
8888
brew uninstall cmake
8989
brew install bison pkg-config gettext glib-utils libgpg-error nasm make meson
9090
pip3 install --user six pyparsing
9191
rm -f /usr/local/lib/pkgconfig/*.pc
9292
- name: Build Sysroot
93-
if: steps.cache-sysroot.outputs.cache-hit != 'true' || github.event.inputs.rebuild_sysroot == 'true'
93+
if: steps.cache-sysroot.outputs.cache-matched-key == '' || github.event.inputs.rebuild_sysroot == 'true'
9494
run: ./scripts/build_dependencies.sh -p ${{ matrix.platform }} -a ${{ matrix.arch }}
9595
env:
9696
NCPU: ${{ endsWith(matrix.platform, '-tci') && '1' || '0' }} # limit 1 CPU for TCI build due to memory issues, 0 = unlimited for other builds
9797
- name: Compress Sysroot
98-
if: steps.cache-sysroot.outputs.cache-hit != 'true' || github.event_name == 'release' || github.event.inputs.test_release == 'true'
98+
if: steps.cache-sysroot.outputs.cache-matched-key == '' || github.event_name == 'release' || github.event.inputs.test_release == 'true'
9999
run: tar -acf sysroot.tgz sysroot*
100100
- name: Upload Sysroot
101-
if: steps.cache-sysroot.outputs.cache-hit != 'true' || github.event_name == 'release' || github.event.inputs.test_release == 'true'
101+
if: steps.cache-sysroot.outputs.cache-matched-key == '' || github.event_name == 'release' || github.event.inputs.test_release == 'true'
102102
uses: actions/upload-artifact@v4
103103
with:
104104
name: Sysroot-${{ matrix.platform }}-${{ matrix.arch }}
105105
path: sysroot.tgz
106+
- name: Save Cache
107+
if: steps.cache-sysroot.outputs.cache-matched-key == ''
108+
uses: actions/cache/save@v4
109+
with:
110+
path: ./sysroot-${{ matrix.platform }}-${{ matrix.arch }}
111+
key: ${{ steps.cache-sysroot.outputs.cache-primary-key }}
112+
upload-chunk-size: 1048576 # 1 MiB
106113
build-sysroot-universal:
107114
name: Build Sysroot (Universal Mac)
108115
runs-on: ${{ fromJSON(needs.configuration.outputs.github-runner) }}
109116
needs: [configuration, build-sysroot]
110117
steps:
111118
- name: Checkout
112119
uses: actions/checkout@v3
113-
- name: Cache Sysroot (Universal Mac)
120+
- name: Check Cache (Universal Mac)
114121
id: cache-sysroot-universal
115-
uses: actions/cache@v4
122+
uses: actions/cache/restore@v4
116123
with:
117-
path: sysroot-macOS-arm64_x86_64
118-
key: macos-universal-${{ hashFiles('scripts/build_dependencies.sh', 'scripts/pack_dependencies.sh') }}-${{ hashFiles('patches/**') }}
124+
path: ./sysroot-macOS-arm64_x86_64
125+
key: macos-universal-${{ hashFiles('scripts/build_dependencies.sh', 'scripts/pack_dependencies.sh') }}-${{ hashFiles('patches/**') }}-${{ github.sha }}
126+
restore-keys: macos-universal-${{ hashFiles('scripts/build_dependencies.sh', 'scripts/pack_dependencies.sh') }}-${{ hashFiles('patches/**') }}
119127
lookup-only: true
120128
- name: Cache Sysroot (arm64)
121-
if: steps.cache-sysroot-universal.outputs.cache-hit != 'true'
129+
if: steps.cache-sysroot-universal.outputs.cache-matched-key == ''
122130
id: cache-sysroot-arm64
123-
uses: actions/cache@v4
131+
uses: actions/cache/restore@v4
124132
with:
125-
path: sysroot-macos-arm64
133+
path: ./sysroot-macos-arm64
126134
key: macos-arm64-${{ hashFiles('scripts/build_dependencies.sh') }}-${{ hashFiles('patches/**') }}
127135
fail-on-cache-miss: true
128136
- name: Cache Sysroot (x86_64)
129-
if: steps.cache-sysroot-universal.outputs.cache-hit != 'true'
137+
if: steps.cache-sysroot-universal.outputs.cache-matched-key == ''
130138
id: cache-sysroot-x86_64
131-
uses: actions/cache@v4
139+
uses: actions/cache/restore@v4
132140
with:
133-
path: sysroot-macos-x86_64
141+
path: ./sysroot-macos-x86_64
134142
key: macos-x86_64-${{ hashFiles('scripts/build_dependencies.sh') }}-${{ hashFiles('patches/**') }}
135143
fail-on-cache-miss: true
136144
- name: Pack Universal Sysroot
137-
if: steps.cache-sysroot-universal.outputs.cache-hit != 'true'
145+
if: steps.cache-sysroot-universal.outputs.cache-matched-key == ''
138146
run: |
139147
./scripts/pack_dependencies.sh . macos arm64 x86_64
140148
- name: Compress Sysroot
141-
if: steps.cache-sysroot-universal.outputs.cache-hit != 'true' || github.event_name == 'release' || github.event.inputs.test_release == 'true'
149+
if: steps.cache-sysroot-universal.outputs.cache-matched-key == '' || github.event_name == 'release' || github.event.inputs.test_release == 'true'
142150
run: tar -acf sysroot.tgz sysroot-macOS-arm64_x86_64
143151
- name: Upload Sysroot
144-
if: steps.cache-sysroot-universal.outputs.cache-hit != 'true' || github.event_name == 'release' || github.event.inputs.test_release == 'true'
152+
if: steps.cache-sysroot-universal.outputs.cache-matched-key == '' || github.event_name == 'release' || github.event.inputs.test_release == 'true'
145153
uses: actions/upload-artifact@v4
146154
with:
147155
name: Sysroot-macos-universal
148156
path: sysroot.tgz
157+
- name: Save Cache (Universal Mac)
158+
if: steps.cache-sysroot-universal.outputs.cache-matched-key == ''
159+
uses: actions/cache/save@v4
160+
with:
161+
path: ./sysroot-macOS-arm64_x86_64
162+
key: ${{ steps.cache-sysroot-universal.outputs.cache-primary-key }}
163+
upload-chunk-size: 1048576 # 1 MiB
149164
build-utm:
150165
name: Build UTM
151166
runs-on: ${{ fromJSON(needs.configuration.outputs.runner) }}
@@ -169,9 +184,9 @@ jobs:
169184
submodules: recursive
170185
- name: Cache Sysroot
171186
id: cache-sysroot
172-
uses: actions/cache@v4
187+
uses: actions/cache/restore@v4
173188
with:
174-
path: sysroot-${{ matrix.configuration.platform }}-${{ matrix.configuration.arch }}
189+
path: ./sysroot-${{ matrix.configuration.platform }}-${{ matrix.configuration.arch }}
175190
key: ${{ matrix.configuration.platform }}-${{ matrix.configuration.arch }}-${{ hashFiles('scripts/build_dependencies.sh') }}-${{ hashFiles('patches/**') }}
176191
fail-on-cache-miss: true
177192
- name: Setup Xcode
@@ -198,9 +213,9 @@ jobs:
198213
submodules: recursive
199214
- name: Cache Sysroot
200215
id: cache-sysroot
201-
uses: actions/cache@v4
216+
uses: actions/cache/restore@v4
202217
with:
203-
path: sysroot-macOS-arm64_x86_64
218+
path: ./sysroot-macOS-arm64_x86_64
204219
key: macos-universal-${{ hashFiles('scripts/build_dependencies.sh', 'scripts/pack_dependencies.sh') }}-${{ hashFiles('patches/**') }}
205220
fail-on-cache-miss: true
206221
- name: Setup Xcode

0 commit comments

Comments
 (0)