-
Notifications
You must be signed in to change notification settings - Fork 126
155 lines (130 loc) ยท 5.88 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: Integration ๐
on:
pull_request:
jobs:
linelint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# PR ๋ผ๋ฒจ ํ์ธ
- name: Get PR labels
id: pr-labels
run: |
echo "๐ PR ๋ฒํธ: ${{ github.event.pull_request.number }}"
pr_number="${{ github.event.pull_request.number }}"
echo "๐ PR ๋ผ๋ฒจ ์กฐํ ์ค..."
labels_json=$(gh pr view $pr_number --json labels -q '.labels[].name')
echo "ํ์ธ๋ ๋ผ๋ฒจ: $labels_json"
if [ -n "$labels_json" ]; then
has_maintenance=$(echo $labels_json | grep -q 'maintenance' && echo 'true' || echo 'false')
echo "maintenance ๋ผ๋ฒจ ํฌํจ ์ฌ๋ถ: $has_maintenance"
echo "has_maintenance=$has_maintenance" >> $GITHUB_OUTPUT
else
echo "maintenance ๋ผ๋ฒจ์ด ์๋ PR์
๋๋ค. ํ์ผ๋ช
๊ท์น ๊ฒ์ฌ๋ฅผ ์งํํฉ๋๋ค."
echo "has_maintenance=false" >> $GITHUB_OUTPUT
fi
env:
GH_TOKEN: ${{ github.token }}
# ์ค๋ฐ๊ฟ ์ฒดํฌ
- name: Check for missing end line breaks
run: |
echo "๐ ์ค๋ฐ๊ฟ ๊ฒ์ฌ ์์"
echo "๊ธฐ์ค ์ปค๋ฐ: ${{ github.event.pull_request.base.sha }}"
echo "ํ์ฌ ์ปค๋ฐ: ${{ github.sha }}"
files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | tr -d '"')
success=true
echo "๐ ๋ณ๊ฒฝ๋ ํ์ผ ๋ชฉ๋ก:"
echo "$files"
echo "## ์ค๋ฐ๊ฟ ๋๋ฝ ํ์ผ" >> $GITHUB_STEP_SUMMARY
for file in $files; do
echo "๊ฒ์ฌ ์ค: $file"
if [ -s "$file" ] && [ "$(tail -c 1 $file | wc -l)" -eq 0 ]; then
echo "โ ์ค๋ฐ๊ฟ ๋๋ฝ: $file"
echo "- $file" >> $GITHUB_STEP_SUMMARY
success=false
else
echo "โ
์ ์: $file"
fi
done
if [ "$success" = false ]; then
echo "โ ๏ธ ์ค๋ฐ๊ฟ ๊ฒ์ฌ ์คํจ"
echo -e "\n:warning: ํ์ผ ๋์ ๋๋ฝ๋ ์ค๋ฐ๊ฟ์ ์ถ๊ฐํด ์ฃผ์ธ์." >> $GITHUB_STEP_SUMMARY
exit 1
else
echo "โ
๋ชจ๋ ํ์ผ์ ์ค๋ฐ๊ฟ ์ ์"
fi
# ์ ์ด๋ฌธ์ ์ฒดํฌ
- name: Check for control characters in filenames
run: |
echo "๐ ํ์ผ๋ช
์ ์ด๋ฌธ์ ๊ฒ์ฌ ์์"
files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | tr -d '"')
success=true
echo "## ์ ์ด๋ฌธ์๊ฐ ํฌํจ๋ ํ์ผ๋ช
" >> $GITHUB_STEP_SUMMARY
for file in $files; do
echo "๊ฒ์ฌ ์ค: $file"
# basename์ผ๋ก ํ์ผ๋ช
๋ง ์ถ์ถํ๊ณ ๋ฐ์ดํ ์ ๊ฑฐ
filename=$(basename "$file" | tr -d '"')
# ๋ฐฑ์ฌ๋์๋ก ์์ํ๋ ์ ์ด๋ฌธ์๋ค ์ฒดํฌ (\b, \n, \r, \t ๋ฑ)
if printf '%q' "$filename" | grep -q '\\[bnrtfv]' || \
# ์ผ๋ฐ์ ์ธ ์ ์ด๋ฌธ์๋ค ์ฒดํฌ (0x00-0x1F, 0x7F)
echo -n "$filename" | LC_ALL=C grep -q '[[:cntrl:]]' || \
# ํน์ ์ ์ด๋ฌธ์๋ค ์ฒดํฌ
echo -n "$filename" | grep -q $'[\x00-\x1F\x7F]' || \
# ์ด์ค์ผ์ดํ ์ํ์ค ์ฒดํฌ
[[ "$filename" =~ (\\[0-7]{1,3}|\\x[0-9a-fA-F]{1,2}) ]]; then
echo "โ ์ ์ด๋ฌธ์ ๋ฐ๊ฒฌ: $file"
echo "- $file (์ ์ด๋ฌธ์ ํฌํจ)" >> $GITHUB_STEP_SUMMARY
success=false
else
echo "โ
์ ์: $file"
fi
done
if [ "$success" = false ]; then
echo "โ ๏ธ ์ ์ด๋ฌธ์ ๊ฒ์ฌ ์คํจ"
echo -e "\n:warning: ํ์ผ๋ช
์์ ์ ์ด๋ฌธ์๋ฅผ ์ ๊ฑฐํด ์ฃผ์ธ์." >> $GITHUB_STEP_SUMMARY
exit 1
else
echo "โ
๋ชจ๋ ํ์ผ๋ช
์ด ์ ์ด๋ฌธ์ ์์ด ์ ์"
fi
# ํ์ผ๋ช
๊ท์น ์ฒดํฌ - maintenance ๋ผ๋ฒจ์ด ์๋ ๊ฒฝ์ฐ์๋ง ์คํ
- name: Check filename rules
if: ${{ steps.pr-labels.outputs.has_maintenance != 'true' }}
run: |
echo "๐ ํ์ผ๋ช
๊ท์น ๊ฒ์ฌ ์์"
echo "PR ์์ฑ์: ${{ github.event.pull_request.user.login }}"
# PR์ ๊ณตํต ์กฐ์ ์ปค๋ฐ์ ์ฐพ์์ merge base๋ก ์ค์
merge_base=$(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }})
echo "Merge base ์ปค๋ฐ: $merge_base"
files=$(git diff --name-only $merge_base ${{ github.event.pull_request.head.sha }} | tr -d '"')
pr_author="${{ github.event.pull_request.user.login }}"
success=true
echo "๐ ๊ฒ์ฌํ ํ์ผ ๋ชฉ๋ก:"
echo "$files"
echo "## ํ์ผ๋ช
๊ท์น ์๋ฐ" >> $GITHUB_STEP_SUMMARY
for file in $files; do
if [ -f "$file" ]; then
echo "๊ฒ์ฌ ์ค: $file"
# ํ์ผ๋ช
๋ง ์ถ์ถ (๊ฒฝ๋ก ์ ์ธ)
filename=$(basename "$file")
# ํ์ผ๋ช
์ด GitHub๊ณ์ ๋ช
์ธ์ง ํ์ธ
shopt -s nocasematch
if [[ ! "$filename" = "$pr_author"* ]]; then
echo "โ ๊ท์น ์๋ฐ: $file"
echo "- $file" >> $GITHUB_STEP_SUMMARY
success=false
else
echo "โ
์ ์: $file"
fi
fi
done
if [ "$success" = false ]; then
echo "โ ๏ธ ํ์ผ๋ช
๊ท์น ๊ฒ์ฌ ์คํจ"
echo -e "\n:warning: ํ์ผ๋ช
์ ๋ฐ๋์ 'GitHub๊ณ์ ๋ช
' ๋๋ 'GitHub๊ณ์ ๋ช
-xxx' ํ์์ผ๋ก ํด์ฃผ์
์ผ ํฉ๋๋ค. (์: ${pr_author}.ts, ${pr_author}-1.ts, ${pr_author}-2.ts)" >> $GITHUB_STEP_SUMMARY
exit 1
else
echo "โ
๋ชจ๋ ํ์ผ๋ช
์ด ๊ท์น์ ๋ง๊ฒ ์ ์"
fi
env:
GH_TOKEN: ${{ github.token }}