3 Commits

Author SHA1 Message Date
Arpad Borsos
dd05243424 2.5.1
Some checks failed
coverage / Test `cargo-llvm-cov` on ubuntu-latest (push) Failing after 0s
globbed-directories / Test `cargo check/test` on ubuntu-latest (push) Failing after 0s
install / Test `cargo install` on ubuntu-latest (push) Failing after 0s
simple / Test `cargo check/test` on ubuntu-latest (push) Failing after 0s
sparse-registry / Test `cargo check/test` with sparse registry 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
coverage / Test `cargo-llvm-cov` on macos-latest (push) Has been cancelled
coverage / Test `cargo-llvm-cov` 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` on macos-latest (push) Has been cancelled
simple / Test `cargo check/test` on windows-latest (push) Has been cancelled
sparse-registry / Test `cargo check/test` with sparse registry on macos-latest (push) Has been cancelled
sparse-registry / Test `cargo check/test` with sparse registry 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-07-03 19:38:11 +02:00
Arpad Borsos
65dbc54a5d update changelog 2023-07-03 19:38:01 +02:00
Jiahao XU
be7377e68e fix src/config.ts: Remove sort_object (#152)
Fixed #151

I've tried running manually load and parse `Cargo.lock` and it runs fine
until `sort_object` is called.

Since `Cargo.lock` is auto-generated and usually sorted, I think there
is no need for sorting.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-06-27 08:55:56 +02:00
6 changed files with 18 additions and 60 deletions

View File

@@ -1,5 +1,14 @@
# Changelog
## 2.5.1
- Fix hash contribution of `Cargo.lock`.
## 2.5.0
- feat: Rm workspace crates version before caching.
- feat: Add hash of `.cargo/config.toml` to key.
## 2.4.0
- Fix cache key stability.

21
dist/restore/index.js vendored
View File

@@ -64224,7 +64224,7 @@ class CacheConfig {
}
}
}
hasher.update(JSON.stringify(sort_object(parsed)));
hasher.update(JSON.stringify(parsed));
parsedKeyFiles.push(cargo_manifest);
}
catch (_e) { // Fallback to caching them as regular file
@@ -64247,7 +64247,7 @@ class CacheConfig {
const packages = parsed.package.filter((p) => {
"source" in p || "checksum" in p;
});
hasher.update(JSON.stringify(sort_object(packages)));
hasher.update(JSON.stringify(packages));
parsedKeyFiles.push(cargo_lock);
}
catch (_e) { // Fallback to caching them as regular file
@@ -64387,23 +64387,6 @@ function sort_and_uniq(a) {
return accumulator;
}, []);
}
function sort_object(o) {
if (Array.isArray(o)) {
return o.sort().map(sort_object);
}
else if (typeof o === 'object' && o != null) {
return Object
.keys(o)
.sort()
.reduce(function (a, k) {
a[k] = sort_object(o[k]);
return a;
}, {});
}
else {
return o;
}
}
;// CONCATENATED MODULE: ./src/cleanup.ts

21
dist/save/index.js vendored
View File

@@ -64224,7 +64224,7 @@ class CacheConfig {
}
}
}
hasher.update(JSON.stringify(sort_object(parsed)));
hasher.update(JSON.stringify(parsed));
parsedKeyFiles.push(cargo_manifest);
}
catch (_e) { // Fallback to caching them as regular file
@@ -64247,7 +64247,7 @@ class CacheConfig {
const packages = parsed.package.filter((p) => {
"source" in p || "checksum" in p;
});
hasher.update(JSON.stringify(sort_object(packages)));
hasher.update(JSON.stringify(packages));
parsedKeyFiles.push(cargo_lock);
}
catch (_e) { // Fallback to caching them as regular file
@@ -64387,23 +64387,6 @@ function sort_and_uniq(a) {
return accumulator;
}, []);
}
function sort_object(o) {
if (Array.isArray(o)) {
return o.sort().map(sort_object);
}
else if (typeof o === 'object' && o != null) {
return Object
.keys(o)
.sort()
.reduce(function (a, k) {
a[k] = sort_object(o[k]);
return a;
}, {});
}
else {
return o;
}
}
;// CONCATENATED MODULE: ./src/cleanup.ts

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "rust-cache",
"version": "2.5.0",
"version": "2.5.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "rust-cache",
"version": "2.5.0",
"version": "2.5.1",
"license": "LGPL-3.0",
"dependencies": {
"@actions/cache": "^3.2.1",

View File

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

View File

@@ -172,7 +172,7 @@ export class CacheConfig {
}
}
hasher.update(JSON.stringify(sort_object(parsed)));
hasher.update(JSON.stringify(parsed));
parsedKeyFiles.push(cargo_manifest);
} catch (_e) { // Fallback to caching them as regular file
@@ -200,7 +200,7 @@ export class CacheConfig {
"source" in p || "checksum" in p
});
hasher.update(JSON.stringify(sort_object(packages)));
hasher.update(JSON.stringify(packages));
parsedKeyFiles.push(cargo_lock);
} catch (_e) { // Fallback to caching them as regular file
@@ -367,20 +367,3 @@ function sort_and_uniq(a: string[]) {
[]
);
}
function sort_object(o: any): any {
if (Array.isArray(o)) {
return o.sort().map(sort_object);
} else if (typeof o === 'object' && o != null) {
return Object
.keys(o)
.sort()
.reduce(function(a: any, k) {
a[k] = sort_object(o[k]);
return a;
}, {});
} else {
return o;
}
}