blob: 69dbea3457506695fe9e67faa8dad091f435e172 (
about) (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
#!/bin/sh
set -eu
TLD="$(cat aux/tld.txt)"
while getopts 'n:o:' flag; do
case "$flag" in
n)
PROJECT="$OPTARG"
;;
o)
OUTDIR="$OPTARG"
;;
*)
exit 2
;;
esac
done
shift $((OPTIND - 1))
assert_arg() {
if [ -z "$1" ]; then
echo "Missing $2" >&2
exit 2
fi
}
assert_arg "${PROJECT:-}" '-n PROJECT'
assert_arg "${OUTDIR:-}" '-o OUTDIR'
PASS='✅'
FAIL='❌'
mkdir -p "$OUTDIR/ci-logs" "$OUTDIR/ci-data"
OUT="$(mktemp)"
chmod 644 "$OUT"
git fetch origin refs/notes/ci-data:refs/notes/ci-data ||: &
git fetch origin refs/notes/ci-logs:refs/notes/ci-logs ||: &
git fetch origin refs/notes/commits:refs/notes/commits ||: &
wait
for c in $(git notes list | cut -d\ -f2); do
DATA="$(git notes --ref=refs/notes/ci-data show "$c")"
FILENAME="$(echo "$DATA" | cut -d\ -f2)"
echo "$DATA" > "$OUTDIR/ci-data/$FILENAME"
git notes --ref=refs/notes/ci-logs show "$c" > "$OUTDIR/ci-logs/$FILENAME"
done
cat <<EOF >> "$OUT"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/svg+xml" href="favicon.svg" />
<title>CI logs for $PROJECT</title>
<style>
pre {
display: inline;
}
</style>
</head>
<body>
<h1>
CI logs for <a href="https://$TLD/$PROJECT/">$PROJECT</a>
</h1>
<ul>
EOF
for f in $(find "$OUTDIR/ci-data/" -type f | LANG=C.UTF-8 sort -r); do
DATA="$(cat "$f")"
STATUS="$(echo "$DATA" | cut -d\ -f1)"
FILENAME="$(echo "$DATA" | cut -d\ -f2)"
if [ "$STATUS" = 0 ]; then
STATUS_MARKER="$PASS"
else
STATUS_MARKER="$FAIL"
fi
cat <<EOF >> "$OUT"
<li>
<a href="ci-logs/$FILENAME">
$STATUS_MARKER <pre>$FILENAME</pre>
</a>
</li>
EOF
done
cat <<EOF >> "$OUT"
</ul>
</body>
</html>
EOF
mv "$OUT" "$OUTDIR/ci.html"
|