Skip to content

[suwi] Week 03

[suwi] Week 03 #1566

Workflow file for this run

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 }}