Skip to content

[CI][C++] Improve ccache reuse by saving to cache only from main #50046

@rok

Description

@rok

Describe the enhancement requested

Our C++ GitHub Actions jobs currently use ccache through actions/cache. Many cache keys include the full C++ source tree hash, for example:

key: cpp-ccache-macos-${{ matrix.macos-version }}-${{ hashFiles('cpp/**') }}
restore-keys: cpp-ccache-macos-${{ matrix.macos-version }}-

This was originally introduced in #7081 as a workaround for GitHub Actions cache immutability: cache entries cannot be updated once written, so changing keys are needed to create new cache snapshots.

However, using hashFiles('cpp/**') might be suboptimal for compiler caches. Hashing the entire source tree at the outer GitHub cache layer creates many distinct cache entries and increases the chance of cache misses/eviction.

Component(s)

Continuous Integration

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions