Skip to content

Commit bd08cf4

Browse files
committed
gh-actions: move formatting check to stand-alone file for local usage
1 parent c1f620b commit bd08cf4

2 files changed

Lines changed: 78 additions & 63 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -42,69 +42,8 @@ jobs:
4242
persist-credentials: false
4343
- name: Install pcre2grep
4444
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends pcre2-utils
45-
# Check for trailing whitespace
46-
- name: Trailing whitespace
47-
run: find simde/ \( -name '*.c' -o -name '*.h' \) -exec grep -nP '\s+$' {} + && exit 1 || exit 0
48-
# We use spaces, not tabs. I don't want to start a holy war here;
49-
# I don't actually have a strong preference between the two, but I
50-
# do have a strong preference for consistency, so don't @ me.
51-
- name: Tabs
52-
run: find simde/ \( -name '*.c' -o -name '*.h' \) -exec grep -nP '\t' {} + && exit 1 || exit 0
53-
# s/8/16/ will result in this if the input is x86.
54-
- name: Bad substitutions
55-
run: git grep -i 'x''1''6''6' && exit 1 || exit 0
56-
- name: Incorrect assertions in test/
57-
run: grep -PR '(?<=[^a-zA-Z0-9_])simde_assert_u?int(8|16|32|64)(?>[^a-zA-Z0-9_])' test/ && exit 1 || exit 0
58-
# Check to make sure no source files have the executable bit set
59-
- name: Executable sources
60-
run: find \( -name '*.c' -o -name '*.h' \) -executable | grep -q '.' && exit 1 || exit 0
61-
# Make sure neon.h includes all the NEON headers.
62-
- name: Missing NEON includes
63-
run: for f in simde/arm/neon/*.h; do grep -q "include \"neon/$(basename "$f")\"" simde/arm/neon.h || (echo "Missing $f" && exit 1); done
64-
# Make sure sve.h includes all the SVE headers.
65-
- name: Missing SVE includes
66-
run: for f in simde/arm/sve/*.h; do grep -q "include \"sve/$(basename "$f")\"" simde/arm/sve.h || (echo "Missing $f" && exit 1); done
67-
# Make sure msa.h includes all the MSA headers.
68-
- name: Missing MSA includes
69-
run: for f in simde/mips/msa/*.h; do grep -q "include \"msa/$(basename "$f")\"" simde/mips/msa.h || (echo "Missing $f" && exit 1); done
70-
# Make sure we can find the expected header guards. It's easy to miss this when doing C&P
71-
- name: Header guards
72-
run: |
73-
while IFS= read -r -d '' file
74-
do
75-
grep -q "$(echo "$file" | tr '[:lower:]' '[:upper:]' | tr '[:punct:]' '_')" "$file" || (echo "Missing or incorrect header guard in $file" && exit 1)
76-
done < <(find simde/*/ -name '*.h' -print0)
77-
# There should be an empty line at the end of every file
78-
- name: Newline at EOF
79-
run: |
80-
while IFS= read -r -d '' file
81-
do
82-
if [ -n "$(tail -c 1 "$file")" ]
83-
then echo "No newline at end of $file" && exit 1
84-
fi
85-
done < <(find simde -name '*.h' -print0)
86-
# Don't #ifndef ; use !defined(...) instead. ifndef leads to annoying inconsistencies
87-
- name: ifndef
88-
run: |
89-
while IFS= read -r -d '' file
90-
do
91-
grep -qP '^ *# *ifndef ' "${file}" && exit 1 || exit 0
92-
done < <(find simde -name '*.h' -print0)
93-
# List of headers we want Meson to install
94-
- name: Meson install headers
95-
run: |
96-
while IFS= read -r -d '' file
97-
do
98-
grep -qF "$(basename "${file}" .h)" meson.build || (echo "${file} missing from top-level meson.build" && exit 1)
99-
done < <(find simde -name '*.h' -print0)
100-
# Make sure we don't accidentally use `vector ...` instead of SIMDE_POWER_ALTIVEC_VECTOR(...)
101-
- name: AltiVec raw vector keyword
102-
run: find simde/ \( -name '*.c' -o -name '*.h' \) -exec grep -nP 'vector( +)((bool|signed|unsigned) +)?(double|float|long long|long|int|short|char)' {} + && exit 1 || exit 0
103-
# Check indentation of preprocessor directives.
104-
- name: Preprocessor directive indentation
105-
run: find simde/*/ -name 'avx*.h' -exec pcre2grep -M '{\n#' {} + && exit 1 || exit 0
106-
- name: Stray `&& 0`
107-
run: git grep ' && 0' simde/ test/ && exit 1 || exit 0
45+
- name: Check formatting
46+
run: .github/workflows/formatting.bash
10847

10948
x86:
11049
runs-on: ubuntu-24.04

.github/workflows/formatting.bash

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/bash
2+
echo "::group::Trailing whitespace"
3+
# Check for trailing whitespace
4+
find simde/ \( -name '*.c' -o -name '*.h' \) -exec grep -nP '\s+$' {} + && exit 1
5+
echo "::endgroup::"
6+
echo "::group::Tabs"
7+
# We use spaces, not tabs. I don't want to start a holy war here;
8+
# I don't actually have a strong preference between the two, but I
9+
# do have a strong preference for consistency, so don't @ me.
10+
find simde/ \( -name '*.c' -o -name '*.h' \) -exec grep -nP '\t' {} + && exit 1
11+
echo "::endgroup::"
12+
echo "::group::Bad substitutions"
13+
# s/8/16/ will result in this if the input is x86.
14+
git grep -i 'x''1''6''6' && exit 1
15+
echo "::endgroup::"
16+
echo "::group::Incorrect assertions in test/"
17+
grep -PR '(?<=[^a-zA-Z0-9_])simde_assert_u?int(8|16|32|64)(?>[^a-zA-Z0-9_])' test/ && exit 1
18+
echo "::endgroup::"
19+
echo "::group::Executable sources"
20+
# Check to make sure no source files have the executable bit set
21+
find \( -name '*.c' -o -name '*.h' \) -executable | grep -q '.' && exit 1
22+
echo "::endgroup::"
23+
echo "::group::Missing NEON includes"
24+
# Make sure neon.h includes all the NEON headers.
25+
for f in simde/arm/neon/*.h; do grep -q "include \"neon/$(basename "$f")\"" simde/arm/neon.h || (echo "Missing $f" && exit 1); done
26+
echo "::endgroup::"
27+
echo "::group::Missing SVE includes"
28+
# Make sure sve.h includes all the SVE headers.
29+
for f in simde/arm/sve/*.h; do grep -q "include \"sve/$(basename "$f")\"" simde/arm/sve.h || (echo "Missing $f" && exit 1); done
30+
echo "::endgroup::"
31+
echo "::group::Missing MSA includes"
32+
# Make sure msa.h includes all the MSA headers.
33+
for f in simde/mips/msa/*.h; do grep -q "include \"msa/$(basename "$f")\"" simde/mips/msa.h || (echo "Missing $f" && exit 1); done
34+
echo "::endgroup::"
35+
echo "::group::Header guards"
36+
# Make sure we can find the expected header guards. It's easy to miss this when doing C&P
37+
while IFS= read -r -d '' file
38+
do
39+
grep -q "$(echo "$file" | tr '[:lower:]' '[:upper:]' | tr '[:punct:]' '_')" "$file" || (echo "Missing or incorrect header guard in $file" && exit 1)
40+
done < <(find simde/*/ -name '*.h' -print0)
41+
echo "::endgroup::"
42+
echo "::group::Newline at EOF"
43+
# There should be an empty line at the end of every file
44+
while IFS= read -r -d '' file
45+
do
46+
if [ -n "$(tail -c 1 "$file")" ]
47+
then echo "No newline at end of $file" && exit 1
48+
fi
49+
done < <(find simde -name '*.h' -print0)
50+
echo "::endgroup::"
51+
echo "::group::ifndef"
52+
# Don't #ifndef ; use !defined(...) instead. ifndef leads to annoying inconsistencies
53+
while IFS= read -r -d '' file
54+
do
55+
grep -qP '^ *# *ifndef ' "${file}" && exit 1
56+
done < <(find simde -name '*.h' -print0)
57+
echo "::endgroup::"
58+
echo "::group::Meson install headers"
59+
# List of headers we want Meson to install
60+
while IFS= read -r -d '' file
61+
do
62+
grep -qF "$(basename "${file}" .h)" meson.build || (echo "${file} missing from top-level meson.build" && exit 1)
63+
done < <(find simde -name '*.h' -print0)
64+
echo "::endgroup::"
65+
echo "::group::AltiVec raw vector keyword"
66+
# Make sure we don't accidentally use `vector ...` instead of SIMDE_POWER_ALTIVEC_VECTOR(...)
67+
find simde/ \( -name '*.c' -o -name '*.h' \) -exec grep -nP 'vector( +)((bool|signed|unsigned) +)?(double|float|long long|long|int|short|char)' {} + && exit 1
68+
echo "::endgroup::"
69+
echo "::group::Preprocessor directive indentation"
70+
# Check indentation of preprocessor directives.
71+
find simde/*/ -name 'avx*.h' -exec pcre2grep -M '{\n#' {} + && exit 1
72+
echo "::endgroup::"
73+
echo '::group::Stray "&& 0"'
74+
git grep ' && 0' simde/ test/ && exit 1
75+
echo "::endgroup::"
76+

0 commit comments

Comments
 (0)