Skip to content

Commit 8cdb1be

Browse files
committed
[CI] Add lint workflow to detect DOS (CRLF) line endings
Add a new GitHub Actions workflow that fails if any file (excluding known legacy CRLF files) has DOS line endings. This prevents new CRLF files from being introduced into the codebase. Ref: #3605
1 parent 307f0f1 commit 8cdb1be

1 file changed

Lines changed: 74 additions & 0 deletions

File tree

.github/workflows/lint.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
pull_request:
6+
types: [assigned, opened, synchronize, reopened]
7+
8+
jobs:
9+
check-line-endings:
10+
name: Check for CRLF line endings
11+
runs-on: ubuntu-slim
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v6
15+
16+
- name: Detect CRLF line endings
17+
run: |
18+
# Known CRLF files that are excluded from this check (see issue #3605)
19+
EXCLUDED_FILES=(
20+
"src/dynarec/arm64/arm64_printer.c"
21+
"src/dynarec/arm64/dynarec_arm64_0f.c"
22+
"src/dynarec/arm64/dynarec_arm64_66.c"
23+
"src/dynarec/arm64/dynarec_arm64_660f.c"
24+
"src/dynarec/arm64/dynarec_arm64_f20f.c"
25+
"src/dynarec/arm64/dynarec_arm64_f30f.c"
26+
"src/dynarec/dynarec_arch.h"
27+
"src/dynarec/dynarec_helper.h"
28+
"src/dynarec/native_lock.h"
29+
"src/emu/modrm.h"
30+
"src/emu/x64run0f.c"
31+
"src/emu/x64run66.c"
32+
"src/emu/x64run660f.c"
33+
"src/emu/x64run66d9.c"
34+
"src/emu/x64run66dd.c"
35+
"src/emu/x64rund8.c"
36+
"src/emu/x64rund9.c"
37+
"src/emu/x64runda.c"
38+
"src/emu/x64rundb.c"
39+
"src/emu/x64rundd.c"
40+
"src/emu/x64rundf.c"
41+
"src/emu/x64runf0.c"
42+
"src/emu/x64runf20f.c"
43+
"src/emu/x64runf30f.c"
44+
"src/include/dictionnary.h"
45+
"src/include/globalsymbols.h"
46+
"src/librarian/dictionnary.c"
47+
"src/librarian/globalsymbols.c"
48+
"src/wrapped/wrappedandroidshmem.c"
49+
"src/wrapped/wrappedandroidshmem_private.h"
50+
"tests/test15.c"
51+
)
52+
53+
# Build a grep exclusion pattern
54+
EXCLUDE_PATTERN=""
55+
for f in "${EXCLUDED_FILES[@]}"; do
56+
if [ -z "$EXCLUDE_PATTERN" ]; then
57+
EXCLUDE_PATTERN="$f"
58+
else
59+
EXCLUDE_PATTERN="$EXCLUDE_PATTERN|$f"
60+
fi
61+
done
62+
63+
# Find all tracked text files with CRLF, excluding known files
64+
CRLF_FILES=$(git grep -rlI $'\r' -- . | grep -Ev "^($EXCLUDE_PATTERN)$" || true)
65+
66+
if [ -n "$CRLF_FILES" ]; then
67+
echo "::error::The following files have DOS (CRLF) line endings. Please convert them to Unix (LF) line endings:"
68+
echo "$CRLF_FILES"
69+
echo ""
70+
echo "You can fix this with: sed -i 's/\r$//' <file> or dos2unix <file>"
71+
exit 1
72+
fi
73+
74+
echo "No unexpected CRLF line endings found."

0 commit comments

Comments
 (0)