[php-src] Issue #14154: ccache in GitHub Actions is likely ineffective for master
| From: | TimWolla | Date: | Mon, 06 May 2024 15:11:56 +0000 |
| Subject: | [php-src] Issue #14154: ccache in GitHub Actions is likely ineffective for master | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-246866@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/14154
Author: TimWolla
### Description
The cache key for GitHub is configured as:
```
key: "LINUX_X64_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{
matrix.zts && 'ZTS' || 'NTS' }}${{ matrix.asan &&
'_ASAN' || '' }}-${{hashFiles('main/php_version.h')}}"
```
Because GitHub’s caches are immutable (on a hit, the cache will not be updated), and because
master’s
php_version.h changes rarely, ccache is currently using a 9 month old cache,
as per https://github.com/php/php-src/actions/caches.
A 9 month old cache might as well not exist.
The cache should regularly be regenerated, e.g. by embedding the current week within the cache key
and then configuring restore keys with a common prefix that allows everything, no matter the week:
```
- id: week
run: |
echo "week=$(date +"%Y-%W")" >> $GITHUB_OUTPUT
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
# This duplicates the "job.name" expression above because
# GitHub has no way to query the job name (github.job is the
# job id, not the job name)
key: "LINUX_X64_${{ matrix.debug && 'DEBUG' || 'RELEASE'
}}_${{ matrix.zts && 'ZTS' || 'NTS' }}${{ matrix.asan &&
'_ASAN' || '' }}-${{hashFiles('main/php_version.h')}}-${{
steps.week.outputs.week }}"
restore-keys: |
LINUX_X64_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{
matrix.zts && 'ZTS' || 'NTS' }}${{ matrix.asan &&
'_ASAN' || '' }}-${{hashFiles('main/php_version.h')}}-
append-timestamp: false
```
Alternatively append-timestamp could be configured as true, which would
update the caches for every build.
### PHP Version
n/a
### Operating System
_No response_