Skip to content

Commit 88d4876

Browse files
committed
add human readable time difference
1 parent a5895c7 commit 88d4876

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

scripts/slowest_tests/update-slowest-times-issue.sh

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ issue_number=1124
88
title="Speed up test times :rocket:"
99
workflow=Tests
1010
latest_id=$(gh run list --workflow $workflow --status success --limit 1 --json databaseId --jq '.[0].databaseId')
11-
jobs=$(gh api /repos/$owner/$repo/actions/runs/$latest_id/jobs --jq '.jobs | map({name: .name, run_id: .run_id, id: .id})')
11+
jobs=$(gh api /repos/$owner/$repo/actions/runs/$latest_id/jobs --jq '.jobs | map({name: .name, run_id: .run_id, id: .id, started_at: .started_at, completed_at: .completed_at})')
1212

1313
# Skip 3.10, float32, and Benchmark tests
1414
function skip_job() {
@@ -34,11 +34,31 @@ function remove_prefix() {
3434
echo $name | sed -e 's/^ubuntu-latest test py3.12 : fast-compile 0 : float32 0 : //'
3535
}
3636

37+
function human_readable_time() {
38+
started_at=$1
39+
completed_at=$2
40+
41+
start_seconds=$(date -d "$started_at" +%s)
42+
end_seconds=$(date -d "$completed_at" +%s)
43+
44+
seconds=$(($end_seconds - $start_seconds))
45+
46+
if [ $seconds -lt 60 ]; then
47+
echo "$seconds seconds"
48+
else
49+
echo "$(date -u -d @$seconds +'%-M minutes %-S seconds')"
50+
fi
51+
}
52+
3753
all_times=""
3854
echo "$jobs" | jq -c '.[]' | while read -r job; do
3955
id=$(echo $job | jq -r '.id')
4056
name=$(echo $job | jq -r '.name')
4157
run_id=$(echo $job | jq -r '.run_id')
58+
started_at=$(echo $job | jq -r '.started_at')
59+
completed_at=$(echo $job | jq -r '.completed_at')
60+
61+
human_readable=$(human_readable_time $started_at $completed_at)
4262

4363
if skip_job $name; then
4464
echo "Skipping $name"
@@ -56,9 +76,13 @@ echo "$jobs" | jq -c '.[]' | while read -r job; do
5676

5777
echo $times
5878

79+
human_readable=$(human_readable_time $started_at $completed_at)
80+
81+
echo $human_readable
82+
5983
name=$(remove_prefix $name)
6084

61-
top="<details><summary>$name</summary>\n\n\n\`\`\`"
85+
top="<details><summary>($human_readable) $name</summary>\n\n\n\`\`\`"
6286
bottom="\`\`\`\n\n</details>"
6387

6488
formatted_times="$top\n$times\n$bottom"

0 commit comments

Comments
 (0)