style(compiler): c++ formatting with github action (#22)

* style(compiler): c++ formatting with github action

* style(compiler): update format script
This commit is contained in:
Ayoub Benaissa
2021-06-03 15:45:29 +01:00
committed by Quentin Bourgerie
parent 5164126447
commit eef82a4713
9 changed files with 137 additions and 102 deletions

18
.github/workflows/conformance.yml vendored Normal file
View File

@@ -0,0 +1,18 @@
name: Conformance
on:
push:
branches: [master]
pull_request:
types: [opened, synchronize, reopened]
jobs:
Formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Format with clang-format
run: .github/workflows/scripts/format_cpp.sh

14
.github/workflows/scripts/format_cpp.sh vendored Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/bash
set -o pipefail
find ./compiler/{include,lib,src} \( -iname "*.h" -o -iname "*.cpp" -o -iname "*.cc" \) | xargs clang-format -i -style='file'
if [ $? -ne 0 ]
then
exit 1
fi
# show changes if any
git diff
# fail if there is a diff, success otherwise
! ( git diff | grep -q ^ ) || exit 1