3
0
Fork 0
mirror of https://github.com/Swatinem/rust-cache synced 2025-06-27 02:28:48 +00:00

support warpbuild cache provider

This commit is contained in:
Sammy Harris 2025-06-24 11:51:03 -05:00
parent eaa85be6b1
commit f29739b6ab
No known key found for this signature in database
GPG key ID: 748BCB143FE9828B
7 changed files with 119122 additions and 2847 deletions

View file

@ -82,7 +82,7 @@ sensible defaults.
lookup-only: ""
# Specifies what to use as the backend providing cache
# Can be set to either "github" or "buildjet"
# Can be set to "github", "buildjet", or "warpbuild"
# default: "github"
cache-provider: ""

View file

@ -41,7 +41,7 @@ inputs:
required: false
default: "true"
cache-provider:
description: "Determines which provider to use for caching. Options are github or buildjet, defaults to github."
description: "Determines which provider to use for caching. Options are github, buildjet, or warpbuild. Defaults to github."
required: false
default: "github"
cache-bin:

60520
dist/restore/index.js vendored

File diff suppressed because one or more lines are too long

60520
dist/save/index.js vendored

File diff suppressed because one or more lines are too long

898
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -23,6 +23,7 @@
"homepage": "https://github.com/Swatinem/rust-cache#readme",
"dependencies": {
"@actions/buildjet-cache": "npm:github-actions.cache-buildjet@0.2.0",
"@actions/warpbuild-cache": "npm:github-actions.warp-cache@1.4.5",
"@actions/cache": "^4.0.0",
"@actions/core": "^1.11.1",
"@actions/exec": "^1.1.1",

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 {