@@ -18,122 +18,122 @@ latest_id=$(gh run list --limit 30 --workflow $workflow --status success --json
1818} | select(.minutes > 10))
1919| .[0].databaseId
2020' )
21- jobs= $( gh api /repos/$owner /$repo /actions/runs/$latest_id /jobs --jq '
22- .jobs
23- ' )
24- # | map({name: .name, run_id: .run_id, id: .id, started_at: .started_at, completed_at: .completed_at})
25-
26- echo $jobs
27-
28- # # Skip 3.10, float32, and Benchmark tests
29- # function skip_job() {
30- # name=$1
31- # # if [[ $name == *"py3.10"* ]]; then
32- # # return 0
33- # # fi
34- # #
35- # # if [[ $name == *"float32 1"* ]]; then
36- # # return 0
37- # # fi
38- # #
39- # # if [[ $name == *"Benchmark"* ]]; then
40- # # return 0
41- # # fi
42- #
43- # return 1
44- # }
45- #
46- # # Remove common prefix from the name
47- # function remove_prefix() {
48- # name=$1
49- # echo $name
50- # # echo $name | sed -e 's/^ubuntu-latest test py3.12 numpy>=2.0 : fast-compile 0 : float32 0 : //'
51- # }
52- #
53- # function human_readable_time() {
54- # started_at=$1
55- # completed_at=$2
56- #
57- # start_seconds=$(date -d "$started_at" +%s)
58- # end_seconds =$(date -d "$completed_at" +%s )
59- #
60- # seconds=$(($end_seconds - $start_seconds))
61- #
62- # if [ $seconds -lt 60 ]; then
63- # echo "$seconds seconds"
64- # else
65- # echo "$(date -u -d @$seconds +'%-M minutes %-S seconds')"
66- # fi
67- # }
68- #
69- # all_times=""
70- # echo "$jobs " | jq -c '.[]' | while read -r job; do
71- # id =$(echo $job | jq -r '.id ')
72- # name =$(echo $job | jq -r '.name ')
73- # run_id =$(echo $job | jq -r '.run_id ')
74- # started_at =$(echo $job | jq -r '.started_at ')
75- # completed_at=$(echo $job | jq -r '.completed_at')
76- #
77- # if skip_job $name; then
78- # echo "Skipping $name"
79- # continue
80- # fi
81- #
82- # echo "Processing job: $name (ID: $id, Run ID: $run_id)"
83- #
84- # # Seeing a bit more stabilty with the API rather than the CLI
85- # # https://docs.github.com/en/rest/ actions/workflow- jobs?apiVersion=2022-11-28#download-job- logs-for-a-workflow-run
86- # times=$(gh api /repos/$owner/$repo/actions/jobs/$id/logs | python extract-slow-tests.py)
87- # # times=$(gh run view --job $id --log | python extract-slow-tests.py)
88- #
89- # if [ -z "$times" ]; then
90- # # Some of the jobs are non-test jobs, so we skip them
91- # echo "No tests found for '$name', skipping"
92- # continue
93- # fi
94- #
95- # echo $times
96- #
97- # human_readable =$(human_readable_time $started_at $completed_at )
98- # name=$(remove_prefix $name)
99- #
100- # top="<details><summary>($human_readable) $name</summary>\n\n\n\ `\`\`"
101- # bottom="\`\`\`\n\n</details>"
102- #
103- # formatted_times="$top\n$times\n$bottom"
104- #
105- # if [ -n "$all_times" ]; then
106- # all_times="$all_times\n$formatted_times"
107- # else
108- # all_times="$formatted_times"
109- # fi
110- # done
111- #
112- # # if [ -z "$all_times" ]; then
113- # # echo "No slow tests found, exiting"
114- # # exit 1
115- # # fi
116- #
117- # run_date =$(date +"%Y-%m-%d")
118- # body=$(cat << EOF
119- # If you are motivated to help speed up some tests, we would appreciate it!
120- #
121- # Here are some of the slowest test times:
122- #
123- # $all_times
124- #
125- # You can find more information on how to contribute [here]($contributing_url)
126- #
127- # Automatically generated by [GitHub Action]($action_url)
128- # Latest run date: $run_date
129- # Run logs: [$latest_id](https://github.com/$owner/$repo/actions/runs/$latest_id)
130- # EOF
131- # )
132- #
133- # if [ "$DRY_RUN" = true ]; then
134- # echo "Dry run, not updating issue"
135- # echo $body
136- # exit
137- # fi
138- # echo $body | gh issue edit $issue_number --body-file - --title "$title"
139- # echo "Updated issue $issue_number with all times"
21+ gh api /repos/$owner /$repo /actions/runs/$latest_id /jobs --jq '
22+ .jobs
23+ | map({name, id, run_id, node_id, started_at, completed_at} )
24+ ' > tmp.json
25+
26+ # Skip 3.10, float32, and Benchmark tests
27+ function skip_job() {
28+ name= $1
29+ # if [[ $name == *"py3.10"* ]]; then
30+ # return 0
31+ # fi
32+ #
33+ # if [[ $name == *"float32 1"* ]]; then
34+ # return 0
35+ # fi
36+ #
37+ # if [[ $name == *"Benchmark"* ]]; then
38+ # return 0
39+ # fi
40+
41+ return 1
42+ }
43+
44+ # Remove common prefix from the name
45+ function remove_prefix() {
46+ name= $1
47+ echo $name
48+ # echo $ name | sed -e 's/^ubuntu-latest test py3.12 numpy>=2.0 : fast-compile 0 : float32 0 : //'
49+ }
50+
51+ function human_readable_time() {
52+ started_at= $1
53+ completed_at= $2
54+
55+ start_seconds= $( date -d " $started_at " +%s )
56+ end_seconds= $( date -d " $completed_at " +%s )
57+
58+ seconds =$(( $end_seconds - $start_seconds ) )
59+
60+ if [ $seconds -lt 60 ] ; then
61+ echo " $seconds seconds "
62+ else
63+ echo " $( date -u -d @ $ seconds + ' %-M minutes %-S seconds' ) "
64+ fi
65+ }
66+
67+
68+ all_times= " "
69+ cat tmp.json | jq -c ' .[] ' | while IFS= read -r job ; do
70+ id= $( printf ' %s ' " $job " | jq -r ' .id ' )
71+ name =$( printf ' %s ' " $job " | jq -r ' .name ' )
72+ run_id =$( printf ' %s ' " $job " | jq -r ' .run_id ' )
73+ started_at =$( printf ' %s ' " $job " | jq -r ' .started_at ' )
74+ completed_at =$( printf ' %s ' " $job " | jq -r ' .completed_at ' )
75+
76+ if skip_job $name ; then
77+ echo " Skipping $name "
78+ continue
79+ fi
80+
81+ echo " Processing job: $name (ID: $id , Run ID: $run_id ) "
82+
83+ # Seeing a bit more stabilty with the API rather than the CLI
84+ # https://docs.github.com/en/rest/actions/workflow-jobs?apiVersion=2022-11-28#download-job-logs-for-a-workflow-run
85+ times= $( gh api /repos/ $owner / $repo / actions/jobs/ $id / logs | python extract-slow-tests.py )
86+ # times=$(gh run view --job $id --log | python extract-slow-tests.py)
87+
88+ if [ -z " $times " ] ; then
89+ # Some of the jobs are non-test jobs, so we skip them
90+ echo " No tests found for ' $name ', skipping "
91+ continue
92+ fi
93+
94+ echo $times
95+
96+ human_readable= $( human_readable_time $started_at $completed_at )
97+ name =$( remove_prefix $name )
98+
99+ top= " <details><summary>( $human_readable ) $name </summary>\n\n\n \`\`\` "
100+ bottom= " \ `\`\`\n\n</details> "
101+
102+ formatted_times= " $top \n $times \n $bottom "
103+
104+ if [ -n " $all_times " ] ; then
105+ all_times= " $all_times \n $formatted_times "
106+ else
107+ all_times= " $formatted_times "
108+ fi
109+ done
110+
111+ if [ -z " $all_times " ] ; then
112+ echo " No slow tests found, exiting "
113+ exit 1
114+ fi
115+
116+ run_date= $( date + " %Y-%m-%d " )
117+ body =$( cat << EOF
118+ If you are motivated to help speed up some tests, we would appreciate it!
119+
120+ Here are some of the slowest test times:
121+
122+ $all_times
123+
124+ You can find more information on how to contribute [here]( $contributing_url )
125+
126+ Automatically generated by [GitHub Action]( $action_url )
127+ Latest run date: $run_date
128+ Run logs: [ $latest_id ](https://github.com/ $owner / $repo /actions/runs/ $latest_id )
129+ EOF
130+ )
131+
132+ if [ " $DRY_RUN " = true ] ; then
133+ echo " Dry run, not updating issue "
134+ echo $body
135+ exit
136+ fi
137+
138+ echo $body | gh issue edit $issue_number --body-file - --title " $title "
139+ echo " Updated issue $issue_number with all times"
0 commit comments