add clang-format action #13
Workflow file for this run
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
name: Code Formatter | |
# run on pull requests to develop | |
on: | |
pull_request | |
jobs: | |
format: | |
name: Clang Formatter | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
# fetch everything to be able to compare with any ref | |
fetch-depth: 0 | |
- name: Check | |
env: | |
LANG: "C.UTF-8" | |
LC_ALL: "C.UTF-8" | |
LANGUAGE: "C.UTF-8" | |
run: | | |
sudo apt-get install -y clang-format-14 python3 git | |
diff_output_file=$(mktemp) | |
git --no-pager diff -U0 --diff-filter=ACMRT ${{github.event.pull_request.base.sha}}...${{ github.event.pull_request.head.sha }} | clang-format-diff-14 -p1 2>&1 | tee $diff_output_file | |
if [ -s $diff_output_file ]; then | |
exit 1 | |
else | |
exit 0 | |
fi |