-
-
Notifications
You must be signed in to change notification settings - Fork 304
ci: improve line break check ci to change file automatically #1977
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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: | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -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" | ||||||||||||||
|
|
@@ -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 "✅ 모든 파일의 줄바꿈 정상" | ||||||||||||||
|
|
@@ -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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
이 부분을 고치는 대신
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
이 부분이 잘 이해가 안됐어요. .github 하위 파일들은 알고리즘 관련 파일이 아니기 때문에
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 다음 부분 덕분에 #1970 에서도 문제가 없었어요. leetcode-study/.github/workflows/integration.yaml Lines 109 to 111 in be10c6c
.github 디렉토리 외에도 일일이 예외 처리하는 Whitelist를 관리하는 것보다 검사 대상 디렉토리만 지정하는 Blacklist 방식도 좋을 것 같고요. maintenance label은 사전에 정적으로 정의한 디렉토리 수준이 아니라 Pull Request 단위로 검사 여부를 동적으로 결정할 수 있어서 좋은 것 같아요.또한 maintenance label이 없는 일반 풀이 제출 Pull Request가 만일 지금처럼 .github 내 파일의 변경을 고의 또는 실수로 포함하는 경우 기존과 같이 실패 처리하는 것이 더 안전하다는 생각도 드네요.
|
||||||||||||||
| pr_author="${{ github.event.pull_request.user.login }}" | ||||||||||||||
| success=true | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.