File tree Expand file tree Collapse file tree 2 files changed +24
-4
lines changed
Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change 1+ check-mirrors-summary.md
Original file line number Diff line number Diff line change 11#! /bin/sh
22
3+ summary_path=" ${GITHUB_STEP_SUMMARY:- check-mirrors-summary.md} "
34temp_path=" $( mktemp) "
45
56zig_version=" $( curl -sSL ' https://ziglang.org/download/index.json' | jq -r ' .master.version' ) "
6- filename=" zig-linux- x86_64-$zig_version .tar.xz"
7+ filename=" zig-x86_64-linux -$zig_version .tar.xz"
78
89curl -L " https://ziglang.org/builds/$filename " > " $temp_path "
910correct_sum=" $( sha512sum " $temp_path " ) "
1011
12+ rm " $summary_path "
13+
14+ echo " | URL | Owner | Result | Time (s) |" >> " $summary_path "
15+ echo " |:----|:------|:-------|---------:|" >> " $summary_path "
16+
1117jq ' .[] | .[0] + " " + .[1]' -r < mirrors.json | while read -r mirror_url mirror_name; do
12- curl -L " $mirror_url /$filename " > " $temp_path "
18+ time_secs= " $( curl -w " %{time_total} " - L " $mirror_url /$filename " -o " $temp_path " ) "
1319 download_status=" $? "
14- mirror_sum=" $( sha512sum " $temp_path " ) "
1520
1621 if [ " $download_status " -eq 0 ]; then
22+ mirror_sum=" $( sha512sum " $temp_path " ) "
1723 if [ " $mirror_sum " = " $correct_sum " ]; then
18- continue
24+ err=" " # success
25+ else
26+ err=" checksum mismatch: $mirror_sum (expected $correct_sum )"
1927 fi
28+ else
29+ err=" curl exit status: $download_status "
30+ fi
31+
32+ md_time_secs=" $( printf ' `%0.2f`' " $time_secs " ) " # 2dp, backticks
33+ md_mirror_name=" $( echo " $mirror_name " | sed -e ' s/[<>]/\\\0/g' ) " # backslash-prefix angle brackets
34+ md_status=" $( if [ " $err " = " " ]; then echo " :white_check_mark:" ; else echo " :warning: \` $err \` " ; fi) " # tick or cross for success
35+ echo " | $mirror_url | $md_mirror_name | $md_status | $md_time_secs |" >> " $summary_path "
36+
37+ if [ " $err " = " " ]; then
38+ continue # success
2039 fi
2140
2241 curl -s \
You can’t perform that action at this time.
0 commit comments