mirror of
https://github.com/Swatinem/rust-cache
synced 2025-04-07 13:45:20 +00:00
pretty printing and fix workspace package retrieval
This commit is contained in:
parent
36af5cb1ae
commit
827b33fbd0
11
dist/restore/index.js
vendored
11
dist/restore/index.js
vendored
|
@ -61642,7 +61642,9 @@ class Workspace {
|
||||||
async getPackages() {
|
async getPackages() {
|
||||||
let packages = [];
|
let packages = [];
|
||||||
try {
|
try {
|
||||||
const meta = JSON.parse(await getCmdOutput("cargo", ["metadata", "--all-features", "--format-version", "1"]));
|
const meta = JSON.parse(await getCmdOutput("cargo", ["metadata", "--all-features", "--format-version", "1"], {
|
||||||
|
cwd: this.root,
|
||||||
|
}));
|
||||||
for (const pkg of meta.packages) {
|
for (const pkg of meta.packages) {
|
||||||
if (!pkg.manifest_path.startsWith(this.root)) {
|
if (!pkg.manifest_path.startsWith(this.root)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -61809,6 +61811,7 @@ class CacheConfig {
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
printInfo() {
|
printInfo() {
|
||||||
|
lib_core.startGroup("Cache Configuration");
|
||||||
lib_core.info(`Workspaces:`);
|
lib_core.info(`Workspaces:`);
|
||||||
for (const workspace of this.workspaces) {
|
for (const workspace of this.workspaces) {
|
||||||
lib_core.info(` ${workspace.root}`);
|
lib_core.info(` ${workspace.root}`);
|
||||||
|
@ -61832,6 +61835,7 @@ class CacheConfig {
|
||||||
for (const file of this.keyFiles) {
|
for (const file of this.keyFiles) {
|
||||||
lib_core.info(` - ${file}`);
|
lib_core.info(` - ${file}`);
|
||||||
}
|
}
|
||||||
|
lib_core.endGroup();
|
||||||
}
|
}
|
||||||
async getCargoBins() {
|
async getCargoBins() {
|
||||||
const bins = new Set();
|
const bins = new Set();
|
||||||
|
@ -62023,10 +62027,11 @@ async function run() {
|
||||||
lib_core.exportVariable("CACHE_ON_FAILURE", cacheOnFailure);
|
lib_core.exportVariable("CACHE_ON_FAILURE", cacheOnFailure);
|
||||||
lib_core.exportVariable("CARGO_INCREMENTAL", 0);
|
lib_core.exportVariable("CARGO_INCREMENTAL", 0);
|
||||||
const config = await CacheConfig["new"]();
|
const config = await CacheConfig["new"]();
|
||||||
|
config.printInfo();
|
||||||
|
lib_core.info("");
|
||||||
const bins = await config.getCargoBins();
|
const bins = await config.getCargoBins();
|
||||||
lib_core.saveState(config_STATE_BINS, JSON.stringify([...bins]));
|
lib_core.saveState(config_STATE_BINS, JSON.stringify([...bins]));
|
||||||
lib_core.info(`# Restoring cache`);
|
lib_core.info(`... Restoring cache ...`);
|
||||||
config.printInfo();
|
|
||||||
const key = config.cacheKey;
|
const key = config.cacheKey;
|
||||||
const restoreKey = await cache.restoreCache(config.cachePaths, key, [config.restoreKey]);
|
const restoreKey = await cache.restoreCache(config.cachePaths, key, [config.restoreKey]);
|
||||||
if (restoreKey) {
|
if (restoreKey) {
|
||||||
|
|
13
dist/save/index.js
vendored
13
dist/save/index.js
vendored
|
@ -61642,7 +61642,9 @@ class Workspace {
|
||||||
async getPackages() {
|
async getPackages() {
|
||||||
let packages = [];
|
let packages = [];
|
||||||
try {
|
try {
|
||||||
const meta = JSON.parse(await getCmdOutput("cargo", ["metadata", "--all-features", "--format-version", "1"]));
|
const meta = JSON.parse(await getCmdOutput("cargo", ["metadata", "--all-features", "--format-version", "1"], {
|
||||||
|
cwd: this.root,
|
||||||
|
}));
|
||||||
for (const pkg of meta.packages) {
|
for (const pkg of meta.packages) {
|
||||||
if (!pkg.manifest_path.startsWith(this.root)) {
|
if (!pkg.manifest_path.startsWith(this.root)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -61809,6 +61811,7 @@ class CacheConfig {
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
printInfo() {
|
printInfo() {
|
||||||
|
core.startGroup("Cache Configuration");
|
||||||
core.info(`Workspaces:`);
|
core.info(`Workspaces:`);
|
||||||
for (const workspace of this.workspaces) {
|
for (const workspace of this.workspaces) {
|
||||||
core.info(` ${workspace.root}`);
|
core.info(` ${workspace.root}`);
|
||||||
|
@ -61832,6 +61835,7 @@ class CacheConfig {
|
||||||
for (const file of this.keyFiles) {
|
for (const file of this.keyFiles) {
|
||||||
core.info(` - ${file}`);
|
core.info(` - ${file}`);
|
||||||
}
|
}
|
||||||
|
core.endGroup();
|
||||||
}
|
}
|
||||||
async getCargoBins() {
|
async getCargoBins() {
|
||||||
const bins = new Set();
|
const bins = new Set();
|
||||||
|
@ -62019,14 +62023,15 @@ async function run() {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const config = await CacheConfig["new"]();
|
const config = await CacheConfig["new"]();
|
||||||
|
config.printInfo();
|
||||||
|
core.info("");
|
||||||
if (core.getState(STATE_KEY) === config.cacheKey) {
|
if (core.getState(STATE_KEY) === config.cacheKey) {
|
||||||
core.info(`Cache up-to-date.`);
|
core.info(`Cache up-to-date.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// TODO: remove this once https://github.com/actions/toolkit/pull/553 lands
|
// TODO: remove this once https://github.com/actions/toolkit/pull/553 lands
|
||||||
await macOsWorkaround();
|
await macOsWorkaround();
|
||||||
core.info(`# Cleaning Cache`);
|
core.info(`... Cleaning Cache ...`);
|
||||||
config.printInfo();
|
|
||||||
const registryName = await getRegistryName(config);
|
const registryName = await getRegistryName(config);
|
||||||
const allPackages = [];
|
const allPackages = [];
|
||||||
for (const workspace of config.workspaces) {
|
for (const workspace of config.workspaces) {
|
||||||
|
@ -62059,7 +62064,7 @@ async function run() {
|
||||||
catch (e) {
|
catch (e) {
|
||||||
core.info(`[warning] ${e.stack}`);
|
core.info(`[warning] ${e.stack}`);
|
||||||
}
|
}
|
||||||
core.info(`# Saving cache`);
|
core.info(`... Saving cache ...`);
|
||||||
await cache.saveCache(config.cachePaths, config.cacheKey);
|
await cache.saveCache(config.cachePaths, config.cacheKey);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
|
|
@ -180,6 +180,7 @@ export class CacheConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
printInfo() {
|
printInfo() {
|
||||||
|
core.startGroup("Cache Configuration");
|
||||||
core.info(`Workspaces:`);
|
core.info(`Workspaces:`);
|
||||||
for (const workspace of this.workspaces) {
|
for (const workspace of this.workspaces) {
|
||||||
core.info(` ${workspace.root}`);
|
core.info(` ${workspace.root}`);
|
||||||
|
@ -203,6 +204,7 @@ export class CacheConfig {
|
||||||
for (const file of this.keyFiles) {
|
for (const file of this.keyFiles) {
|
||||||
core.info(` - ${file}`);
|
core.info(` - ${file}`);
|
||||||
}
|
}
|
||||||
|
core.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getCargoBins(): Promise<Set<string>> {
|
public async getCargoBins(): Promise<Set<string>> {
|
||||||
|
|
|
@ -26,12 +26,13 @@ async function run() {
|
||||||
core.exportVariable("CARGO_INCREMENTAL", 0);
|
core.exportVariable("CARGO_INCREMENTAL", 0);
|
||||||
|
|
||||||
const config = await CacheConfig.new();
|
const config = await CacheConfig.new();
|
||||||
|
config.printInfo();
|
||||||
|
core.info("");
|
||||||
|
|
||||||
const bins = await config.getCargoBins();
|
const bins = await config.getCargoBins();
|
||||||
core.saveState(STATE_BINS, JSON.stringify([...bins]));
|
core.saveState(STATE_BINS, JSON.stringify([...bins]));
|
||||||
|
|
||||||
core.info(`# Restoring cache`);
|
core.info(`... Restoring cache ...`);
|
||||||
config.printInfo();
|
|
||||||
const key = config.cacheKey;
|
const key = config.cacheKey;
|
||||||
const restoreKey = await cache.restoreCache(config.cachePaths, key, [config.restoreKey]);
|
const restoreKey = await cache.restoreCache(config.cachePaths, key, [config.restoreKey]);
|
||||||
if (restoreKey) {
|
if (restoreKey) {
|
||||||
|
|
|
@ -21,6 +21,8 @@ async function run() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const config = await CacheConfig.new();
|
const config = await CacheConfig.new();
|
||||||
|
config.printInfo();
|
||||||
|
core.info("");
|
||||||
|
|
||||||
if (core.getState(STATE_KEY) === config.cacheKey) {
|
if (core.getState(STATE_KEY) === config.cacheKey) {
|
||||||
core.info(`Cache up-to-date.`);
|
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
|
// TODO: remove this once https://github.com/actions/toolkit/pull/553 lands
|
||||||
await macOsWorkaround();
|
await macOsWorkaround();
|
||||||
|
|
||||||
core.info(`# Cleaning Cache`);
|
core.info(`... Cleaning Cache ...`);
|
||||||
config.printInfo();
|
|
||||||
|
|
||||||
const registryName = await getRegistryName(config);
|
const registryName = await getRegistryName(config);
|
||||||
|
|
||||||
|
@ -66,7 +67,7 @@ async function run() {
|
||||||
core.info(`[warning] ${(e as any).stack}`);
|
core.info(`[warning] ${(e as any).stack}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
core.info(`# Saving cache`);
|
core.info(`... Saving cache ...`);
|
||||||
await cache.saveCache(config.cachePaths, config.cacheKey);
|
await cache.saveCache(config.cachePaths, config.cacheKey);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
core.info(`[warning] ${(e as any).stack}`);
|
core.info(`[warning] ${(e as any).stack}`);
|
||||||
|
|
|
@ -9,7 +9,9 @@ export class Workspace {
|
||||||
let packages: Packages = [];
|
let packages: Packages = [];
|
||||||
try {
|
try {
|
||||||
const meta: Meta = JSON.parse(
|
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) {
|
for (const pkg of meta.packages) {
|
||||||
if (!pkg.manifest_path.startsWith(this.root)) {
|
if (!pkg.manifest_path.startsWith(this.root)) {
|
||||||
|
|
Loading…
Reference in a new issue