Add use-cache option
This option can be used to disable preservation of the global Zig cache directory across runs. This option is only applicable in rare cases, and should not be used by the majority of users.
This commit is contained in:
@@ -45,6 +45,10 @@ be https://ziglang.org/download to avoid the official website being hit with lar
|
||||
If you've experienced issues with a default mirror, please open an issue, and I will communicate with the
|
||||
mirror's owner or remove it from the list.
|
||||
|
||||
If necessary, the caching of the global Zig cache directory can be disabled by setting the option
|
||||
`use-cache: false`. Don't do this without reason: preserving the Zig cache will typically speed things up
|
||||
and decrease the load on GitHub's runners.
|
||||
|
||||
[mach-nominated]: https://machengine.org/about/nominated-zig/
|
||||
|
||||
## Details
|
||||
|
||||
@@ -9,6 +9,10 @@ inputs:
|
||||
description: 'Override of Zig download mirror to use, e.g. "https://pkg.machengine.org/zig".'
|
||||
required: false
|
||||
default: ''
|
||||
use-cache:
|
||||
description: 'Whether to cache the global Zig cache directory.'
|
||||
required: true
|
||||
default: true
|
||||
runs:
|
||||
using: 'node20'
|
||||
main: 'main.js'
|
||||
|
||||
@@ -105,9 +105,13 @@ async function main() {
|
||||
}
|
||||
|
||||
core.addPath(zig_dir);
|
||||
await cache.restoreCache([await common.getZigCachePath()], await common.getCachePrefix());
|
||||
|
||||
// Direct Zig to use the global cache as every local cache, so that we get maximum benefit from the caching above.
|
||||
core.exportVariable('ZIG_LOCAL_CACHE_DIR', await common.getZigCachePath());
|
||||
|
||||
if (core.getBooleanInput('use-cache')) {
|
||||
await cache.restoreCache([await common.getZigCachePath()], await common.getCachePrefix());
|
||||
}
|
||||
} catch (err) {
|
||||
core.setFailed(err.message);
|
||||
}
|
||||
|
||||
@@ -5,9 +5,11 @@ const common = require('./common');
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
const prefix = await common.getCachePrefix();
|
||||
const name = prefix + github.context.runId;
|
||||
await cache.saveCache([await common.getZigCachePath()], name);
|
||||
if (core.getBooleanInput('use-cache')) {
|
||||
const prefix = await common.getCachePrefix();
|
||||
const name = prefix + github.context.runId;
|
||||
await cache.saveCache([await common.getZigCachePath()], name);
|
||||
}
|
||||
} catch (err) {
|
||||
core.setFailed(err.message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user