szha commented on a change in pull request #20433:
URL: https://github.com/apache/incubator-mxnet/pull/20433#discussion_r709644361
##########
File path: ci/docker/runtime_functions.sh
##########
@@ -716,6 +717,43 @@ sanity_cpp() {
3rdparty/dmlc-core/scripts/lint.py mxnet cpp include src plugin
cpp-package tests --exclude_path src/operator/contrib/ctc_include include/onednn
}
+sanity_clang() {
+ set -ex
+ # .github/workgflows/greetings.yml passes BASE_SHA, GITHUB_RUN_ID,
GITHUB_BASE_REF for pull requests.
+ BASE_SHA="${GITHUB_PR_BASE_SHA}"
+ GITHUB_RUN_ID="${GITHUB_PR_RUN_ID}"
+ GITHUB_BASE_REF="${GITHUB_PR_BASE_REF}"
+
+ if [ "${BASE_SHA}" == "" ]; then
+ BASE_SHA=`git show-ref --hash refs/remotes/origin/master`
+ if [ "${GITHUB_RUN_ID}" == "" ] || [ "${GITHUB_BASE_REF}" == "" ]; then
+ GITHUB_RUN_ID=`(git log --pretty=format:'%h' -n 1)`
+ GITHUB_BASE_REF="master"
+ fi
+ fi
+
+ git remote add "${GITHUB_RUN_ID}"
https://github.com/apache/incubator-mxnet.git
+ git fetch "${GITHUB_RUN_ID}" "$GITHUB_BASE_REF"
+
+ tools/lint/clang_format_ci.sh "${BASE_SHA}"
+ GIT_DIFFERENCE=$(git diff)
+ if [[ -z $GIT_DIFFERENCE ]]; then
+ git remote remove "${GITHUB_RUN_ID}" # temporary remote is removed
+ exit 0
+ fi
+
+ echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
+ echo "| clang-format failures found! Run: "
+ echo "| tool/lint/clang_format_ci.sh ${BASE_SHA} "
+ echo "| to fix this error. "
+ echo "| For more info, see: "
+ echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
+
+ echo "$GIT_DIFFERENCE"
+ git remote remove "${GITHUB_RUN_ID}" # temporary remote is removed
+ exit 1
Review comment:
If you exit on 742, who takes care of removing the added remote on 753?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]