Skip to content

[EGON] Week14 Solutions #810

[EGON] Week14 Solutions

[EGON] Week14 Solutions #810

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
- name: Check for 1. missing end line breaks and 2. control characters in filenames
run: |
# ๋”ฐ์˜ดํ‘œ๋ฅผ ์ œ๊ฑฐํ•˜๊ณ  ํŒŒ์ผ ๋ชฉ๋ก ๊ฐ€์ ธ์˜ค๊ธฐ
files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | tr -d '"')
echo "๋ณ€๊ฒฝ๋œ ํŒŒ์ผ ๋ชฉ๋ก:"
echo "$files"
success=true
# ์ค„๋ฐ”๊ฟˆ ์ฒดํฌ
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
# ์ œ์–ด๋ฌธ์ž ์ฒดํฌ
echo -e "\n## ์ œ์–ด๋ฌธ์ž๊ฐ€ ํฌํ•จ๋œ ํŒŒ์ผ๋ช…" >> $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]'; then
echo "- $file (์ œ์–ด๋ฌธ์ž ํฌํ•จ)" >> $GITHUB_STEP_SUMMARY
success=false
fi
# ์ผ๋ฐ˜์ ์ธ ์ œ์–ด๋ฌธ์ž๋“ค ์ฒดํฌ (0x00-0x1F, 0x7F)
if echo -n "$filename" | LC_ALL=C grep -q '[[:cntrl:]]'; then
echo "- $file (์ œ์–ด๋ฌธ์ž ํฌํ•จ)" >> $GITHUB_STEP_SUMMARY
success=false
fi
# ํŠน์ˆ˜ ์ œ์–ด๋ฌธ์ž๋“ค ์ฒดํฌ
if echo -n "$filename" | grep -q $'[\x00-\x1F\x7F]'; then
echo "- $file (์ œ์–ด๋ฌธ์ž ํฌํ•จ)" >> $GITHUB_STEP_SUMMARY
success=false
fi
# ์ด์Šค์ผ€์ดํ”„ ์‹œํ€€์Šค ์ฒดํฌ
if [[ "$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
echo "1. ํŒŒ์ผ ๋์˜ ๋ˆ„๋ฝ๋œ ์ค„๋ฐ”๊ฟˆ์„ ์ถ”๊ฐ€ํ•ด ์ฃผ์„ธ์š”." >> $GITHUB_STEP_SUMMARY
echo "2. ํŒŒ์ผ๋ช…์—์„œ ์ œ์–ด๋ฌธ์ž๋ฅผ ์ œ๊ฑฐํ•ด ์ฃผ์„ธ์š”." >> $GITHUB_STEP_SUMMARY
exit 1
fi