Skip to content

Commit 6513474

Browse files
authored
GH-50191: [CI][Python] Switch caching to apache/infrastructure-actions/stash (#50192)
### Rationale for this change `apache/infrastructure-actions/stash` benefits from much greater size limits than `actions/cache`, so our compilation cache stands a greater chance of not being evicted by the next time a build runs. ### Are these changes tested? By the affected CI jobs. ### Are there any user-facing changes? No. * GitHub Issue: #50191 Authored-by: Antoine Pitrou <antoine@python.org> Signed-off-by: Antoine Pitrou <antoine@python.org>
1 parent 46bb919 commit 6513474

1 file changed

Lines changed: 32 additions & 21 deletions

File tree

.github/workflows/python.yml

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -72,30 +72,25 @@ jobs:
7272
- conda-python-3.12-no-numpy
7373
include:
7474
- name: conda-python-docs
75-
cache: conda-python-3.11
7675
image: conda-python-docs
7776
title: AMD64 Conda Python 3.11 Sphinx & Numpydoc
7877
python: "3.11"
7978
- name: conda-python-3.11-nopandas
80-
cache: conda-python-3.11
8179
image: conda-python
8280
title: AMD64 Conda Python 3.11 Without Pandas
8381
python: "3.11"
8482
- name: conda-python-3.10-pandas-1.3.4
85-
cache: conda-python-3.10
8683
image: conda-python-pandas
8784
title: AMD64 Conda Python 3.10 Pandas 1.3.4
8885
python: "3.10"
8986
pandas: "1.3.4"
9087
numpy: "1.21.2"
9188
- name: conda-python-3.13-pandas-latest
92-
cache: conda-python-3.13
9389
image: conda-python-pandas
9490
title: AMD64 Conda Python 3.13 Pandas latest
9591
python: "3.13"
9692
pandas: latest
9793
- name: conda-python-3.12-no-numpy
98-
cache: conda-python-3.12
9994
image: conda-python-no-numpy
10095
title: AMD64 Conda Python 3.12 without NumPy
10196
python: "3.12"
@@ -111,12 +106,11 @@ jobs:
111106
persist-credentials: false
112107
fetch-depth: 0
113108
submodules: recursive
114-
- name: Cache Docker Volumes
115-
uses: actions/cache@v5
109+
- name: Restore Docker Volumes
110+
uses: apache/infrastructure-actions/stash/restore@0ba14156c9f4c3cfbe4b0c9f36339ab0f8d81e53
116111
with:
117112
path: .docker
118-
key: ${{ matrix.cache }}-${{ hashFiles('cpp/**') }}
119-
restore-keys: ${{ matrix.cache }}-
113+
key: python-${{ matrix.name }}
120114
- name: Setup Python
121115
uses: actions/setup-python@v6
122116
with:
@@ -130,6 +124,14 @@ jobs:
130124
run: |
131125
source ci/scripts/util_enable_core_dumps.sh
132126
archery docker run ${{ matrix.image }}
127+
- name: Save Docker Volumes
128+
if: ${{ !cancelled() }}
129+
continue-on-error: true
130+
uses: apache/infrastructure-actions/stash/save@0ba14156c9f4c3cfbe4b0c9f36339ab0f8d81e53
131+
with:
132+
path: .docker
133+
key: python-${{ matrix.name }}
134+
include-hidden-files: true
133135
- name: Docker Push
134136
if: >-
135137
success() &&
@@ -216,12 +218,11 @@ jobs:
216218
id: ccache-info
217219
shell: bash
218220
run: echo "cache-dir=$(ccache --get-config cache_dir)" >> $GITHUB_OUTPUT
219-
- name: Cache ccache
220-
uses: actions/cache@v5
221+
- name: Restore ccache
222+
uses: apache/infrastructure-actions/stash/restore@0ba14156c9f4c3cfbe4b0c9f36339ab0f8d81e53
221223
with:
222224
path: ${{ steps.ccache-info.outputs.cache-dir }}
223-
key: python-ccache-macos-${{ matrix.macos-version }}-${{ hashFiles('cpp/**', 'python/**') }}
224-
restore-keys: python-ccache-macos-${{ matrix.macos-version }}-
225+
key: python-ccache-macos-${{ matrix.macos-version }}
225226
- name: Build
226227
shell: bash
227228
run: |
@@ -242,6 +243,13 @@ jobs:
242243
python -m pip install wheel
243244
ci/scripts/cpp_build.sh $(pwd) $(pwd)/build
244245
ci/scripts/python_build.sh $(pwd) $(pwd)/build
246+
- name: Save ccache
247+
if: ${{ !cancelled() }}
248+
continue-on-error: true
249+
uses: apache/infrastructure-actions/stash/save@0ba14156c9f4c3cfbe4b0c9f36339ab0f8d81e53
250+
with:
251+
path: ${{ steps.ccache-info.outputs.cache-dir }}
252+
key: python-ccache-macos-${{ matrix.macos-version }}
245253
- name: Test
246254
shell: bash
247255
run: ci/scripts/python_test.sh $(pwd) $(pwd)/build
@@ -252,6 +260,7 @@ jobs:
252260
if: ${{ !contains(github.event.pull_request.title, 'WIP') }}
253261
timeout-minutes: 60
254262
env:
263+
CCACHE_DIR: /ccache
255264
PYTHON_CMD: "py -3.13"
256265
steps:
257266
- name: Disable Crash Dialogs
@@ -284,23 +293,25 @@ jobs:
284293
id: path-info
285294
shell: bash
286295
run: |
287-
echo "CCACHE_DIR=$(ccache --get-config cache_dir)" >> $GITHUB_ENV
288296
echo "usr-windows-dir="$(cygpath --absolute --windows /usr)"" >> $GITHUB_OUTPUT
289-
- name: Cache ccache
290-
uses: actions/cache@v5
297+
- name: Restore ccache
298+
uses: apache/infrastructure-actions/stash/restore@0ba14156c9f4c3cfbe4b0c9f36339ab0f8d81e53
291299
with:
292300
path: ${{ env.CCACHE_DIR }}
293-
key: python-ccache-windows-${{ env.CACHE_VERSION }}-${{ hashFiles('cpp/**') }}
294-
restore-keys: python-ccache-windows-${{ env.CACHE_VERSION }}-
295-
env:
296-
# We can invalidate the current cache by updating this.
297-
CACHE_VERSION: "2025-09-16.1"
301+
key: python-ccache-windows
298302
- name: Build Arrow C++ and PyArrow
299303
shell: cmd
300304
env:
301305
USR_WINDOWS_DIR: ${{ steps.path-info.outputs.usr-windows-dir }}
302306
run: |
303307
call "ci\scripts\python_build.bat" %cd% "%USR_WINDOWS_DIR%"
308+
- name: Save ccache
309+
if: ${{ !cancelled() }}
310+
continue-on-error: true
311+
uses: apache/infrastructure-actions/stash/save@0ba14156c9f4c3cfbe4b0c9f36339ab0f8d81e53
312+
with:
313+
path: ${{ env.CCACHE_DIR }}
314+
key: python-ccache-windows
304315
- name: Test PyArrow
305316
shell: cmd
306317
run: |

0 commit comments

Comments
 (0)