5 Commits

Author SHA1 Message Date
Arpad Borsos
578b235f6e 2.6.1
Some checks failed
buildjet / Test buildjet provider on ubuntu-latest (push) Failing after 0s
coverage / Test `cargo-llvm-cov` on ubuntu-latest (push) Failing after 0s
git-registry / Test cargo "git" registry on ubuntu-latest (push) Failing after 0s
install / Test `cargo install` on ubuntu-latest (push) Failing after 0s
simple / Test `cargo check/test/build` on ubuntu-latest (push) Failing after 0s
target-dir / Test custom target-dir on ubuntu-latest (push) Failing after 0s
workspaces / Test multiple workspaces on ubuntu-latest (push) Failing after 0s
buildjet / Test buildjet provider on macos-latest (push) Has been cancelled
buildjet / Test buildjet provider on windows-latest (push) Has been cancelled
coverage / Test `cargo-llvm-cov` on macos-latest (push) Has been cancelled
coverage / Test `cargo-llvm-cov` on windows-latest (push) Has been cancelled
git-registry / Test cargo "git" registry on macos-latest (push) Has been cancelled
git-registry / Test cargo "git" registry on windows-latest (push) Has been cancelled
install / Test `cargo install` on macos-latest (push) Has been cancelled
install / Test `cargo install` on windows-latest (push) Has been cancelled
simple / Test `cargo check/test/build` on macos-latest (push) Has been cancelled
simple / Test `cargo check/test/build` on windows-latest (push) Has been cancelled
target-dir / Test custom target-dir on macos-latest (push) Has been cancelled
target-dir / Test custom target-dir on windows-latest (push) Has been cancelled
workspaces / Test multiple workspaces on macos-latest (push) Has been cancelled
workspaces / Test multiple workspaces on windows-latest (push) Has been cancelled
2023-08-12 16:51:06 +02:00
Arpad Borsos
5113490c3f prepare 2.6.1 2023-08-12 16:50:53 +02:00
Jiahao XU
c0e052c18c Fix hashing of parsed Cargo.toml (#160)
The values for the dependencies could be strings intead of objects, so
add a `try` block to take care of that.

Also set `dep.path` to `""` if the dependency contains a key `path` to
make sure that the cache isn't invalidated due to change in workspace.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-08-12 12:34:30 +02:00
Jiahao XU
4e0f4b19dd Fix typo in hashing parsed Cargo.lock (#159)
This simple mistake caused the entire `Cargo.lock` to be ignored (JS
treats having no return as `false`).

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-08-10 19:50:14 +02:00
Jiahao XU
b919e1427f 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 <Jiahao_XU@outlook.com>
2023-08-04 12:39:02 +02:00
6 changed files with 54 additions and 30 deletions

View File

@@ -1,5 +1,9 @@
# Changelog
## 2.6.1
- Fix hash contributions of `Cargo.lock`/`Cargo.toml` files.
## 2.6.0
- Add "buildjet" as a second `cache-provider` backend.

25
dist/restore/index.js vendored
View File

@@ -67021,16 +67021,24 @@ class CacheConfig {
const deps = parsed[section_name];
for (const key of Object.keys(deps)) {
const dep = deps[key];
if ("path" in dep) {
dep.version = "0.0.0";
try {
if ("path" in dep) {
dep.version = "0.0.0";
dep.path = "";
}
}
catch (_e) {
// Not an object, probably a string (version),
// continue.
continue;
}
}
}
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,19 +67050,18 @@ 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;
}
// Package without `[[package]].source` and `[[package]].checksum`
// are the one with `path = "..."` to crates within the workspace.
const packages = parsed.package.filter((p) => {
"source" in p || "checksum" in p;
});
const packages = parsed.package.filter((p) => "source" in p || "checksum" in p);
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);
}
}

25
dist/save/index.js vendored
View File

@@ -67021,16 +67021,24 @@ class CacheConfig {
const deps = parsed[section_name];
for (const key of Object.keys(deps)) {
const dep = deps[key];
if ("path" in dep) {
dep.version = "0.0.0";
try {
if ("path" in dep) {
dep.version = "0.0.0";
dep.path = "";
}
}
catch (_e) {
// Not an object, probably a string (version),
// continue.
continue;
}
}
}
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,19 +67050,18 @@ 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;
}
// Package without `[[package]].source` and `[[package]].checksum`
// are the one with `path = "..."` to crates within the workspace.
const packages = parsed.package.filter((p) => {
"source" in p || "checksum" in p;
});
const packages = parsed.package.filter((p) => "source" in p || "checksum" in p);
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);
}
}

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "rust-cache",
"version": "2.6.0",
"version": "2.6.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "rust-cache",
"version": "2.6.0",
"version": "2.6.1",
"license": "LGPL-3.0",
"dependencies": {
"@actions/buildjet-cache": "npm:github-actions.cache-buildjet@0.1.2",

View File

@@ -1,7 +1,7 @@
{
"private": true,
"name": "rust-cache",
"version": "2.6.0",
"version": "2.6.1",
"description": "A GitHub Action that implements smart caching for rust/cargo projects with sensible defaults.",
"keywords": [
"actions",

View File

@@ -166,8 +166,15 @@ export class CacheConfig {
for (const key of Object.keys(deps)) {
const dep = deps[key];
if ("path" in dep) {
dep.version = "0.0.0";
try {
if ("path" in dep) {
dep.version = "0.0.0";
dep.path = "";
}
} catch (_e) {
// Not an object, probably a string (version),
// continue.
continue;
}
}
}
@@ -175,8 +182,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,21 +198,20 @@ 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;
}
// Package without `[[package]].source` and `[[package]].checksum`
// are the one with `path = "..."` to crates within the workspace.
const packages = parsed.package.filter((p: any) => {
"source" in p || "checksum" in p;
});
const packages = parsed.package.filter((p: any) => "source" in p || "checksum" in p);
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);
}
}