mirror of
https://github.com/Swatinem/rust-cache
synced 2025-06-19 06:43:41 +00:00
Improve errors and cleanup
- Silence errors and do not create error annotations, fixes #144 - Implement cleanup for new sparse registry - Do not clean `-sys` dependencies from `registry/src`, hopefully fixes #150
This commit is contained in:
parent
e97a782690
commit
f6987ea139
7 changed files with 213 additions and 56 deletions
38
src/utils.ts
38
src/utils.ts
|
@ -3,6 +3,16 @@ import * as ghCache from "@actions/cache";
|
|||
import * as core from "@actions/core";
|
||||
import * as exec from "@actions/exec";
|
||||
|
||||
export function reportError(e: any) {
|
||||
const { commandFailed } = e;
|
||||
if (commandFailed) {
|
||||
core.error(`Command failed: ${commandFailed.command}`);
|
||||
core.error(commandFailed.stderr);
|
||||
} else {
|
||||
core.error(`${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
export async function getCmdOutput(
|
||||
cmd: string,
|
||||
args: Array<string> = [],
|
||||
|
@ -24,23 +34,25 @@ export async function getCmdOutput(
|
|||
...options,
|
||||
});
|
||||
} catch (e) {
|
||||
core.error(`Command failed: ${cmd} ${args.join(" ")}`);
|
||||
core.error(stderr);
|
||||
(e as any).commandFailed = {
|
||||
command: `${cmd} ${args.join(" ")}`,
|
||||
stderr,
|
||||
};
|
||||
throw e;
|
||||
}
|
||||
return stdout;
|
||||
}
|
||||
|
||||
export function getCacheHandler() {
|
||||
const cacheProvider = core.getInput("cache-provider");
|
||||
switch (cacheProvider) {
|
||||
case 'github':
|
||||
core.info ("Using Github Cache.");
|
||||
return ghCache;
|
||||
case 'buildjet':
|
||||
core.info ("Using Buildjet Cache.");
|
||||
return buildjetCache;
|
||||
default:
|
||||
throw new Error("Only currently support github and buildjet caches");
|
||||
}
|
||||
const cacheProvider = core.getInput("cache-provider");
|
||||
switch (cacheProvider) {
|
||||
case "github":
|
||||
core.info("Using Github Cache.");
|
||||
return ghCache;
|
||||
case "buildjet":
|
||||
core.info("Using Buildjet Cache.");
|
||||
return buildjetCache;
|
||||
default:
|
||||
throw new Error("Only currently support github and buildjet caches");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue