Skip to content

Commit b2b6097

Browse files
authored
Merge pull request InsightSoftwareConsortium#5954 from hjmjohnson/improve-ccache-for-with-larger-quota
ENH: Optimize GitHub Actions ccache strategy for faster C++ builds
2 parents 912328d + 5e46e52 commit b2b6097

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

.github/workflows/arm.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ jobs:
9494
echo "CCACHE_BASEDIR=${GITHUB_WORKSPACE}" >> "$GITHUB_ENV"
9595
echo "CCACHE_COMPILERCHECK=content" >> "$GITHUB_ENV"
9696
echo "CCACHE_NOHASHDIR=true" >> "$GITHUB_ENV"
97-
echo "CCACHE_NODIRECT=1" >> "$GITHUB_ENV"
97+
echo "CCACHE_SLOPPINESS=pch_defines,time_macros" >> "$GITHUB_ENV"
9898
echo "CCACHE_DIR=${{ runner.temp }}/ccache" >> "$GITHUB_ENV"
99-
echo "CCACHE_MAXSIZE=2.4G" >> "$GITHUB_ENV"
99+
echo "CCACHE_MAXSIZE=5G" >> "$GITHUB_ENV"
100100
if [ "$RUNNER_OS" == "Linux" ]; then
101101
sudo apt-get update -qq && sudo apt-get install -y ccache locales
102102
sudo locale-gen de_DE.UTF-8
@@ -109,7 +109,9 @@ jobs:
109109
uses: actions/cache/restore@v5
110110
with:
111111
path: ${{ runner.temp }}/ccache
112-
key: ccache-v1-${{ matrix.os }}-${{ matrix.name }}
112+
key: ccache-v4-${{ runner.os }}-${{ matrix.name }}-${{ github.sha }}
113+
restore-keys: |
114+
ccache-v4-${{ runner.os }}-${{ matrix.name }}-
113115
114116
- name: Show ccache configuration, stats and maintenance
115117
shell: bash
@@ -170,11 +172,11 @@ jobs:
170172
env:
171173
CTEST_OUTPUT_ON_FAILURE: 1
172174
- name: Save compiler cache
173-
if: github.ref == 'refs/heads/main'
175+
if: ${{ !cancelled() }}
174176
uses: actions/cache/save@v5
175177
with:
176178
path: ${{ runner.temp }}/ccache
177-
key: ccache-v1-${{ matrix.os }}-${{ matrix.name }}
179+
key: ccache-v4-${{ runner.os }}-${{ matrix.name }}-${{ github.sha }}
178180

179181
- name: ccache stats
180182
if: always()

.github/workflows/pixi.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ jobs:
5353
echo "CCACHE_BASEDIR=${GITHUB_WORKSPACE}" >> "$GITHUB_ENV"
5454
echo "CCACHE_COMPILERCHECK=content" >> "$GITHUB_ENV"
5555
echo "CCACHE_NOHASHDIR=true" >> "$GITHUB_ENV"
56-
echo "CCACHE_NODIRECT=1" >> "$GITHUB_ENV"
56+
echo "CCACHE_SLOPPINESS=pch_defines,time_macros" >> "$GITHUB_ENV"
5757
echo "CCACHE_DIR=${{ runner.temp }}/ccache" >> "$GITHUB_ENV"
58-
echo "CCACHE_MAXSIZE=2.4G" >> "$GITHUB_ENV"
58+
echo "CCACHE_MAXSIZE=5G" >> "$GITHUB_ENV"
5959
if [ "$RUNNER_OS" == "Linux" ]; then
6060
sudo apt-get update -qq && sudo apt-get install -y ccache locales
6161
sudo locale-gen de_DE.UTF-8
@@ -70,7 +70,9 @@ jobs:
7070
uses: actions/cache/restore@v5
7171
with:
7272
path: ${{ runner.temp }}/ccache
73-
key: ccache-v1-${{ matrix.os }}-pixi-cxx
73+
key: ccache-v4-${{ runner.os }}-pixi-cxx-${{ github.sha }}
74+
restore-keys: |
75+
ccache-v4-${{ runner.os }}-pixi-cxx-
7476
7577
- name: Show ccache configuration, stats and maintenance
7678
shell: bash
@@ -150,11 +152,11 @@ jobs:
150152
echo "****** df -h /"
151153
df -h /
152154
- name: Save compiler cache
153-
if: github.ref == 'refs/heads/main'
155+
if: ${{ !cancelled() }}
154156
uses: actions/cache/save@v5
155157
with:
156158
path: ${{ runner.temp }}/ccache
157-
key: ccache-v1-${{ matrix.os }}-pixi-cxx
159+
key: ccache-v4-${{ runner.os }}-pixi-cxx-${{ github.sha }}
158160

159161
- name: ccache stats
160162
if: always()

0 commit comments

Comments
 (0)