Skip to content

Commit 9776486

Browse files
committed
store to ccache only from main
1 parent 50eb001 commit 9776486

3 files changed

Lines changed: 110 additions & 40 deletions

File tree

‎.github/workflows/cpp.yml‎

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,13 @@ jobs:
119119
persist-credentials: false
120120
fetch-depth: 0
121121
submodules: recursive
122-
- name: Cache Docker Volumes
123-
uses: actions/cache@v5
122+
- name: Restore Docker Volumes
123+
uses: actions/cache/restore@v5
124124
with:
125125
path: .docker
126-
key: ${{ matrix.image }}-${{ hashFiles('cpp/**') }}
127-
restore-keys: ${{ matrix.image }}-
126+
key: ${{ matrix.image }}-${{ github.run_id }}
127+
restore-keys: |
128+
${{ matrix.image }}-
128129
- name: Setup Python on hosted runner
129130
if: |
130131
matrix.runs-on == 'ubuntu-latest'
@@ -149,6 +150,12 @@ jobs:
149150
sudo sysctl -w vm.mmap_rnd_bits=28
150151
source ci/scripts/util_enable_core_dumps.sh
151152
archery docker run ${{ matrix.image }}
153+
- name: Save Docker Volumes
154+
if: github.ref == 'refs/heads/main'
155+
uses: actions/cache/save@v5
156+
with:
157+
path: .docker
158+
key: ${{ matrix.image }}-${{ github.run_id }}
152159
- name: Docker Push
153160
if: >-
154161
success() &&
@@ -254,12 +261,13 @@ jobs:
254261
id: ccache-info
255262
run: |
256263
echo "cache-dir=$(ccache --get-config cache_dir)" >> $GITHUB_OUTPUT
257-
- name: Cache ccache
258-
uses: actions/cache@v5
264+
- name: Restore ccache
265+
uses: actions/cache/restore@v5
259266
with:
260267
path: ${{ steps.ccache-info.outputs.cache-dir }}
261-
key: cpp-ccache-macos-${{ matrix.macos-version }}-${{ hashFiles('cpp/**') }}
262-
restore-keys: cpp-ccache-macos-${{ matrix.macos-version }}-
268+
key: cpp-ccache-macos-${{ matrix.macos-version }}-${{ github.run_id }}
269+
restore-keys: |
270+
cpp-ccache-macos-${{ matrix.macos-version }}-
263271
- name: Build
264272
run: |
265273
if [ "${{ matrix.macos-version }}" = "15-intel" ]; then
@@ -283,6 +291,12 @@ jobs:
283291
sudo sysctl -w kern.corefile=/tmp/core.%N.%P
284292
ulimit -c unlimited # must enable within the same shell
285293
ci/scripts/cpp_test.sh $(pwd) $(pwd)/build
294+
- name: Save ccache
295+
if: github.ref == 'refs/heads/main'
296+
uses: actions/cache/save@v5
297+
with:
298+
path: ${{ steps.ccache-info.outputs.cache-dir }}
299+
key: cpp-ccache-macos-${{ matrix.macos-version }}-${{ github.run_id }}
286300

287301
windows:
288302
if: ${{ !contains(github.event.pull_request.title, 'WIP') }}
@@ -361,12 +375,13 @@ jobs:
361375
- name: Setup MSYS2
362376
shell: msys2 {0}
363377
run: ci/scripts/msys2_setup.sh cpp
364-
- name: Cache ccache
365-
uses: actions/cache@v5
378+
- name: Restore ccache
379+
uses: actions/cache/restore@v5
366380
with:
367381
path: ccache
368-
key: cpp-ccache-${{ matrix.msystem_lower}}-${{ hashFiles('cpp/**') }}
369-
restore-keys: cpp-ccache-${{ matrix.msystem_lower}}-
382+
key: cpp-ccache-${{ matrix.msystem_lower}}-${{ github.run_id }}
383+
restore-keys: |
384+
cpp-ccache-${{ matrix.msystem_lower}}-
370385
- name: Build
371386
shell: msys2 {0}
372387
run: |
@@ -405,3 +420,9 @@ jobs:
405420
shell: msys2 {0}
406421
run: |
407422
ci/scripts/cpp_test.sh "$(pwd)" "$(pwd)/build"
423+
- name: Save ccache
424+
if: github.ref == 'refs/heads/main'
425+
uses: actions/cache/save@v5
426+
with:
427+
path: ccache
428+
key: cpp-ccache-${{ matrix.msystem_lower}}-${{ github.run_id }}

‎.github/workflows/cpp_extra.yml‎

