mirror of
https://github.com/Swatinem/rust-cache
synced 2026-06-26 02:00:35 +00:00
use rollup to do bundle splitting
this uses dynamic imports for the cache provider and should thus solve the deprecated import error when using warpbuild
This commit is contained in:
parent
1fe0a60026
commit
c106961fee
10 changed files with 333200 additions and 665905 deletions
|
|
@ -12,7 +12,7 @@ process.on("uncaughtException", (e) => {
|
|||
});
|
||||
|
||||
async function run() {
|
||||
const cacheProvider = getCacheProvider();
|
||||
const cacheProvider = await getCacheProvider();
|
||||
|
||||
if (!cacheProvider.cache.isFeatureAvailable()) {
|
||||
setCacheHitOutput(false);
|
||||
|
|
@ -42,9 +42,10 @@ async function run() {
|
|||
lookupOnly,
|
||||
});
|
||||
if (restoreKey) {
|
||||
const match = restoreKey.localeCompare(key, undefined, {
|
||||
sensitivity: "accent"
|
||||
}) === 0;
|
||||
const match =
|
||||
restoreKey.localeCompare(key, undefined, {
|
||||
sensitivity: "accent",
|
||||
}) === 0;
|
||||
core.info(`${lookupOnly ? "Found" : "Restored from"} cache key "${restoreKey}" full match: ${match}.`);
|
||||
if (!match) {
|
||||
// pre-clean the target directory on cache mismatch
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ process.on("uncaughtException", (e) => {
|
|||
});
|
||||
|
||||
async function run() {
|
||||
const cacheProvider = getCacheProvider();
|
||||
const cacheProvider = await getCacheProvider();
|
||||
|
||||
const save = core.getInput("save-if").toLowerCase() || "true";
|
||||
|
||||
|
|
|
|||
12
src/utils.ts
12
src/utils.ts
|
|
@ -1,7 +1,5 @@
|
|||
import * as core from "@actions/core";
|
||||
import * as exec from "@actions/exec";
|
||||
import * as warpbuildCache from "@actions/warpbuild-cache";
|
||||
import * as ghCache from "@actions/cache";
|
||||
import fs from "fs";
|
||||
|
||||
export function reportError(e: any) {
|
||||
|
|
@ -42,8 +40,8 @@ export async function getCmdOutput(cmdFormat: string, cmd: string, options: exec
|
|||
}
|
||||
|
||||
export interface GhCache {
|
||||
isFeatureAvailable: typeof ghCache.isFeatureAvailable;
|
||||
restoreCache: typeof ghCache.restoreCache;
|
||||
isFeatureAvailable: typeof import("@actions/cache").isFeatureAvailable;
|
||||
restoreCache: typeof import("@actions/cache").restoreCache;
|
||||
saveCache: (paths: string[], key: string) => Promise<string | number>;
|
||||
}
|
||||
|
||||
|
|
@ -52,15 +50,15 @@ export interface CacheProvider {
|
|||
cache: GhCache;
|
||||
}
|
||||
|
||||
export function getCacheProvider(): CacheProvider {
|
||||
export async function getCacheProvider(): Promise<CacheProvider> {
|
||||
const cacheProvider = core.getInput("cache-provider");
|
||||
let cache: GhCache;
|
||||
switch (cacheProvider) {
|
||||
case "github":
|
||||
cache = ghCache;
|
||||
cache = await import("@actions/cache");
|
||||
break;
|
||||
case "warpbuild":
|
||||
cache = warpbuildCache;
|
||||
cache = await import("@actions/warpbuild-cache");
|
||||
break;
|
||||
default:
|
||||
throw new Error(`The \`cache-provider\` \`${cacheProvider}\` is not valid.`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue