Skip to content

Commit

Permalink
Fix #146: use compiler hash instead of volatile mtime (#147)
Browse files Browse the repository at this point in the history
* Fix #146: use compiler hash instead of volatile mtime

This addresses issue where GitHub actions runners report different mtime for compiler causing incorrect cache misses

* Fix #146: use compiler hash instead of volatile mtime for darwin

This addresses issue where GitHub actions runners report different mtime for compiler causing incorrect cache misses
  • Loading branch information
janisozaur authored Sep 8, 2023
1 parent 6d1841e commit 9a21fcb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/restore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,17 @@ async function restore(ccacheVariant : string) : Promise<void> {
}
}

async function configure(ccacheVariant : string) : Promise<void> {
async function configure(ccacheVariant : string, platform : string) : Promise<void> {
const ghWorkSpace = process.env.GITHUB_WORKSPACE || "unreachable, make ncc happy";
const maxSize = core.getInput('max-size');

if (ccacheVariant === "ccache") {
await execBash(`ccache --set-config=cache_dir='${path.join(ghWorkSpace, '.ccache')}'`);
await execBash(`ccache --set-config=max_size='${maxSize}'`);
await execBash(`ccache --set-config=compression=true`);
if (platform === "darwin") {
await execBash(`ccache --set-config=compiler_check=content`);
}
core.info("Cccache config:");
await execBash("ccache -p");
} else {
Expand Down Expand Up @@ -194,8 +197,8 @@ async function runInner() : Promise<void> {
await restore(ccacheVariant);
core.endGroup();

core.startGroup(`Configure ${ccacheVariant}`);
await configure(ccacheVariant);
core.startGroup(`Configure ${ccacheVariant}, ${process.platform}`);
await configure(ccacheVariant, process.platform);
await execBash(`${ccacheVariant} -z`);
core.endGroup();
}
Expand Down

0 comments on commit 9a21fcb

Please sign in to comment.