Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/actions/save-ccache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Save ccache
description: >
Replaces the cache stored under the key instead of adding an entry per commit, so the
caches of the repository stay below its quota. The job needs the actions: write permission.

inputs:
key:
description: Cache key, the same one given to actions/cache/restore
required: true
path:
description: Directory of the ccache
default: .ccache

runs:
using: composite
steps:
- name: Delete the previous cache
shell: bash
env:
GH_TOKEN: ${{ github.token }}
CACHE_KEY: ${{ inputs.key }}
# cache keys are immutable, there is nothing to delete the first time
run: gh cache delete "$CACHE_KEY" --repo "$GITHUB_REPOSITORY" || true

- name: Save the cache
uses: actions/cache/save@v4
with:
path: ${{ inputs.path }}
key: ${{ inputs.key }}
10 changes: 5 additions & 5 deletions .github/workflows/build-deb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ concurrency:

permissions:
contents: read
actions: write # replace the ccache entries

jobs:
build:
Expand Down Expand Up @@ -130,7 +131,7 @@ jobs:
uses: actions/cache/restore@v4
with:
path: .ccache
key: ccache-deb-${{ matrix.name }}-${{ matrix.arch }}_${{ github.sha }}
key: ccache-deb-${{ matrix.name }}-${{ matrix.arch }}
restore-keys: |
ccache-deb-${{ matrix.name }}-${{ matrix.arch }}_

Expand All @@ -156,12 +157,11 @@ jobs:
bash -euxc "./docker/build.sh"

- name: Save ccache
# Pull requests only read the cache, pushes to main and manual runs populate it.
# Pull requests only read the cache, pushes to main and manual runs replace it.
if: ${{ !cancelled() && github.event_name != 'pull_request' }}
uses: actions/cache/save@v4
uses: ./.github/actions/save-ccache
with:
path: .ccache
key: ccache-deb-${{ matrix.name }}-${{ matrix.arch }}_${{ github.sha }}
key: ccache-deb-${{ matrix.name }}-${{ matrix.arch }}

- name: Upload deb package
uses: actions/upload-artifact@v4
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ concurrency:

permissions:
contents: read
actions: write # replace the ccache entries

jobs:
build:
Expand Down Expand Up @@ -65,7 +66,7 @@ jobs:
uses: actions/cache/restore@v4
with:
path: .ccache
key: ccache-${{ matrix.os }}_${{ github.sha }}
key: ccache-${{ matrix.os }}
restore-keys: |
ccache-${{ matrix.os }}_

Expand Down Expand Up @@ -105,12 +106,11 @@ jobs:
run: ccache --show-stats

- name: Save ccache
# Pull requests only read the cache, pushes to main and manual runs populate it.
# Pull requests only read the cache, pushes to main and manual runs replace it.
if: ${{ !cancelled() && github.event_name != 'pull_request' }}
uses: actions/cache/save@v4
uses: ./.github/actions/save-ccache
with:
path: .ccache
key: ccache-${{ matrix.os }}_${{ github.sha }}
key: ccache-${{ matrix.os }}

- name: Repair wheel with delocate
run: |
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ concurrency:

permissions:
contents: read
actions: write # replace the ccache entries

jobs:
msys2-mingw64:
Expand Down Expand Up @@ -149,7 +150,7 @@ jobs:
uses: actions/cache/restore@v4
with:
path: .ccache
key: ccache-windows_${{ github.sha }}
key: ccache-windows
restore-keys: |
ccache-windows_

Expand Down Expand Up @@ -194,12 +195,11 @@ jobs:
run: ccache --show-stats

- name: Save ccache
# Pull requests only read the cache, pushes to main and manual runs populate it.
# Pull requests only read the cache, pushes to main and manual runs replace it.
if: ${{ !cancelled() && github.event_name != 'pull_request' }}
uses: actions/cache/save@v4
uses: ./.github/actions/save-ccache
with:
path: .ccache
key: ccache-windows_${{ github.sha }}
key: ccache-windows

- name: Repair wheel with delvewheel
run: |
Expand Down
28 changes: 13 additions & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ concurrency:

permissions:
contents: read
actions: write # replace the ccache entries

jobs:
linux:
Expand Down Expand Up @@ -79,7 +80,7 @@ jobs:
uses: actions/cache/restore@v4
with:
path: .ccache
key: ccache-linux-test_${{ github.sha }}
key: ccache-linux-test
restore-keys: |
ccache-linux-test_

Expand Down Expand Up @@ -120,12 +121,11 @@ jobs:
run: ccache --show-stats

- name: Save ccache
# Pull requests only read the cache, pushes to main and manual runs populate it.
# Pull requests only read the cache, pushes to main and manual runs replace it.
if: ${{ !cancelled() && github.event_name != 'pull_request' }}
uses: actions/cache/save@v4
uses: ./.github/actions/save-ccache
with:
path: .ccache
key: ccache-linux-test_${{ github.sha }}
key: ccache-linux-test

- name: Setup test environment
run: |
Expand Down Expand Up @@ -333,7 +333,7 @@ jobs:
uses: actions/cache/restore@v4
with:
path: .ccache
key: ccache-windows_${{ github.sha }}
key: ccache-windows
restore-keys: |
ccache-windows_

Expand Down Expand Up @@ -386,12 +386,11 @@ jobs:
run: ccache --show-stats

- name: Save ccache
# Pull requests only read the cache, pushes to main and manual runs populate it.
# Pull requests only read the cache, pushes to main and manual runs replace it.
if: ${{ !cancelled() && github.event_name != 'pull_request' }}
uses: actions/cache/save@v4
uses: ./.github/actions/save-ccache
with:
path: .ccache
key: ccache-windows_${{ github.sha }}
key: ccache-windows

- name: Run unit tests
shell: bash
Expand Down Expand Up @@ -443,7 +442,7 @@ jobs:
uses: actions/cache/restore@v4
with:
path: .ccache
key: ccache-${{ matrix.os }}_${{ github.sha }}
key: ccache-${{ matrix.os }}
restore-keys: |
ccache-${{ matrix.os }}_

Expand Down Expand Up @@ -483,12 +482,11 @@ jobs:
run: ccache --show-stats

- name: Save ccache
# Pull requests only read the cache, pushes to main and manual runs populate it.
# Pull requests only read the cache, pushes to main and manual runs replace it.
if: ${{ !cancelled() && github.event_name != 'pull_request' }}
uses: actions/cache/save@v4
uses: ./.github/actions/save-ccache
with:
path: .ccache
key: ccache-${{ matrix.os }}_${{ github.sha }}
key: ccache-${{ matrix.os }}

- name: Run unit tests
run: |
Expand Down
Loading