Comment on syntax errors (#656)
This commit is contained in:
parent
fe2b9718e1
commit
46502ac44a
16
.github/workflows/lint_c.yml
vendored
16
.github/workflows/lint_c.yml
vendored
@ -43,7 +43,19 @@ jobs:
|
|||||||
uses: ./.github/actions/docker
|
uses: ./.github/actions/docker
|
||||||
|
|
||||||
- name: 'Check syntax'
|
- name: 'Check syntax'
|
||||||
|
id: syntax_check
|
||||||
uses: ./.github/actions/docker
|
uses: ./.github/actions/docker
|
||||||
continue-on-error: false
|
|
||||||
with:
|
with:
|
||||||
run: /syntax_check.sh
|
run: SET_GH_OUTPUT=1 /syntax_check.sh
|
||||||
|
|
||||||
|
- name: Report syntax errors
|
||||||
|
if: failure() && steps.syntax_check.outputs.errors && github.event.pull_request
|
||||||
|
uses: peter-evans/create-or-update-comment@v1
|
||||||
|
with:
|
||||||
|
issue-number: ${{ github.event.pull_request.number }}
|
||||||
|
body: |
|
||||||
|
Please fix following syntax errors:
|
||||||
|
```
|
||||||
|
${{ steps.syntax_check.outputs.errors }}
|
||||||
|
```
|
||||||
|
You might want to run `docker compose exec dev /syntax_check.sh` for an auto-fix.
|
@ -3,7 +3,6 @@
|
|||||||
# set -e
|
# set -e
|
||||||
|
|
||||||
CLANG_FORMAT_BIN="/usr/bin/clang-format-12"
|
CLANG_FORMAT_BIN="/usr/bin/clang-format-12"
|
||||||
PATH="$HOME/.cargo/bin:${PATH}"
|
|
||||||
|
|
||||||
PROJECT_DIR=$(pwd)
|
PROJECT_DIR=$(pwd)
|
||||||
|
|
||||||
@ -19,14 +18,20 @@ C_FILES=$(find . \
|
|||||||
|
|
||||||
ulimit -s 65536
|
ulimit -s 65536
|
||||||
$CLANG_FORMAT_BIN --version
|
$CLANG_FORMAT_BIN --version
|
||||||
$CLANG_FORMAT_BIN --verbose -style=file -n --Werror --ferror-limit=0 $C_FILES
|
errors=$($CLANG_FORMAT_BIN --verbose -style=file -n --Werror --ferror-limit=0 $C_FILES |& tee /dev/stderr | sed '/^Formatting/d')
|
||||||
c_syntax_rc=$?
|
|
||||||
|
|
||||||
if [[ $c_syntax_rc -eq 0 ]]; then
|
if [[ -z "$errors" ]]; then
|
||||||
echo "Code looks fine for me!"
|
echo "Code looks fine for me!"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -n "${SET_GH_OUTPUT}" ]]; then
|
||||||
|
errors="${errors//'%'/'%25'}"
|
||||||
|
errors="${errors//$'\n'/'%0A'}"
|
||||||
|
errors="${errors//$'\r'/'%0D'}"
|
||||||
|
echo "::set-output name=errors::$errors"
|
||||||
|
fi
|
||||||
|
|
||||||
read -p "Do you want fix syntax? (y/n): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1
|
read -p "Do you want fix syntax? (y/n): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1
|
||||||
|
|
||||||
cd $PROJECT_DIR
|
cd $PROJECT_DIR
|
||||||
|
Loading…
Reference in New Issue
Block a user