Skip to content

Commit 946f4af

Browse files
gdubickiautarch
authored andcommitted
Fix caching when the effective cache key would contain spaces
This can happen when the OS name is something like "Ubuntu 24.04.4 LTS", for example. Also, to be safer, we replace all other whitespace with dashes too.
1 parent 17e4565 commit 946f4af

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

Changes.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
## 0.0.8
1+
## 1.0.7
22

33
- Fixed a bug in calculating the `cross` binary's hash.
4+
- Fixed cache key handling to deal with spaces in cache key elements, for example in the OS version.
5+
Reported by @gdubicki (Greg Dubicki). GH #50. Fixes #1.
46

57
## 1.0.6 2026-03-15
68

parse-and-set-rust-cache-parameters.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import os
55
import sys
66
import hashlib
7+
import re
78

89

910
def main():
@@ -32,6 +33,8 @@ def main():
3233
get_file_hash(build_command)
3334
)
3435

36+
parameters["key"] = sanitize_key(parameters["key"])
37+
3538
file = os.environ["GITHUB_OUTPUT"]
3639
with open(file, "w") as f:
3740
for key, value in parameters.items():
@@ -46,4 +49,9 @@ def get_file_hash(build_command):
4649
return file_hash.hexdigest()
4750

4851

52+
def sanitize_key(key):
53+
# cache key cannot contain any whitespace
54+
return re.sub(r"\s+", "-", key)
55+
56+
4957
main()

0 commit comments

Comments
 (0)