Skip to content

Commit 158bd31

Browse files
committed
ci: save caches on main only by default (#5020)
1 parent a213b36 commit 158bd31

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
with:
3434
python-version: ${{ inputs.python-version }}
3535
architecture: ${{ inputs.python-architecture }}
36-
check-latest: ${{ startsWith(inputs.python-version, 'pypy') }} # PyPy can have FFI changes within Python versions, which creates pain in CI
36+
check-latest: ${{ startsWith(inputs.python-version, 'pypy') }} # PyPy can have FFI changes within Python versions, which creates pain in CI
3737

3838
- name: Install nox
3939
run: python -m pip install --upgrade pip && pip install nox
@@ -52,7 +52,7 @@ jobs:
5252

5353
- uses: Swatinem/rust-cache@v2
5454
with:
55-
save-if: ${{ github.event_name != 'merge_group' }}
55+
save-if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }}
5656

5757
- if: inputs.os == 'ubuntu-latest'
5858
name: Prepare LD_LIBRARY_PATH (Ubuntu only)

.github/workflows/ci.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
python-version: "3.12"
7272
- uses: Swatinem/rust-cache@v2
7373
with:
74-
save-if: ${{ github.event_name != 'merge_group' }}
74+
save-if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }}
7575
- run: python -m pip install --upgrade pip && pip install nox
7676
# This is a smoke test to confirm that CI will run on MSRV (including dev dependencies)
7777
- name: Check with MSRV package versions
@@ -157,7 +157,7 @@ jobs:
157157
architecture: ${{ matrix.platform.python-architecture }}
158158
- uses: Swatinem/rust-cache@v2
159159
with:
160-
save-if: ${{ github.event_name != 'merge_group' }}
160+
save-if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }}
161161
- run: python -m pip install --upgrade pip && pip install nox
162162
- run: nox -s clippy-all
163163
env:
@@ -413,7 +413,7 @@ jobs:
413413
python-version: "3.12.4"
414414
- uses: Swatinem/rust-cache@v2
415415
with:
416-
save-if: ${{ github.event_name != 'merge_group' }}
416+
save-if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }}
417417
- uses: dtolnay/rust-toolchain@stable
418418
- uses: taiki-e/install-action@valgrind
419419
- run: python -m pip install --upgrade pip && pip install nox
@@ -434,7 +434,7 @@ jobs:
434434
python-version: "3.12"
435435
- uses: Swatinem/rust-cache@v2
436436
with:
437-
save-if: ${{ github.event_name != 'merge_group' }}
437+
save-if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }}
438438
- uses: dtolnay/rust-toolchain@nightly
439439
with:
440440
components: rust-src
@@ -456,7 +456,7 @@ jobs:
456456
python-version: "3.12"
457457
- uses: Swatinem/rust-cache@v2
458458
with:
459-
save-if: ${{ github.event_name != 'merge_group' }}
459+
save-if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }}
460460
- uses: dtolnay/rust-toolchain@nightly
461461
with:
462462
components: rust-src
@@ -477,7 +477,7 @@ jobs:
477477
python-version: "3.12"
478478
- uses: Swatinem/rust-cache@v2
479479
with:
480-
save-if: ${{ github.event_name != 'merge_group' }}
480+
save-if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }}
481481
- uses: dtolnay/rust-toolchain@stable
482482
with:
483483
components: llvm-tools-preview,rust-src
@@ -520,14 +520,14 @@ jobs:
520520
key: emscripten-${{ hashFiles('emscripten/*') }}-${{ hashFiles('noxfile.py') }}-${{ steps.setup-python.outputs.python-path }}
521521
- uses: Swatinem/rust-cache@v2
522522
with:
523-
save-if: ${{ github.event_name != 'merge_group' }}
523+
save-if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }}
524524
- name: Build
525525
if: steps.cache.outputs.cache-hit != 'true'
526526
run: nox -s build-emscripten
527527
- name: Test
528528
run: nox -s test-emscripten
529529
- uses: actions/cache/save@v4
530-
if: ${{ github.event_name != 'merge_group' }}
530+
if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }}
531531
with:
532532
path: |
533533
.nox/emscripten
@@ -541,7 +541,7 @@ jobs:
541541
- uses: actions/checkout@v4
542542
- uses: Swatinem/rust-cache@v2
543543
with:
544-
save-if: ${{ github.event_name != 'merge_group' }}
544+
save-if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }}
545545
- uses: dtolnay/rust-toolchain@stable
546546
with:
547547
components: rust-src
@@ -588,7 +588,7 @@ jobs:
588588
- uses: actions/checkout@v4
589589
- uses: Swatinem/rust-cache@v2
590590
with:
591-
save-if: ${{ github.event_name != 'merge_group' }}
591+
save-if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }}
592592
- uses: dtolnay/rust-toolchain@stable
593593
with:
594594
components: rust-src
@@ -625,7 +625,7 @@ jobs:
625625
python-version: "3.12"
626626
- uses: Swatinem/rust-cache@v2
627627
with:
628-
save-if: ${{ github.event_name != 'merge_group' }}
628+
save-if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }}
629629
- uses: dtolnay/rust-toolchain@stable
630630
- run: python3 -m pip install --upgrade pip && pip install nox
631631
- run: python3 -m nox -s test-version-limits
@@ -649,7 +649,7 @@ jobs:
649649
python-version: "3.12"
650650
- uses: Swatinem/rust-cache@v2
651651
with:
652-
save-if: ${{ github.event_name != 'merge_group' }}
652+
save-if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }}
653653
- uses: dtolnay/rust-toolchain@master
654654
with:
655655
toolchain: stable
@@ -701,7 +701,7 @@ jobs:
701701
- uses: Swatinem/rust-cache@v2
702702
with:
703703
workspaces: examples/maturin-starter
704-
save-if: ${{ github.event_name != 'merge_group' }}
704+
save-if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }}
705705
key: ${{ matrix.target }}
706706
- name: Setup cross-compiler
707707
if: ${{ matrix.target == 'x86_64-pc-windows-gnu' }}
@@ -731,7 +731,7 @@ jobs:
731731
- uses: Swatinem/rust-cache@v2
732732
with:
733733
workspaces: examples/maturin-starter
734-
save-if: ${{ github.event_name != 'merge_group' }}
734+
save-if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }}
735735
- uses: actions/cache/restore@v4
736736
with:
737737
# https://github.com/PyO3/maturin/discussions/1953

0 commit comments

Comments
 (0)