Skip to content

Commit 586e886

Browse files
committed
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.
1 parent 9cfad99 commit 586e886

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ be https://ziglang.org/download to avoid the official website being hit with lar
4545
If you've experienced issues with a default mirror, please open an issue, and I will communicate with the
4646
mirror's owner or remove it from the list.
4747

48+
If necessary, the caching of the global Zig cache directory can be disabled by setting the option
49+
`use-cache: false`. Don't do this without reason: preserving the Zig cache will typically speed things up
50+
and decrease the load on GitHub's runners.
51+
4852
[mach-nominated]: https://machengine.org/about/nominated-zig/
4953

5054
## Details

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ inputs:
99
description: 'Override of Zig download mirror to use, e.g. "https://pkg.machengine.org/zig".'
1010
required: false
1111
default: ''
12+
use-cache:
13+
description: 'Whether to cache the global Zig cache directory.'
14+
required: true
15+
default: true
1216
runs:
1317
using: 'node20'
1418
main: 'main.js'

main.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,13 @@ async function main() {
105105
}
106106

107107
core.addPath(zig_dir);
108-
await cache.restoreCache([await common.getZigCachePath()], await common.getCachePrefix());
108+
109109
// Direct Zig to use the global cache as every local cache, so that we get maximum benefit from the caching above.
110110
core.exportVariable('ZIG_LOCAL_CACHE_DIR', await common.getZigCachePath());
111+
112+
if (core.getBooleanInput('use-cache')) {
113+
await cache.restoreCache([await common.getZigCachePath()], await common.getCachePrefix());
114+
}
111115
} catch (err) {
112116
core.setFailed(err.message);
113117
}

post.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ const common = require('./common');
55

66
async function main() {
77
try {
8-
const prefix = await common.getCachePrefix();
9-
const name = prefix + github.context.runId;
10-
await cache.saveCache([await common.getZigCachePath()], name);
8+
if (core.getBooleanInput('use-cache')) {
9+
const prefix = await common.getCachePrefix();
10+
const name = prefix + github.context.runId;
11+
await cache.saveCache([await common.getZigCachePath()], name);
12+
}
1113
} catch (err) {
1214
core.setFailed(err.message);
1315
}

0 commit comments

Comments
 (0)