3
0
Fork 0
mirror of https://github.com/Swatinem/rust-cache synced 2025-09-29 22:49:02 +00:00

pretty printing and fix workspace package retrieval

This commit is contained in:
Arpad Borsos 2022-07-09 15:51:45 +02:00
parent 36af5cb1ae
commit 827b33fbd0
No known key found for this signature in database
GPG key ID: FC7BCA77824B3298
6 changed files with 29 additions and 13 deletions

View file

@ -180,6 +180,7 @@ export class CacheConfig {
}
printInfo() {
core.startGroup("Cache Configuration");
core.info(`Workspaces:`);
for (const workspace of this.workspaces) {
core.info(` ${workspace.root}`);
@ -203,6 +204,7 @@ export class CacheConfig {
for (const file of this.keyFiles) {
core.info(` - ${file}`);
}
core.endGroup();
}
public async getCargoBins(): Promise<Set<string>> {

View file

@ -26,12 +26,13 @@ async function run() {
core.exportVariable("CARGO_INCREMENTAL", 0);
const config = await CacheConfig.new();
config.printInfo();
core.info("");
const bins = await config.getCargoBins();
core.saveState(STATE_BINS, JSON.stringify([...bins]));
core.info(`# Restoring cache`);
config.printInfo();
core.info(`... Restoring cache ...`);
const key = config.cacheKey;
const restoreKey = await cache.restoreCache(config.cachePaths, key, [config.restoreKey]);
if (restoreKey) {

View file

@ -21,6 +21,8 @@ async function run() {
try {
const config = await CacheConfig.new();
config.printInfo();
core.info("");
if (core.getState(STATE_KEY) === config.cacheKey) {
core.info(`Cache up-to-date.`);
@ -30,8 +32,7 @@ async function run() {
// TODO: remove this once https://github.com/actions/toolkit/pull/553 lands
await macOsWorkaround();
core.info(`# Cleaning Cache`);
config.printInfo();
core.info(`... Cleaning Cache ...`);
const registryName = await getRegistryName(config);
@ -66,7 +67,7 @@ async function run() {
core.info(`[warning] ${(e as any).stack}`);
}
core.info(`# Saving cache`);
core.info(`... Saving cache ...`);
await cache.saveCache(config.cachePaths, config.cacheKey);
} catch (e) {
core.info(`[warning] ${(e as any).stack}`);

View file

@ -9,7 +9,9 @@ export class Workspace {
let packages: Packages = [];
try {
const meta: Meta = JSON.parse(
await getCmdOutput("cargo", ["metadata", "--all-features", "--format-version", "1"]),
await getCmdOutput("cargo", ["metadata", "--all-features", "--format-version", "1"], {
cwd: this.root,
}),
);
for (const pkg of meta.packages) {
if (!pkg.manifest_path.startsWith(this.root)) {