Skip to content

Commit

Permalink
Use clang-format for github workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
bmatherly committed Feb 27, 2025
1 parent 7dde983 commit f3b648f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# .clang-format for MLT
# .clang-format for Shotcut
#
# Adapted from https://github.com/qt-creator/qt-creator/blob/master/.clang-format
#
Expand Down
26 changes: 17 additions & 9 deletions .github/workflows/check-code-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,38 @@ name: check-code-format
on:
workflow_dispatch:
pull_request:
types: [opened, reopened]
types: [opened, reopened, synchronize]
push:

jobs:
astyle:
clang-format:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Artistic Style
run: sudo apt-get install -y astyle grep
- name: Install clang-format
run: sudo apt-get install -y clang-format-14

- name: Check style
run: |
results="$(astyle --project=.astylerc --dry-run --recursive "./*.cpp,*.h" | awk '/^Formatted/')"
if [ -z "$results" ]
FILES=`find . -type f -name "*.h" -o -name "*.c" -o -name "*.cpp"`
FILTERED_FILES=()
for file in ${FILES[@]};
do
[[ $file =~ "./src/" ]] &&
[[ ! $file =~ "spatialmedia" ]] &&
[[ ! $file =~ "defaultlayouts.h" ]] &&
[[ ! $file =~ "_autogen" ]] &&
FILTERED_FILES+=($file)
done
clang-format-14 --verbose --dry-run --Werror -style=file -i ${FILTERED_FILES[@]}
if [ $? -eq 0 ]
then
echo "SUCCESS: All files are formatted correctly"
exit 0
else
count=`wc -l <<< "$results"`
echo "FAILURE: $count files are formatted incorrectly"
echo "${results//'Formatted '/' '}"
echo "FAILURE: some files are formatted incorrectly"
exit 99
fi

0 comments on commit f3b648f

Please sign in to comment.