Skip to content

Commit 8f01e87

Browse files
committed
apacheGH-50283: [CI][Ruby] Switch caching to apache/infrastructure-actions/stash
1 parent 85d0d9d commit 8f01e87

2 files changed

Lines changed: 55 additions & 28 deletions

File tree

.github/workflows/ruby.yml

Lines changed: 53 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,11 @@ jobs:
8686
persist-credentials: false
8787
fetch-depth: 0
8888
submodules: recursive
89-
- name: Cache Docker Volumes
90-
uses: actions/cache@v5
89+
- name: Restore Docker Volumes
90+
uses: apache/infrastructure-actions/stash/restore@0ba14156c9f4c3cfbe4b0c9f36339ab0f8d81e53
9191
with:
9292
path: .docker
93-
key: ubuntu-${{ matrix.ubuntu }}-ruby-${{ hashFiles('cpp/**') }}
94-
restore-keys: ubuntu-${{ matrix.ubuntu }}-ruby-
93+
key: ruby-ubuntu-${{ matrix.ubuntu }}
9594
- name: Setup Python
9695
uses: actions/setup-python@v6
9796
with:
@@ -112,6 +111,14 @@ jobs:
112111
-e Protobuf_SOURCE=BUNDLED \
113112
-e gRPC_SOURCE=BUNDLED \
114113
ubuntu-ruby
114+
- name: Save Docker Volumes
115+
if: ${{ !cancelled() }}
116+
continue-on-error: true
117+
uses: apache/infrastructure-actions/stash/save@0ba14156c9f4c3cfbe4b0c9f36339ab0f8d81e53
118+
with:
119+
path: .docker
120+
key: ruby-ubuntu-${{ matrix.ubuntu }}
121+
include-hidden-files: true
115122
- name: Docker Push
116123
if: >-
117124
success() &&
@@ -181,20 +188,26 @@ jobs:
181188
ci/scripts/ccache_setup.sh
182189
- name: ccache info
183190
id: ccache-info
184-
run: |
185-
echo "cache-dir=$(ccache --get-config cache_dir)" >> $GITHUB_OUTPUT
186-
- name: Cache ccache
187-
uses: actions/cache@v5
191+
shell: bash
192+
run: echo "cache-dir=$(ccache --get-config cache_dir)" >> $GITHUB_OUTPUT
193+
- name: Restore ccache
194+
uses: apache/infrastructure-actions/stash/restore@0ba14156c9f4c3cfbe4b0c9f36339ab0f8d81e53
188195
with:
189196
path: ${{ steps.ccache-info.outputs.cache-dir }}
190-
key: ruby-ccache-macos-${{ hashFiles('cpp/**') }}
191-
restore-keys: ruby-ccache-macos-
197+
key: ruby-ccache-macos
192198
- name: Build C++
193199
run: |
194200
ci/scripts/cpp_build.sh $(pwd) $(pwd)/build
195201
- name: Build GLib
196202
run: |
197203
ci/scripts/c_glib_build.sh $(pwd) $(pwd)/build
204+
- name: Save ccache
205+
if: ${{ !cancelled() }}
206+
continue-on-error: true
207+
uses: apache/infrastructure-actions/stash/save@0ba14156c9f4c3cfbe4b0c9f36339ab0f8d81e53
208+
with:
209+
path: ${{ steps.ccache-info.outputs.cache-dir }}
210+
key: ruby-ccache-macos
198211
- name: Test GLib
199212
shell: bash
200213
run: ci/scripts/c_glib_test.sh $(pwd) $(pwd)/build
@@ -263,12 +276,15 @@ jobs:
263276
- name: Setup MSYS2
264277
run: |
265278
ridk exec bash ci\scripts\msys2_setup.sh ruby
266-
- name: Cache ccache
267-
uses: actions/cache@v5
279+
- name: Restore ccache
280+
uses: apache/infrastructure-actions/stash/restore@0ba14156c9f4c3cfbe4b0c9f36339ab0f8d81e53
268281
with:
269-
path: ccache
270-
key: ruby-ccache-ucrt${{ matrix.mingw-n-bits }}-${{ hashFiles('cpp/**') }}
271-
restore-keys: ruby-ccache-ucrt${{ matrix.mingw-n-bits }}-
282+
# CCACHE_DIR is set by `msys2_setup.sh`
283+
path: ${{ env.CCACHE_DIR }}
284+
key: ruby-ccache-ucrt${{ matrix.mingw-n-bits }}
285+
- name: Show ccache config
286+
run: |
287+
ccache --show-config
272288
- name: Build C++
273289
run: |
274290
$Env:CMAKE_BUILD_PARALLEL_LEVEL = $Env:NUMBER_OF_PROCESSORS
@@ -282,6 +298,13 @@ jobs:
282298
$build_dir = "$(ridk exec cygpath --unix "$(Get-Location)\build")"
283299
$ErrorActionPreference = "Continue"
284300
ridk exec bash ci\scripts\c_glib_build.sh "${source_dir}" "${build_dir}"
301+
- name: Save ccache
302+
if: ${{ !cancelled() }}
303+
continue-on-error: true
304+
uses: apache/infrastructure-actions/stash/save@0ba14156c9f4c3cfbe4b0c9f36339ab0f8d81e53
305+
with:
306+
path: ${{ env.CCACHE_DIR }}
307+
key: ruby-ccache-ucrt${{ matrix.mingw-n-bits }}
285308
- name: RubyGems info
286309
id: rubygems-info
287310
run: |
@@ -353,6 +376,7 @@ jobs:
353376
ARROW_WITH_SNAPPY: ON
354377
ARROW_WITH_ZLIB: ON
355378
ARROW_WITH_ZSTD: ON
379+
CCACHE_DIR: /ccache
356380
CMAKE_CXX_STANDARD: "20"
357381
CMAKE_GENERATOR: Ninja
358382
CMAKE_INSTALL_PREFIX: "${{ github.workspace }}/dist"
@@ -386,20 +410,14 @@ jobs:
386410
shell: bash
387411
run: |
388412
ci/scripts/ccache_setup.sh
389-
- name: ccache info
390-
id: ccache-info
391-
shell: bash
392-
run: |
393-
echo "cache-dir=$(ccache --get-config cache_dir)" >> $GITHUB_OUTPUT
394-
- name: Cache ccache
395-
uses: actions/cache@v5
413+
- name: Restore ccache
414+
uses: apache/infrastructure-actions/stash/restore@0ba14156c9f4c3cfbe4b0c9f36339ab0f8d81e53
396415
with:
397-
path: ${{ steps.ccache-info.outputs.cache-dir }}
398-
key: glib-ccache-msvc-${{ env.CACHE_VERSION }}-${{ hashFiles('cpp/**') }}
399-
restore-keys: glib-ccache-msvc-${{ env.CACHE_VERSION }}-
400-
env:
401-
# We can invalidate the current cache by updating this.
402-
CACHE_VERSION: "2024-05-09"
416+
path: ${{ env.CCACHE_DIR }}
417+
key: ruby-ccache-msvc
418+
- name: Show ccache config
419+
run: |
420+
ccache --show-config
403421
- name: Checkout vcpkg
404422
uses: actions/checkout@v7
405423
with:
@@ -442,3 +460,10 @@ jobs:
442460
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
443461
set VCPKG_ROOT=%VCPKG_ROOT_KEEP%
444462
bash -c "ci/scripts/c_glib_build.sh $(pwd) $(pwd)/build"
463+
- name: Save ccache
464+
if: ${{ !cancelled() }}
465+
continue-on-error: true
466+
uses: apache/infrastructure-actions/stash/save@0ba14156c9f4c3cfbe4b0c9f36339ab0f8d81e53
467+
with:
468+
path: ${{ env.CCACHE_DIR }}
469+
key: ruby-ccache-msvc

ci/scripts/cpp_build.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ if [ "${ARROW_ENABLE_THREADING:-ON}" = "OFF" ]; then
7575
fi
7676

7777
if [ "${ARROW_USE_CCACHE}" == "ON" ]; then
78+
echo -e "===\n=== ccache configuration\n==="
79+
ccache --show-config
7880
echo -e "===\n=== ccache statistics before build\n==="
7981
ccache -sv 2>/dev/null || ccache -s
8082
fi

0 commit comments

Comments
 (0)