Lines changed: 66 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,13 @@ jobs:
141141
persist-credentials: false
142142
fetch-depth: 0
143143
submodules: recursive
144-
- name: Cache Docker Volumes
145-
uses: actions/cache@v5
144+
- name: Restore Docker Volumes
145+
uses: actions/cache/restore@v5
146146
with:
147147
path: .docker
148-
key: extra-${{ matrix.image }}-${{ hashFiles('cpp/**') }}
149-
restore-keys: extra-${{ matrix.image }}-
148+
key: extra-${{ matrix.image }}-${{ github.run_id }}
149+
restore-keys: |
150+
extra-${{ matrix.image }}-
150151
- name: Setup Python
151152
uses: actions/setup-python@v6
152153
with:
@@ -169,6 +170,12 @@ jobs:
169170
done
170171
fi
171172
archery docker run ${{ matrix.run-options || '' }} ${{ matrix.image }}
173+
- name: Save Docker Volumes
174+
if: github.ref == 'refs/heads/main'
175+
uses: actions/cache/save@v5
176+
with:
177+
path: .docker
178+
key: extra-${{ matrix.image }}-${{ github.run_id }}
172179
- name: Docker Push
173180
if: >-
174181
success() &&
@@ -227,12 +234,13 @@ jobs:
227234
- name: Free up disk space
228235
run: |
229236
ci/scripts/util_free_space.sh
230-
- name: Cache Docker Volumes
231-
uses: actions/cache@v5
237+
- name: Restore Docker Volumes
238+
uses: actions/cache/restore@v5
232239
with:
233240
path: .docker
234-
key: jni-${{ matrix.platform.runs-on }}-${{ hashFiles('cpp/**') }}
235-
restore-keys: jni-${{ matrix.platform.runs-on }}-
241+
key: jni-${{ matrix.platform.runs-on }}-${{ github.run_id }}
242+
restore-keys: |
243+
jni-${{ matrix.platform.runs-on }}-
236244
- name: Setup Python
237245
uses: actions/setup-python@v6
238246
with:
@@ -248,6 +256,12 @@ jobs:
248256
run: |
249257
source ci/scripts/util_enable_core_dumps.sh
250258
archery docker run cpp-jni
259+
- name: Save Docker Volumes
260+
if: github.ref == 'refs/heads/main'
261+
uses: actions/cache/save@v5
262+
with:
263+
path: .docker
264+
key: jni-${{ matrix.platform.runs-on }}-${{ github.run_id }}
251265
- name: Docker Push
252266
if: >-
253267
success() &&
@@ -300,12 +314,13 @@ jobs:
300314
- name: Prepare ccache
301315
run: |
302316
echo "CCACHE_DIR=${PWD}/ccache" >> ${GITHUB_ENV}
303-
- name: Cache ccache
304-
uses: actions/cache@v5
317+
- name: Restore ccache
318+
uses: actions/cache/restore@v5
305319
with:
306320
path: ccache
307-
key: jni-macos-${{ hashFiles('cpp/**') }}
308-
restore-keys: jni-macos-
321+
key: jni-macos-${{ github.run_id }}
322+
restore-keys: |
323+
jni-macos-
309324
- name: CMake
310325
run: |
311326
cmake \
@@ -347,6 +362,12 @@ jobs:
347362
cmake --build cpp/examples/minimal_build.build
348363
cd cpp/examples/minimal_build
349364
../minimal_build.build/arrow-example
365+
- name: Save ccache
366+
if: github.ref == 'refs/heads/main'
367+
uses: actions/cache/save@v5
368+
with:
369+
path: ccache
370+
key: jni-macos-${{ github.run_id }}
350371

