-
Notifications
You must be signed in to change notification settings - Fork 126
113 lines (94 loc) ยท 4.15 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
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: |
pr_number="${{ github.event.pull_request.number }}"
labels_json=$(gh pr view $pr_number --json labels -q '.labels[].name')
if [ -n "$labels_json" ]; then
echo "has_maintenance=$(echo $labels_json | grep -q 'maintenance' && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
else
echo "has_maintenance=false" >> $GITHUB_OUTPUT
fi
env:
GH_TOKEN: ${{ github.token }}
# ์ค๋ฐ๊ฟ ์ฒดํฌ
- name: Check for missing end line breaks
run: |
# ๋ฐ์ดํ๋ฅผ ์ ๊ฑฐํ๊ณ ํ์ผ ๋ชฉ๋ก ๊ฐ์ ธ์ค๊ธฐ
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
if [ -s "$file" ] && [ "$(tail -c 1 $file | wc -l)" -eq 0 ]; then
echo "๋ฐ๊ฒฌ๋ ์ค๋ฐ๊ฟ ๋๋ฝ: $file"
echo "- $file" >> $GITHUB_STEP_SUMMARY
success=false
fi
done
if [ "$success" = false ]; then
echo -e "\n:warning: ํ์ผ ๋์ ๋๋ฝ๋ ์ค๋ฐ๊ฟ์ ์ถ๊ฐํด ์ฃผ์ธ์." >> $GITHUB_STEP_SUMMARY
exit 1
fi
# ์ ์ด๋ฌธ์ ์ฒดํฌ
- name: Check for control characters in filenames
run: |
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
# 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 (์ ์ด๋ฌธ์ ํฌํจ)" >> $GITHUB_STEP_SUMMARY
success=false
fi
done
if [ "$success" = false ]; then
echo -e "\n:warning: ํ์ผ๋ช
์์ ์ ์ด๋ฌธ์๋ฅผ ์ ๊ฑฐํด ์ฃผ์ธ์." >> $GITHUB_STEP_SUMMARY
exit 1
fi
# ํ์ผ๋ช
๊ท์น ์ฒดํฌ - maintenance ๋ผ๋ฒจ์ด ์๋ ๊ฒฝ์ฐ์๋ง ์คํ
- name: Check filename rules
if: ${{ steps.pr-labels.outputs.has_maintenance != 'true' }}
run: |
files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | tr -d '"')
pr_author="${{ github.event.pull_request.user.login }}"
success=true
echo "## ํ์ผ๋ช
๊ท์น ์๋ฐ" >> $GITHUB_STEP_SUMMARY
for file in $files; do
if [ -f "$file" ]; then
# ํ์ผ๋ช
๋ง ์ถ์ถ (๊ฒฝ๋ก ์ ์ธ)
filename=$(basename "$file")
# ํ์ผ๋ช
์ด GitHub๊ณ์ ๋ช
์ธ์ง ํ์ธ
shopt -s nocasematch
if [[ ! "$filename" = "$pr_author"* ]]; then
echo "- $file" >> $GITHUB_STEP_SUMMARY
success=false
fi
fi
done
if [ "$success" = false ]; then
echo -e "\n:warning: ํ์ผ๋ช
์ ๋ฐ๋์ 'GitHub๊ณ์ ๋ช
' ๋๋ 'GitHub๊ณ์ ๋ช
-xxx' ํ์์ผ๋ก ํด์ฃผ์
์ผ ํฉ๋๋ค. (์: ${pr_author}.ts, ${pr_author}-1.ts, ${pr_author}-2.ts)" >> $GITHUB_STEP_SUMMARY
exit 1
fi
env:
GH_TOKEN: ${{ github.token }}