4444
4545compilation_errors_warnings_out=" $1 "
4646cmake_output_log=" $2 "
47- build_number =" $3 "
47+ comment_title =" $3 "
4848pull_request_number=" $4 "
4949repository_name=" $5 "
5050github_token=" $6 "
5151build_id=" $7 "
5252job_name=" $8 "
5353job_status=" $9 "
54+ commit_sha=" ${10} "
55+ commit_date=" ${11} "
5456
5557echo " job_status: $job_status "
5658if [[ " $job_status " == " success" || " $job_status " == " failure" ]]; then
@@ -63,31 +65,40 @@ warnings_errors=$(cat "$compilation_errors_warnings_out")
6365
6466delimiter=" -=-=-=-"
6567tests_failures=" "
66- if [[ -f " $cmake_output_log " ]]; then
68+ if test -f " $cmake_output_log "
69+ then
6770 tests_failures=$( < " $cmake_output_log " sed -n -e ' /The following tests FAILED:/,$p' )
6871 tests_failures=${tests_failures// $' \n ' / $delimiter }
6972 tabulation=" "
7073 tests_failures=${tests_failures// $' \t ' / $tabulation }
7174fi
7275
73- if [[ " $succeeded " -eq 1 ]]; then
74- [[ -z " $warnings_errors " ]] && warnings_errors=' Compilation - successful'
75- [[ -z " $tests_failures " ]] && tests_failures=' Testing - passed'
76+ if test " $succeeded " -eq 1
77+ then
78+ if test -z " $warnings_errors "
79+ then
80+ warnings_errors=' Compilation - successful'
81+ fi
82+
83+ if test -z " $tests_failures "
84+ then
85+ tests_failures=' Testing - passed'
86+ fi
7687else
77- if [[ -z " $warnings_errors " && -z " $tests_failures " ]]; then
88+ if test -z " $warnings_errors " && test -z " $tests_failures "
89+ then
7890 warnings_errors=' Build failed for unknown reason. Check build logs'
7991 fi
8092fi
8193
94+ # Concatenate both reports into one
8295val=" $warnings_errors " " $delimiter " " $delimiter " " $tests_failures "
8396max_comment_size=3000
84- if [[ ${# val} -gt " $max_comment_size " ]]; then
97+ if test ${# val} -gt " $max_comment_size "
98+ then
8599 val=" ${val: 0: max_comment_size} %0D%0A%0D%0A%0D%0A ==> And there is more. Read log. <=="
86100fi
87101
88- commit_sha=" $( git log --skip=1 -1 --pretty=format:%H) "
89- commit_date=" $( TZ=UTC0 git show -s --format=%cd --date=format-local:' %Y-%m-%d %H:%M:%S' " $commit_sha " ) "
90-
91102# Fetch numeric job ID from GitHub API
92103job_id=$( curl -s -H " Authorization: token $github_token " \
93104 " https://api.github.com/repos/${repository_name} /actions/runs/${build_id} /jobs" | \
@@ -100,17 +111,26 @@ else
100111 build_link=" [Build log](https://github.com/${repository_name} /actions/runs/${build_id} )"
101112fi
102113
114+ # Build comment
115+ commit_sha=" $( git log --skip=1 -1 --pretty=format:%H) "
116+ commit_date=" $( TZ=UTC0 git show -s --format=%cd --date=format-local:' %Y-%m-%d %H:%M:%S' " $commit_sha " ) "
117+ build_link=' [Build log](https://dev.azure.com/DARMA-tasking/DARMA/_build/results?buildId=' " $build_id " ' &view=logs&j=' " $job_id " ' &t=' " $task_id )"
103118comment_body=" Build for $commit_sha ($commit_date UTC)\n\n" ' ```' " \n$val \n" ' ```' " \n\n$build_link "
104- comment_body=${comment_body// $delimiter / $' \n ' }
105- comment_body=${comment_body// \" / \\\" }
119+
120+ # Fix new lines
121+ new_line=" \n"
122+ comment_body=${comment_body// $delimiter / $new_line }
123+ quotation_mark=" \" "
124+ new_quotation_mark=" \\\" "
125+ comment_body=${comment_body// $quotation_mark / $new_quotation_mark }
106126
107127rm -f data.json
108128
109129{
110130echo " {"
111131echo ' "event_type": "comment-pr",'
112132echo ' "client_payload": {'
113- echo ' "comment_title": "' " $build_number " ' ",'
133+ echo ' "comment_title": "' " $comment_title " ' ",'
114134echo ' "comment_content": "' " $comment_body " ' ",'
115135echo ' "pr_number": "' " $pull_request_number " ' "'
116136echo " }"
0 commit comments