[yeoju] Week 3 #1562
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |