Skip to content

Commit

Permalink
fix(ci): multiline regex in change detection (apache#13075)
Browse files Browse the repository at this point in the history
* fix(ci): multiline regex in change detection

* fix shellcheck issues
  • Loading branch information
villebro authored and amitmiran137 committed Feb 14, 2021
1 parent 0fbc826 commit 5fc1f85
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions scripts/ci_check_no_file_changes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,7 @@
URL="https://api.github.com/repos/${GITHUB_REPO}/pulls/${PR_NUMBER}/files"
FILES=$(curl -s -X GET -G "${URL}" | jq -r '.[] | .filename')

cat<<EOF
CHANGED FILES:
$FILES
EOF

REGEXES=()
for CHECK in "$@"
do
if [[ ${CHECK} == "python" ]]; then
Expand All @@ -44,11 +39,26 @@ do
echo "Invalid check: \"${CHECK}\". Falling back to exiting with FAILURE code"
exit 1
fi
REGEXES=("${REGEXES[@]}" "${REGEX}")
done
echo

if [[ "${FILES}" =~ ${REGEX} ]]; then
echo "Detected changes... Exiting with FAILURE code"
exit 1
fi
cat<<EOF
CHANGED FILES:
$FILES
EOF

for FILE in ${FILES}
do
for REGEX in "${REGEXES[@]}"
do
if [[ "${FILE}" =~ ${REGEX} ]]; then
echo "Detected changes in following file: ${FILE}"
echo "Exiting with FAILURE code"
exit 1
fi
done
done
echo "No changes detected... Exiting with SUCCESS code"
exit 0

0 comments on commit 5fc1f85

Please sign in to comment.