351372
odbc-linux:
352373
needs: check-labels
@@ -372,12 +393,13 @@ jobs:
372393
persist-credentials: false
373394
fetch-depth: 0
374395
submodules: recursive
375-
- name: Cache Docker Volumes
376-
uses: actions/cache@v5
396+
- name: Restore Docker Volumes
397+
uses: actions/cache/restore@v5
377398
with:
378399
path: .docker
379-
key: ubuntu-cpp-odbc-${{ hashFiles('cpp/**') }}
380-
restore-keys: ubuntu-cpp-odbc-
400+
key: ubuntu-cpp-odbc-${{ github.run_id }}
401+
restore-keys: |
402+
ubuntu-cpp-odbc-
381403
- name: Setup Python on hosted runner
382404
uses: actions/setup-python@v6
383405
with:
@@ -393,6 +415,12 @@ jobs:
393415
sudo sysctl -w vm.mmap_rnd_bits=28
394416
source ci/scripts/util_enable_core_dumps.sh
395417
archery docker run ubuntu-cpp-odbc
418+
- name: Save Docker Volumes
419+
if: github.ref == 'refs/heads/main'
420+
uses: actions/cache/save@v5
421+
with:
422+
path: .docker
423+
key: ubuntu-cpp-odbc-${{ github.run_id }}
396424
- name: Docker Push
397425
if: >-
398426
success() &&
@@ -464,12 +492,13 @@ jobs:
464492
id: ccache-info
465493
run: |
466494
echo "cache-dir=$(ccache --get-config cache_dir)" >> $GITHUB_OUTPUT
467-
- name: Cache ccache
468-
uses: actions/cache@v5.0.2
495+
- name: Restore ccache
496+
uses: actions/cache/restore@v5.0.2
469497
with:
470498
path: ${{ steps.ccache-info.outputs.cache-dir }}
471-
key: cpp-odbc-ccache-macos-${{ matrix.macos-version }}-${{ matrix.build-type }}-${{ hashFiles('cpp/**') }}
472-
restore-keys: cpp-odbc-ccache-macos-${{ matrix.macos-version }}-${{ matrix.build-type }}-
499+
key: cpp-odbc-ccache-macos-${{ matrix.macos-version }}-${{ matrix.build-type }}-${{ github.run_id }}
500+
restore-keys: |
501+
cpp-odbc-ccache-macos-${{ matrix.macos-version }}-${{ matrix.build-type }}-
473502
- name: Build
474503
run: |
475504
# Homebrew uses /usr/local as prefix. So packages
@@ -530,6 +559,12 @@ jobs:
530559
sudo mkdir -p /Library/ODBC
531560
sudo chown -R $USER /Library/ODBC
532561
ci/scripts/cpp_test.sh $(pwd) $(pwd)/build
562+
- name: Save ccache
563+
if: github.ref == 'refs/heads/main'
564+
uses: actions/cache/save@v5
565+
with:
566+
path: ${{ steps.ccache-info.outputs.cache-dir }}
567+
key: cpp-odbc-ccache-macos-${{ matrix.macos-version }}-${{ matrix.build-type }}-${{ github.run_id }}
533568

534569
odbc-msvc:
535570
needs: check-labels
@@ -589,12 +624,13 @@ jobs:
589624
shell: bash
590625
run: |
591626
echo "cache-dir=$(ccache --get-config cache_dir)" >> $GITHUB_OUTPUT
592-
- name: Cache ccache
593-
uses: actions/cache@v5
627+
- name: Restore ccache
628+
uses: actions/cache/restore@v5
594629
with:
595630
path: ${{ steps.ccache-info.outputs.cache-dir }}
596-
key: cpp-odbc-ccache-windows-x64-${{ hashFiles('cpp/**') }}
597-
restore-keys: cpp-odbc-ccache-windows-x64-
631+
key: cpp-odbc-ccache-windows-x64-${{ github.run_id }}
632+
restore-keys: |
633+
cpp-odbc-ccache-windows-x64-
598634
- name: Checkout vcpkg
599635
uses: actions/checkout@v6
600636
with:
@@ -697,6 +733,12 @@ jobs:
697733
698734
Write-Error "ODBC DLL not found"
699735
exit 1
736+
- name: Save ccache
737+
if: github.ref == 'refs/heads/main'
738+
uses: actions/cache/save@v5
739+
with:
740+
path: ${{ steps.ccache-info.outputs.cache-dir }}
741+
key: cpp-odbc-ccache-windows-x64-${{ github.run_id }}
700742

701743
odbc-nightly:
702744
needs: odbc-msvc

‎.github/workflows/cpp_windows.yml‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,13 @@ jobs:
107107
shell: bash
108108
run: |
109109
echo "cache-dir=$(ccache --get-config cache_dir)" >> $GITHUB_OUTPUT
110-
- name: Cache ccache
111-
uses: actions/cache@v5
110+
- name: Restore ccache
111+
uses: actions/cache/restore@v5
112112
with:
113113
path: ${{ steps.ccache-info.outputs.cache-dir }}
114-
key: cpp-ccache-windows-${{ inputs.arch }}-${{ hashFiles('cpp/**') }}
115-
restore-keys: cpp-ccache-windows-${{ inputs.arch }}-
114+
key: cpp-ccache-windows-${{ inputs.arch }}-${{ github.run_id }}
115+
restore-keys: |
116+
cpp-ccache-windows-${{ inputs.arch }}-
116117
- name: Build
117118
shell: cmd
118119
env:
@@ -130,3 +131,9 @@ jobs:
130131
# For ORC
131132
set TZDIR=%MSYS2_LOCATION%\usr\share\zoneinfo
132133
bash -c "ci/scripts/cpp_test.sh $(pwd) $(pwd)/build"
134+
- name: Save ccache
135+
if: github.ref == 'refs/heads/main'
136+
uses: actions/cache/save@v5
137+
with:
138+
path: ${{ steps.ccache-info.outputs.cache-dir }}
139+
key: cpp-ccache-windows-${{ inputs.arch }}-${{ github.run_id }}

0 commit comments

Comments
 (0)