Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: Integration 🔄

permissions:
contents: write
pull-requests: write

on:
pull_request:

Expand Down Expand Up @@ -41,7 +45,7 @@ jobs:
echo "현재 커밋: ${{ github.sha }}"

files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | tr -d '"')
success=true
target_file_list=()

echo "📝 변경된 파일 목록:"
echo "$files"
Expand All @@ -50,17 +54,30 @@ jobs:
for file in $files; do
echo "검사 중: $file"
if [ -s "$file" ] && [ "$(tail -c 1 $file | wc -l)" -eq 0 ]; then
echo "❌ 줄바꿈 누락: $file"
# 개행 추가
echo >> "$file"
echo "✏️ 개행 추가: $file"
echo "- $file" >> $GITHUB_STEP_SUMMARY
success=false
target_file_list+=("$file")
else
echo "✅ 정상: $file"
fi
done

if [ "$success" = false ]; then
echo "⚠️ 줄바꿈 검사 실패"
echo -e "\n:warning: 파일 끝의 누락된 줄바꿈을 추가해 주세요." >> $GITHUB_STEP_SUMMARY
if [ "${#target_file_list[@]}" -gt 0 ]; then
echo -e "\n자동 수정된 파일 수: ${#target_file_list[@]}" >> "$GITHUB_STEP_SUMMARY"

# 유저 설정
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"

# 변경분 커밋 & 푸시
git checkout "${GITHUB_HEAD_REF}"
git add -A
git commit -m "chore(ci): add missing trailing newline to files"
git push origin "HEAD:${GITHUB_HEAD_REF}"

echo "✅ 누락된 개행 자동 추가 및 커밋/푸시 완료"
exit 1
else
echo "✅ 모든 파일의 줄바꿈 정상"
Expand Down Expand Up @@ -117,7 +134,8 @@ jobs:
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 '"')
# .github 디렉토리 하위 파일 제외하고 대상 파일로 지정
files=$(git diff --name-only "$merge_base" ${{ github.event.pull_request.head.sha }} -- . ':(exclude).github/**' | tr -d '"')
Comment on lines +136 to +137
Copy link
Contributor

@yhkee0404 yhkee0404 Nov 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# .github 디렉토리 하위 파일 제외하고 대상 파일로 지정
files=$(git diff --name-only "$merge_base" ${{ github.event.pull_request.head.sha }} -- . ':(exclude).github/**' | tr -d '"')
files=$(git diff --name-only $merge_base ${{ github.event.pull_request.head.sha }} | tr -d '"')

이 부분을 고치는 대신 maintenance label을 붙이면 해결되는 문제는 아닐까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분을 고치는 대신 maintenance label을 붙이면 해결되는 문제는 아닐까요?

이 부분이 잘 이해가 안됐어요. .github 하위 파일들은 알고리즘 관련 파일이 아니기 때문에 {github 닉네임}.xxx 파일 컨벤션을 제외하도록 했습니다. maintenance 라벨을 붙이면 이 부분이 해결되지 않을 것 같은데, 부가 설명 가능하실까요?

Copy link
Contributor

@yhkee0404 yhkee0404 Nov 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

다음 부분 덕분에 #1970 에서도 문제가 없었어요.

# 파일명 규칙 체크 - maintenance 라벨이 없는 경우에만 실행
- name: Check filename rules
if: ${{ steps.pr-labels.outputs.has_maintenance != 'true' }}

.github 디렉토리 외에도 일일이 예외 처리하는 Whitelist를 관리하는 것보다 검사 대상 디렉토리만 지정하는 Blacklist 방식도 좋을 것 같고요. maintenance label은 사전에 정적으로 정의한 디렉토리 수준이 아니라 Pull Request 단위로 검사 여부를 동적으로 결정할 수 있어서 좋은 것 같아요.
또한 maintenance label이 없는 일반 풀이 제출 Pull Request가 만일 지금처럼 .github 내 파일의 변경을 고의 또는 실수로 포함하는 경우 기존과 같이 실패 처리하는 것이 더 안전하다는 생각도 드네요.

pr_author="${{ github.event.pull_request.user.login }}"
success=true

Expand Down