-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CI check for whitespace (calling the git workflow for it)
Change-Id: I8e6678c9917ae5ef11fa790c9880f72bbc93a5c1
- Loading branch information
1 parent
8095b5e
commit f617e36
Showing
2 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
name: check-whitespace | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize] | ||
|
||
# Avoid unnecessary builds | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
check-whitespace: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: git log --check | ||
id: check_out | ||
run: | | ||
baseSha=${{ github.event.pull_request.base.sha }} | ||
problems=() | ||
commit= | ||
commitText= | ||
commitTextmd= | ||
# Store the output of git log in a variable | ||
log_output=$(git log --check --pretty=format:"---% h% s" ${baseSha}..) | ||
# Use a for loop to iterate over lines of log_output | ||
IFS=$'\n' | ||
for line in $log_output; do | ||
case "${line}" in | ||
"--- "*) | ||
commit="${line#--- }" | ||
commitText="${commit}" | ||
commitTextmd="[${commit}](https://github.com/${{ github.repository }}/commit/${commit})" | ||
;; | ||
"") | ||
;; | ||
*) | ||
if test -n "${commit}"; then | ||
problems+=("1) --- ${commitTextmd}") | ||
echo "" | ||
echo "--- ${commitText}" | ||
commit= | ||
fi | ||
case "${line}" in | ||
*:[1-9]*:) # contains file and line number information | ||
dash=${line%%:*} | ||
dashend=${line#*:} | ||
dashend=${dashend%:*} | ||
problems+=("[${line}](https://github.com/${{ github.repository }}/blob/${{github.event.pull_request.head.ref}}/${dash}#L${dashend}) ${commit}") | ||
;; | ||
*) | ||
problems+=("\`${line}\`") | ||
;; | ||
esac | ||
echo "${line}" | ||
;; | ||
esac | ||
done | ||
if test ${#problems[*]} -gt 0; then | ||
echo "⚠️ Please review the Summary output for further information." | ||
echo "### :x: A whitespace issue was found in one or more of the commits." >$GITHUB_STEP_SUMMARY | ||
echo "" >>$GITHUB_STEP_SUMMARY | ||
echo "Errors:" >>$GITHUB_STEP_SUMMARY | ||
for i in "${problems[@]}"; do | ||
echo "${i}" >>$GITHUB_STEP_SUMMARY | ||
done | ||
exit 2 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters