mirror of
https://github.com/Swatinem/rust-cache
synced 2025-08-18 02:42:18 +00:00
support warpbuild cache provider (#247)
This commit is contained in:
parent
eaa85be6b1
commit
52ea1434f8
7 changed files with 119122 additions and 2847 deletions
26
src/utils.ts
26
src/utils.ts
|
@ -1,6 +1,7 @@
|
|||
import * as core from "@actions/core";
|
||||
import * as exec from "@actions/exec";
|
||||
import * as buildjetCache from "@actions/buildjet-cache";
|
||||
import * as warpbuildCache from "@actions/warpbuild-cache";
|
||||
import * as ghCache from "@actions/cache";
|
||||
import fs from "fs";
|
||||
|
||||
|
@ -44,17 +45,32 @@ export async function getCmdOutput(
|
|||
return stdout;
|
||||
}
|
||||
|
||||
export interface GhCache {
|
||||
isFeatureAvailable: typeof ghCache.isFeatureAvailable;
|
||||
restoreCache: typeof ghCache.restoreCache;
|
||||
saveCache: (paths: string[], key: string) => Promise<string | number>;
|
||||
}
|
||||
|
||||
export interface CacheProvider {
|
||||
name: string;
|
||||
cache: typeof ghCache;
|
||||
cache: GhCache;
|
||||
}
|
||||
|
||||
export function getCacheProvider(): CacheProvider {
|
||||
const cacheProvider = core.getInput("cache-provider");
|
||||
const cache = cacheProvider === "github" ? ghCache : cacheProvider === "buildjet" ? buildjetCache : undefined;
|
||||
|
||||
if (!cache) {
|
||||
throw new Error(`The \`cache-provider\` \`{cacheProvider}\` is not valid.`);
|
||||
let cache: GhCache;
|
||||
switch (cacheProvider) {
|
||||
case "github":
|
||||
cache = ghCache;
|
||||
break;
|
||||
case "buildjet":
|
||||
cache = buildjetCache;
|
||||
break;
|
||||
case "warpbuild":
|
||||
cache = warpbuildCache;
|
||||
break;
|
||||
default:
|
||||
throw new Error(`The \`cache-provider\` \`${cacheProvider}\` is not valid.`);
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue