Skip to content

Add 'src/libcanard/' from commit '644d3f711f4b26f29e0e4a25a596a071388… #1314

Add 'src/libcanard/' from commit '644d3f711f4b26f29e0e4a25a596a071388…

Add 'src/libcanard/' from commit '644d3f711f4b26f29e0e4a25a596a071388… #1314

name: General Formatting Checks
on:
- pull_request
- push
jobs:
general-formatting-checks:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
# https://github.com/per1234/formatting-checks
- name: Check for files starting with a blank line
run: find . -path './.git' -prune -or -path './src/types' -prune -or -path './libcanard' -prune -or -path './extras/test/external' -prune -or -type f -print0 | xargs -0 -L1 bash -c 'tail -1 "$0" | grep --binary-files=without-match --regexp="^$"; if [[ "$?" == "0" ]]; then echo "Blank line found at end of $0."; false; fi'
- name: Check for unnecessary use of true tabs
run: find . -path './.git' -prune -or -path './libcanard' -prune -or -path './extras/test/external' -prune -or \( -not -name 'keywords.txt' -and -not -name '.gitmodules' -and -type f \) -exec grep --with-filename --line-number --binary-files=without-match --regexp=$'\t' '{}' \; -exec echo 'Tab found.' \; -exec false '{}' +
- name: Check for trailing whitespace
run: find . -path './.git' -prune -or -path './libcanard' -prune -or -path './src/DSDL_Types.h.impl' -prune -or -path './extras/test/external' -prune -or -type f -exec grep --with-filename --line-number --binary-files=without-match --regexp='[[:blank:]]$' '{}' \; -exec echo 'Trailing whitespace found.' \; -exec false '{}' +
- name: Check for non-Unix line endings
run: find . -path './.git' -prune -or -path './libcanard' -prune -or -path './extras/test/external' -prune -or -type f -exec grep --files-with-matches --binary-files=without-match --regexp=$'\r$' '{}' \; -exec echo 'Non-Unix EOL detected.' \; -exec false '{}' +
- name: Check for blank lines at end of files
run: find . -path './.git' -prune -or -path './src/types' -prune -or -path './src/DSDL_Types.h.impl' -prune -or -path './libcanard' -prune -or -path './extras/test/external' -prune -or -type f -print0 | xargs -0 -L1 bash -c 'tail -1 "$0" | grep --binary-files=without-match --regexp="^$"; if [[ "$?" == "0" ]]; then echo "Blank line found at end of $0."; false; fi'
- name: Check for files that don't end in a newline
# https://stackoverflow.com/a/25686825
run: find . -path './.git' -prune -or -path './src/types' -prune -or -path './libcanard' -prune -or -path './extras/test/external' -prune -or -type f -print0 | xargs -0 -L1 bash -c 'if test "$(grep --files-with-matches --binary-files=without-match --max-count=1 --regexp='.*' "$0")" && test "$(tail --bytes=1 "$0")"; then echo "No new line at end of $0."; false; fi'