Are cross-OS caches possible? #755
Replies: 3 comments 4 replies
-
@louis-bompart Cache version is unique for a combination of compression tool used for compression of cache (Gzip, Zstd, etc based on runner OS) and the path of directories being cached. If two caches have different versions, they are identified as unique cache entries. This also means that a cache created on |
Beta Was this translation helpful? Give feedback.
-
This is the code responsible for deciding which compression to use: function getCompressionMethod() {
return __awaiter(this, void 0, void 0, function* () {
if (process.platform === 'win32' && !(yield isGnuTarInstalled())) {
// Disable zstd due to bug https://github.com/actions/cache/issues/301
return constants_1.CompressionMethod.Gzip;
}
const versionOutput = yield getVersion('zstd');
const version = semver.clean(versionOutput);
if (!versionOutput.toLowerCase().includes('zstd command line interface')) {
// zstd is not installed
return constants_1.CompressionMethod.Gzip;
}
else if (!version || semver.lt(version, 'v1.3.2')) {
// zstd is installed but using a version earlier than v1.3.2
// v1.3.2 is required to use the `--long` options in zstd
return constants_1.CompressionMethod.ZstdWithoutLong;
}
else {
return constants_1.CompressionMethod.Zstd;
}
});
}
function isGnuTarInstalled() {
return __awaiter(this, void 0, void 0, function* () {
const versionOutput = yield getVersion('tar');
return versionOutput.toLowerCase().includes('gnu tar');
});
} Therefore, if you can manage to use the same compression everywhere, it should work. |
Beta Was this translation helpful? Give feedback.
-
We are working on cross os caching. We have also released a release in |
Beta Was this translation helpful? Give feedback.
-
Hi 👋
I'm trying to set up
action/caches
in a Node app project. Mainly, I'm trying to cache my build outputs and redistribute them in subsequent jobs in a single workflow.The build occurs on a
ubuntu-latest
runner, and the subsequent jobs occur onubuntu-latest
andwindows-latest
.I adapted the
path
parameter to use\
instead of/
onwindows-latest
, and I'm using an OS-agnostickey
for the cache (to be precise:verdaccio-${{ github.sha }}-${{ github.run_attempt }}
.)I noticed that when trying to restore the cache from
windows-latest
, it ends up in a no-hit, but not onubuntu-latest
(despite both jobs running after the job that uploaded the cache)I also noticed that all examples that I could find use
${{runner-os}}
in thekey
.My question is then, is it possible to cache something from a
linux-latest
runner and restore it in awindows-latest
?Beta Was this translation helpful? Give feedback.
All reactions