forked from nnstreamer/nnstreamer
-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (52 loc) · 1.8 KB
/
static.check.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: Static checkers and verifiers
on:
pull_request:
branches: [ main ]
push:
jobs:
simple_script_checkers:
runs-on: ubuntu-latest
name: Static checks
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 5
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v41
with:
since_last_remote_commit: true
- name: List all files changed
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
for file in "$ALL_CHANGED_FILES"; do
echo "$file was changed"
done
- name: Run clang-format for cc/hh/hpp/cpp files
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
shell: bash
run: |
sudo apt update && sudo apt-get install clang-format
echo "Check .clang-format file"
if [ ! -f ".clang-format" ]; then
echo ".clang-format file not found"
exit 1
fi
for file in "$ALL_CHANGED_FILES"; do
if [[ "$file" =~ .*\.hh$ ]] || [[ "$file" =~ .*\.hpp ]] || [[ "$file" =~ .*\.cc$ ]] || [[ "$file" =~ .*\.cpp ]]; then
echo "$file appears to be a C++ file. Applying clang-format"
clang-format -i ${file}
else
echo "$file appears not to be C++ file. skipping clang-format"
fi
done
git diff -- *.cc *.hh *.hpp *.cpp > .ci.clang-format.patch
SIZE=$(stat -c%s .ci.clang-format.patch)
if [[ $SIZE -ne 0 ]]; then
echo "clang-format shows that the commit has style errors."
cat .ci.clang-format.patch
exit 1
fi
echo "clang-format shows no style errors."