From b919e1427f59422679cf2ed5fc6ddc010f753026 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Fri, 4 Aug 2023 20:39:02 +1000 Subject: [PATCH] feat: Add logging to `Cargo.lock`/`Cargo.toml` hashing (#156) There are a few problems in cargo-binstall where sometimes change to `Cargo.lock` does not invalidate the cache. Signed-off-by: Jiahao XU --- dist/restore/index.js | 9 +++++---- dist/save/index.js | 9 +++++---- src/config.ts | 9 +++++---- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/dist/restore/index.js b/dist/restore/index.js index b888c6a..51219fe 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -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); } } @@ -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; } @@ -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); } } diff --git a/dist/save/index.js b/dist/save/index.js index 8a1e3e9..a11263d 100644 --- a/dist/save/index.js +++ b/dist/save/index.js @@ -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); } } @@ -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; } @@ -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); } } diff --git a/src/config.ts b/src/config.ts index 4bbe68d..07b2eaf 100644 --- a/src/config.ts +++ b/src/config.ts @@ -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); } } @@ -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; } @@ -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); } }