forked from DaleStudy/leetcode-study
-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (58 loc) · 2.58 KB
/
integration.yaml
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: 🔄 Integration
on:
pull_request:
jobs:
linelint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for 1. missing end line breaks and 2. control characters in filenames
run: |
# 따옴표를 제거하고 파일 목록 가져오기
files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | tr -d '"')
echo "변경된 파일 목록:"
echo "$files"
success=true
# 줄바꿈 체크
echo "## 줄바꿈 누락 파일" >> $GITHUB_STEP_SUMMARY
for file in $files; do
if [ -s "$file" ] && [ "$(tail -c 1 $file | wc -l)" -eq 0 ]; then
echo "발견된 줄바꿈 누락: $file"
echo "- $file" >> $GITHUB_STEP_SUMMARY
success=false
fi
done
# 제어문자 체크
echo -e "\n## 제어문자가 포함된 파일명" >> $GITHUB_STEP_SUMMARY
for file in $files; do
# basename으로 파일명만 추출하고 따옴표 제거
filename=$(basename "$file" | tr -d '"')
# 백슬래시로 시작하는 제어문자들 체크 (\b, \n, \r, \t 등)
if printf '%q' "$filename" | grep -q '\\[bnrtfv]'; then
echo "- $file (제어문자 포함)" >> $GITHUB_STEP_SUMMARY
success=false
fi
# 일반적인 제어문자들 체크 (0x00-0x1F, 0x7F)
if echo -n "$filename" | LC_ALL=C grep -q '[[:cntrl:]]'; then
echo "- $file (제어문자 포함)" >> $GITHUB_STEP_SUMMARY
success=false
fi
# 특수 제어문자들 체크
if echo -n "$filename" | grep -q $'[\x00-\x1F\x7F]'; then
echo "- $file (제어문자 포함)" >> $GITHUB_STEP_SUMMARY
success=false
fi
# 이스케이프 시퀀스 체크
if [[ "$filename" =~ (\\[0-7]{1,3}|\\x[0-9a-fA-F]{1,2}) ]]; then
echo "- $file (제어문자 포함)" >> $GITHUB_STEP_SUMMARY
success=false
fi
done
if [ "$success" = false ]; then
echo -e "\n:warning: 위 문제들을 해결해 주세요:" >> $GITHUB_STEP_SUMMARY
echo "1. 파일 끝의 누락된 줄바꿈을 추가해 주세요." >> $GITHUB_STEP_SUMMARY
echo "2. 파일명에서 제어문자를 제거해 주세요." >> $GITHUB_STEP_SUMMARY
exit 1
fi