mirror of
https://github.com/Swatinem/rust-cache
synced 2025-04-29 06:35:53 +00:00
Add BuildJet Option (#154)
This commit is contained in:
parent
9de8f90afb
commit
b00faf5858
10 changed files with 5501 additions and 24 deletions
|
@ -1,8 +1,8 @@
|
|||
import * as cache from "@actions/cache";
|
||||
import * as core from "@actions/core";
|
||||
|
||||
import { cleanTargetDir } from "./cleanup";
|
||||
import { CacheConfig } from "./config";
|
||||
import { getCacheHandler } from "./utils";
|
||||
|
||||
process.on("uncaughtException", (e) => {
|
||||
core.error(e.message);
|
||||
|
@ -12,6 +12,8 @@ process.on("uncaughtException", (e) => {
|
|||
});
|
||||
|
||||
async function run() {
|
||||
const cache = getCacheHandler();
|
||||
|
||||
if (!cache.isFeatureAvailable()) {
|
||||
setCacheHitOutput(false);
|
||||
return;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import * as cache from "@actions/cache";
|
||||
import * as core from "@actions/core";
|
||||
import * as exec from "@actions/exec";
|
||||
|
||||
import { cleanBin, cleanGit, cleanRegistry, cleanTargetDir } from "./cleanup";
|
||||
import { CacheConfig, isCacheUpToDate } from "./config";
|
||||
import { getCacheHandler } from "./utils";
|
||||
|
||||
process.on("uncaughtException", (e) => {
|
||||
core.error(e.message);
|
||||
|
@ -13,6 +13,8 @@ process.on("uncaughtException", (e) => {
|
|||
});
|
||||
|
||||
async function run() {
|
||||
const cache = getCacheHandler();
|
||||
|
||||
const save = core.getInput("save-if").toLowerCase() || "true";
|
||||
|
||||
if (!(cache.isFeatureAvailable() && save === "true")) {
|
||||
|
|
16
src/utils.ts
16
src/utils.ts
|
@ -1,3 +1,5 @@
|
|||
import * as buildjetCache from "@actions/buildjet-cache";
|
||||
import * as ghCache from "@actions/cache";
|
||||
import * as core from "@actions/core";
|
||||
import * as exec from "@actions/exec";
|
||||
|
||||
|
@ -28,3 +30,17 @@ export async function getCmdOutput(
|
|||
}
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue