Skip to content

Commit

Permalink
feat: Add logging to Cargo.lock/Cargo.toml hashing (#156)
Browse files Browse the repository at this point in the history
There are a few problems in cargo-binstall where sometimes change to
`Cargo.lock` does not invalidate the cache.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
  • Loading branch information
NobodyXu authored Aug 4, 2023
1 parent b8a6852 commit b919e14
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
9 changes: 5 additions & 4 deletions dist/restore/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67029,8 +67029,8 @@ class CacheConfig {
hasher.update(JSON.stringify(parsed));
parsedKeyFiles.push(cargo_manifest);
}
catch (_e) {
// Fallback to caching them as regular file
catch (e) { // Fallback to caching them as regular file
lib_core.warning(`Error parsing Cargo.toml manifest, fallback to caching entire file: ${e}`);
keyFiles.push(cargo_manifest);
}
}
Expand All @@ -67042,6 +67042,7 @@ class CacheConfig {
if (parsed.version !== 3 || !("package" in parsed)) {
// Fallback to caching them as regular file since this action
// can only handle Cargo.lock format version 3
lib_core.warning('Unsupported Cargo.lock format, fallback to caching entire file');
keyFiles.push(cargo_lock);
continue;
}
Expand All @@ -67053,8 +67054,8 @@ class CacheConfig {
hasher.update(JSON.stringify(packages));
parsedKeyFiles.push(cargo_lock);
}
catch (_e) {
// Fallback to caching them as regular file
catch (e) { // Fallback to caching them as regular file
lib_core.warning(`Error parsing Cargo.lock manifest, fallback to caching entire file: ${e}`);
keyFiles.push(cargo_lock);
}
}
Expand Down
9 changes: 5 additions & 4 deletions dist/save/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67029,8 +67029,8 @@ class CacheConfig {
hasher.update(JSON.stringify(parsed));
parsedKeyFiles.push(cargo_manifest);
}
catch (_e) {
// Fallback to caching them as regular file
catch (e) { // Fallback to caching them as regular file
core.warning(`Error parsing Cargo.toml manifest, fallback to caching entire file: ${e}`);
keyFiles.push(cargo_manifest);
}
}
Expand All @@ -67042,6 +67042,7 @@ class CacheConfig {
if (parsed.version !== 3 || !("package" in parsed)) {
// Fallback to caching them as regular file since this action
// can only handle Cargo.lock format version 3
core.warning('Unsupported Cargo.lock format, fallback to caching entire file');
keyFiles.push(cargo_lock);
continue;
}
Expand All @@ -67053,8 +67054,8 @@ class CacheConfig {
hasher.update(JSON.stringify(packages));
parsedKeyFiles.push(cargo_lock);
}
catch (_e) {
// Fallback to caching them as regular file
catch (e) { // Fallback to caching them as regular file
core.warning(`Error parsing Cargo.lock manifest, fallback to caching entire file: ${e}`);
keyFiles.push(cargo_lock);
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ export class CacheConfig {
hasher.update(JSON.stringify(parsed));

parsedKeyFiles.push(cargo_manifest);
} catch (_e) {
// Fallback to caching them as regular file
} catch (e) { // Fallback to caching them as regular file
core.warning(`Error parsing Cargo.toml manifest, fallback to caching entire file: ${e}`);
keyFiles.push(cargo_manifest);
}
}
Expand All @@ -191,6 +191,7 @@ export class CacheConfig {
if (parsed.version !== 3 || !("package" in parsed)) {
// Fallback to caching them as regular file since this action
// can only handle Cargo.lock format version 3
core.warning('Unsupported Cargo.lock format, fallback to caching entire file');
keyFiles.push(cargo_lock);
continue;
}
Expand All @@ -204,8 +205,8 @@ export class CacheConfig {
hasher.update(JSON.stringify(packages));

parsedKeyFiles.push(cargo_lock);
} catch (_e) {
// Fallback to caching them as regular file
} catch (e) { // Fallback to caching them as regular file
core.warning(`Error parsing Cargo.lock manifest, fallback to caching entire file: ${e}`);
keyFiles.push(cargo_lock);
}
}
Expand Down

0 comments on commit b919e14

Please sign in to comment.