Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92383,6 +92383,7 @@ const core = __nccwpck_require__(7484);
const tc = __nccwpck_require__(3472);
const axios = __nccwpck_require__(7269);
const cache = __nccwpck_require__(5116);
const exec = __nccwpck_require__(5236);
const common = __nccwpck_require__(7211);
const minisign = __nccwpck_require__(460);

Expand Down Expand Up @@ -92579,14 +92580,22 @@ async function main() {
}

core.addPath(zig_dir);
const zig_version = (await exec.getExecOutput('zig', ['version'])).stdout.trim();
core.info(`Resolved Zig version ${zig_version}`);

const cache_path = common.getZigCachePath();
core.exportVariable('ZIG_GLOBAL_CACHE_DIR', cache_path);
core.exportVariable('ZIG_LOCAL_CACHE_DIR', cache_path);

if (core.getBooleanInput('use-cache')) {
core.info('Attempting restore of Zig cache');
await cache.restoreCache([cache_path], await common.getCachePrefix());
const cache_prefix = await common.getCachePrefix();
core.info(`Attempting restore of Zig cache with prefix '${cache_prefix}'`);
const hit = await cache.restoreCache([cache_path], cache_prefix);
if (hit === undefined) {
core.info(`Cache miss: leaving Zig cache directory at ${cache_path} unpopulated`);
} else {
core.info(`Cache hit (key '${hit}'): populating Zig cache directory at ${cache_path}`);
}
}
} catch (err) {
core.setFailed(err.message);
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions dist/post/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82881,7 +82881,7 @@ async function main() {
}

if (accessible) {
core.info('Checking cache size');
core.info(`Checking size of cache directory at ${cache_path}`);
const size = await dirSize(cache_path);
const size_limit = core.getInput('cache-size-limit') * 1024 * 1024; // MiB -> bytes
if (size_limit !== 0 && size > size_limit) {
Expand All @@ -82896,7 +82896,7 @@ async function main() {

const prefix = await common.getCachePrefix();
const name = `${prefix}${github.context.runId}-${github.context.runAttempt}`;
core.info('Saving Zig cache');
core.info(`Saving Zig cache with key '${name}'`);
await cache.saveCache([cache_path], name);
} else {
core.info('Zig cache directory is inaccessible; nothing to save');
Expand All @@ -82912,14 +82912,18 @@ async function dirSize(dir_path) {
let total = 0;
for (const ent of await fs.readdir(dir_path, { withFileTypes: true, recursive: true })) {
if (ent.isFile()) {
const p = path.join(ent.parentPath, ent.name);
try {
const stat = await fs.stat(path.join(ent.parentPath, ent.name));
const stat = await fs.stat(p);
total += stat.size;
} catch {}
} catch {
core.warning(`Failed to stat ${p}: ${err}`);
}
}
}
return total;
} catch {
} catch (err) {
core.warning(`Failed to compute size of '${dir_path}': ${err}`);
return 0;
}
}
Expand Down
2 changes: 1 addition & 1 deletion dist/post/index.js.map

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const core = require('@actions/core');
const tc = require('@actions/tool-cache');
const axios = require('axios');
const cache = require('@actions/cache');
const exec = require('@actions/exec');
const common = require('./common');
const minisign = require('./minisign');

Expand Down Expand Up @@ -201,14 +202,22 @@ async function main() {
}

core.addPath(zig_dir);
const zig_version = (await exec.getExecOutput('zig', ['version'])).stdout.trim();
core.info(`Resolved Zig version ${zig_version}`);

const cache_path = common.getZigCachePath();
core.exportVariable('ZIG_GLOBAL_CACHE_DIR', cache_path);
core.exportVariable('ZIG_LOCAL_CACHE_DIR', cache_path);

if (core.getBooleanInput('use-cache')) {
core.info('Attempting restore of Zig cache');
await cache.restoreCache([cache_path], await common.getCachePrefix());
const cache_prefix = await common.getCachePrefix();
core.info(`Attempting restore of Zig cache with prefix '${cache_prefix}'`);
const hit = await cache.restoreCache([cache_path], cache_prefix);
if (hit === undefined) {
core.info(`Cache miss: leaving Zig cache directory at ${cache_path} unpopulated`);
} else {
core.info(`Cache hit (key '${hit}'): populating Zig cache directory at ${cache_path}`);
}
}
} catch (err) {
core.setFailed(err.message);
Expand Down
14 changes: 9 additions & 5 deletions post.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async function main() {
}

if (accessible) {
core.info('Checking cache size');
core.info(`Checking size of cache directory at ${cache_path}`);
const size = await dirSize(cache_path);
const size_limit = core.getInput('cache-size-limit') * 1024 * 1024; // MiB -> bytes
if (size_limit !== 0 && size > size_limit) {
Expand All @@ -33,7 +33,7 @@ async function main() {

const prefix = await common.getCachePrefix();
const name = `${prefix}${github.context.runId}-${github.context.runAttempt}`;
core.info('Saving Zig cache');
core.info(`Saving Zig cache with key '${name}'`);
await cache.saveCache([cache_path], name);
} else {
core.info('Zig cache directory is inaccessible; nothing to save');
Expand All @@ -49,14 +49,18 @@ async function dirSize(dir_path) {
let total = 0;
for (const ent of await fs.readdir(dir_path, { withFileTypes: true, recursive: true })) {
if (ent.isFile()) {
const p = path.join(ent.parentPath, ent.name);
try {
const stat = await fs.stat(path.join(ent.parentPath, ent.name));
const stat = await fs.stat(p);
total += stat.size;
} catch {}
} catch {
core.warning(`Failed to stat ${p}: ${err}`);
}
}
}
return total;
} catch {
} catch (err) {
core.warning(`Failed to compute size of '${dir_path}': ${err}`);
return 0;
}
}
Expand Down
Loading