summaryrefslogtreecommitdiff
path: root/.gitlab-ci/run-style-check.sh
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2021-10-19 14:36:37 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2021-10-19 16:37:00 +0100
commitbe9bd124cf829e442793db02910b3915eb3bf83b (patch)
tree363a2c2da4bc177244ab77c4fb31d4a752f868fa /.gitlab-ci/run-style-check.sh
parent51902fc68421e7bb9135424b2d903c43e77675bf (diff)
downloadlibgweather-be9bd124cf829e442793db02910b3915eb3bf83b.tar.gz
ci: Post the style check output as a comment on the MR
If the job is part of a merge request.
Diffstat (limited to '.gitlab-ci/run-style-check.sh')
-rwxr-xr-x.gitlab-ci/run-style-check.sh23
1 files changed, 12 insertions, 11 deletions
diff --git a/.gitlab-ci/run-style-check.sh b/.gitlab-ci/run-style-check.sh
index 86c142b..b47ea3f 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}