Skip to content

Commit 45bfd5c

Browse files
committed
run-vmtest: add path normalization script
actions/upload-artifacts has restrictions on what characters can be used in uploaded paths. Add a script that replaces forbidden characters in all paths under a specified directory. We ran into this problem when trying to upload traffic monitor logs (which may contain a colon `:`). But since it's a github-specific restriction, it doesn't make sense to enforce it upstream. Signed-off-by: Ihor Solodrai <[email protected]>
1 parent fe465b7 commit 45bfd5c

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
# Github's actions/upload-artifact has restriction on the characters that can be used in a path.
6+
# Invalid characters include:
7+
# Double quote ",
8+
# Colon :,
9+
# Less than <,
10+
# Greater than >,
11+
# Vertical bar |,
12+
# Asterisk *,
13+
# Question mark ?,
14+
# Carriage return \r,
15+
# Line feed \n
16+
17+
DIR=$1
18+
if [[ ! -d "$DIR" ]]; then
19+
exit 0
20+
fi
21+
22+
normalize() {
23+
local path="$1"
24+
echo -n "$path" | tr '":><|*?\r\n' '_________'
25+
}
26+
27+
find "$DIR" -depth | while read -r path; do
28+
if [[ "$path" == "$DIR" ]]; then
29+
continue
30+
fi
31+
dirname=$(dirname "$path")
32+
basename=$(basename "$path")
33+
new_basename=$(normalize "$basename")
34+
if [[ "$basename" != "$new_basename" ]]; then
35+
new_path="${dirname}/${new_basename}"
36+
mv -v "$path" "$new_path"
37+
fi
38+
done

run-vmtest/run.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ vmtest -k "${VMLINUZ}" --kargs "panic=-1 sysctl.vm.panic_on_oom=1" \
9191
cd '${GITHUB_WORKSPACE}' && \
9292
${VMTEST_SCRIPT} ${TEST_RUNNERS}"
9393

94+
# fixup traffic montioring log paths if present
95+
PCAP_DIR=/tmp/tmon_pcap
96+
${GITHUB_ACTION_PATH}/normalize-paths-for-github.sh "$PCAP_DIR"
97+
9498
foldable end vmtest
9599

96100
foldable start collect_status "Collecting exit status"

0 commit comments

Comments
 (0)