Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ccache in GitHub Actions is likely ineffective for master #14154

Open
TimWolla opened this issue May 6, 2024 · 1 comment
Open

ccache in GitHub Actions is likely ineffective for master #14154

TimWolla opened this issue May 6, 2024 · 1 comment

Comments

@TimWolla
Copy link
Member

TimWolla commented May 6, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
@TimWolla and others