[libgweather/style-check-feedback: 2/4] ci: Post the style check output as a comment on the MR




commit be9bd124cf829e442793db02910b3915eb3bf83b
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Tue Oct 19 14:36:37 2021 +0100

    ci: Post the style check output as a comment on the MR
    
    If the job is part of a merge request.

 .gitlab-ci/run-style-check.sh | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)
---
diff --git a/.gitlab-ci/run-style-check.sh b/.gitlab-ci/run-style-check.sh
index 86c142b8..b47ea3fd 100755
--- a/.gitlab-ci/run-style-check.sh
+++ b/.gitlab-ci/run-style-check.sh
@@ -14,19 +14,20 @@ git diff -U0 --no-color "${newest_common_ancestor_sha}" libgweather/*.c libgweat
 )
 exit_status=$?
 
+[ ${exit_status} == 0 ] || exit ${exit_status}
+
 format_diff="$(<format-diff.log)"
 
 if [ -n "${format_diff}" ]; then
-  echo \`\`\`diff > format-diff.log
-  echo "${format_diff}" >> format-diff.log
-  echo \`\`\` >> format-diff.log
+  echo 'body=```diff' > format.log
+  cat format-diff.log >> format.log
+  echo '```' >> format.log
+  [ -n "$CI_MERGE_REQUEST_IID" ] && curl \
+    --request POST \
+    --header "Private-Token: $STYLE_CHECK_TOKEN" \
+    --data-urlencode "$(<format.log)" \
+    https://gitlab.gnome.org/api/v4/projects/$CI_PROJECT_ID/merge_requests/$CI_MERGE_REQUEST_IID/notes \
+    --insecure
+  unlink format.log
   exit 1
-  #[ -z "$CI_MERGE_REQUEST_IID" ] && curl \
-  #  --request POST \
-  #  --header "Private-Token: $FORMAT_PRIVATE_TOKEN" \
-  #  -d @format-diff.log \
-  #  
https://gitlab.your-server.com/api/v4/projects/$CI_PROJECT_ID/merge_requests/$CI_MERGE_REQUEST_IID/notes \
-  #  --insecure
 fi
-
-exit ${exit_status}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]