Skip to content

[khyo] Week3

[khyo] Week3 #1579

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