3
0
Fork 0
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:
Sammy Harris 2025-06-24 12:04:05 -05:00 committed by GitHub
parent eaa85be6b1
commit 52ea1434f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 119122 additions and 2847 deletions

View file

@ -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 {