Skip to content

Commit 244047d

Browse files
committed
[CI] Fix ineffective ccache
Cache on GHA is immutable. For this reason, hendrikmuhs/ccache-action creates a new cache entry for each push, each with an appended timestamp, which fills the cache very quickly. In an attempt to fix this, we've disabled the append-timestamp option and appended a hash of php_version.h. Hence, we'll only get a new cache file once this file is touched. However, since this file rarely ever updates for master, we're relying on an extremely outdated cache. To fix this, append the current year+week to rebuild the cache each week instead, as suggested by Tim. Also use major.minor version instead of the has of php_version.h for readability. Fixes GH-14154
1 parent c891263 commit 244047d

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

.github/actions/ccache/action.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,20 @@ inputs:
55
runs:
66
using: composite
77
steps:
8+
- name: Get cache key
9+
shell: bash
10+
id: cache_key
11+
run: |
12+
major=$(cat main/php_version.h | sed -En 's/^#define PHP_MAJOR_VERSION ([0-9]+)/\1/p')
13+
minor=$(cat main/php_version.h | sed -En 's/^#define PHP_MINOR_VERSION ([0-9]+)/\1/p')
14+
week=$(date +"%Y-%W")
15+
prefix="${{ inputs.name }}-$major.$minor"
16+
echo "key=$prefix-$week" >> $GITHUB_OUTPUT
17+
echo "prefix=$prefix-" >> $GITHUB_OUTPUT
818
- name: ccache
919
uses: hendrikmuhs/ccache-action@v1.2
1020
with:
11-
key: "${{ inputs.name }}-${{ hashFiles('main/php_version.h') }}"
21+
key: "${{ steps.cache_key.outputs.key }}"
1222
append-timestamp: false
23+
restore-keys: "${{ steps.cache_key.outputs.prefix }}"
1324
save: ${{ github.event_name != 'pull_request' }}

.github/workflows/test-suite.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
type: string
1111
permissions:
1212
contents: read
13+
env:
14+
CC: ccache gcc
15+
CXX: ccache g++
1316
jobs:
1417
LINUX_PPC64:
1518
if: ${{ fromJson(inputs.branch).jobs.LINUX_PPC64 }}

.github/workflows/test.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ permissions:
2929
concurrency:
3030
group: ${{ github.workflow }}-${{ github.event.pull_request.url || github.run_id }}
3131
cancel-in-progress: true
32-
env:
33-
CC: ccache gcc
34-
CXX: ccache g++
3532
jobs:
3633
GENERATE_MATRIX:
3734
name: Generate Matrix

0 commit comments

Comments
 (0)