mirror of
https://github.com/Swatinem/rust-cache.git
synced 2025-07-19 07:11:24 +03:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
7e1e2d0a10 | |||
98c8021b55 | |||
14d3bc39c4 | |||
52ea1434f8 | |||
eaa85be6b1 | |||
901019c0f8 |
@ -1,5 +1,10 @@
|
||||
# Changelog
|
||||
|
||||
## 2.8.0
|
||||
|
||||
- Add support for `warpbuild` cache provider
|
||||
- Add new `cache-workspace-crates` feature
|
||||
|
||||
## 2.7.8
|
||||
|
||||
- Include CPU arch in the cache key
|
||||
|
@ -60,6 +60,12 @@ sensible defaults.
|
||||
# default: "false"
|
||||
cache-all-crates: ""
|
||||
|
||||
# Similar to cache-all-crates.
|
||||
# If `true` the workspace crates will be cached.
|
||||
# Useful if the workspace contains libraries that are only updated sporadically.
|
||||
# default: "false"
|
||||
cache-workspace-crates: ""
|
||||
|
||||
# Determines whether the cache should be saved.
|
||||
# If `false`, the cache is only restored.
|
||||
# Useful for jobs where the matrix is additive e.g. additional Cargo features,
|
||||
@ -76,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: ""
|
||||
|
||||
|
@ -32,12 +32,16 @@ inputs:
|
||||
description: "Determines which crates are cached. If `true` all crates will be cached, otherwise only dependent crates will be cached."
|
||||
required: false
|
||||
default: "false"
|
||||
cache-workspace-crates:
|
||||
description: "Similar to cache-all-crates. If `true` the workspace crates will be cached."
|
||||
required: false
|
||||
default: "false"
|
||||
save-if:
|
||||
description: "Determiners whether the cache should be saved. If `false`, the cache is only restored."
|
||||
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:
|
||||
|
60521
dist/restore/index.js
vendored
60521
dist/restore/index.js
vendored
File diff suppressed because one or more lines are too long
60526
dist/save/index.js
vendored
60526
dist/save/index.js
vendored
File diff suppressed because one or more lines are too long
902
package-lock.json
generated
902
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "rust-cache",
|
||||
"version": "2.7.8",
|
||||
"version": "2.8.0",
|
||||
"description": "A GitHub Action that implements smart caching for rust/cargo projects with sensible defaults.",
|
||||
"keywords": [
|
||||
"actions",
|
||||
@ -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",
|
||||
|
@ -36,9 +36,14 @@ async function run() {
|
||||
await macOsWorkaround();
|
||||
}
|
||||
|
||||
const workspaceCrates = core.getInput("cache-workspace-crates").toLowerCase() || "false";
|
||||
const allPackages = [];
|
||||
for (const workspace of config.workspaces) {
|
||||
const packages = await workspace.getPackagesOutsideWorkspaceRoot();
|
||||
if (workspaceCrates === "true") {
|
||||
const wsMembers = await workspace.getWorkspaceMembers();
|
||||
packages.push(...wsMembers);
|
||||
}
|
||||
allPackages.push(...packages);
|
||||
try {
|
||||
core.info(`... Cleaning ${workspace.target} ...`);
|
||||
|
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 {
|
||||
|
@ -15,6 +15,7 @@ export class Workspace {
|
||||
const meta: Meta = JSON.parse(
|
||||
await getCmdOutput("cargo", ["metadata", "--all-features", "--format-version", "1", ...extraArgs], {
|
||||
cwd: this.root,
|
||||
env: { "CARGO_ENCODED_RUSTFLAGS": "" },
|
||||
}),
|
||||
);
|
||||
core.debug(`workspace "${this.root}" has ${meta.packages.length} packages`);
|
||||
|
1378
tests/Cargo.lock
generated
1378
tests/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -14,4 +14,4 @@ watto = { git = "https://github.com/getsentry/watto", rev = "d71c8218506bddba102
|
||||
trybuild = "1"
|
||||
|
||||
[target.'cfg(not(target_env = "msvc"))'.dependencies]
|
||||
tikv-jemallocator = "0.5.4"
|
||||
tikv-jemallocator = "0.6.0"
|
||||
|
1570
tests/wasm-workspace/Cargo.lock
generated
1570
tests/wasm-workspace/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,5 @@
|
||||
[workspace]
|
||||
resolver = "2"
|
||||
members = [
|
||||
"crates/one",
|
||||
"crates/two",
|
||||
|
@ -5,7 +5,7 @@ version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
reqwest = "0.11.0"
|
||||
reqwest = "0.12"
|
||||
async-std = "1"
|
||||
tracing = "0.1"
|
||||
tracing-futures = "0.2"
|
||||
|
@ -5,4 +5,4 @@ version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
clap = "3"
|
||||
clap = "4"
|
||||
|
Reference in New Issue
Block a user