Skip to content

Commit

Permalink
chore(BE): 코드 품질 CI 작업
Browse files Browse the repository at this point in the history
- CI 단계에서 자동 포맷팅 수행 작업

close #5
  • Loading branch information
keem-hyun committed Oct 1, 2024
1 parent a9d2cc9 commit 5754278
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/code-quality-check-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Backend Code Quality CI

on:
push:
branches: [ develop, release ]
paths:
- 'app/backend/**'
pull_request:
paths:
- 'app/backend/**'

jobs:
lint-and-test:
# Ubuntu 최신 환경에서 실행
runs-on: ubuntu-latest

steps:
# Github Repository 체크아웃
- name: Checkout code
uses: actions/checkout@v4

# python 환경 설정
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

# python 버전 표시
- name : Display Python version
run : python --version

# Python 패키지 설치
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r app/backend/requirements.txt
# 코드 포맷팅 Pre-commit 실행
- name: Run pre-commit
run: pre-commit run --files app/backend/**/*.py

# 변경사항 확인
- name: Check for changes
id: git-check
run: |
git diff --exit-code || echo "changes=true" >> $GITHUB_OUTPUT
# 변경사항 커밋 & 푸시
- name: Commit and push changes
if: steps.git-check.outputs.changes == 'true' && github.event_name == 'pull_request'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .
git commit -m "Apply automatic formatting changes"
git push https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git HEAD:${{ github.head_ref }}
# PR에 코멘트 추가
- name: Comment PR
if: steps.git-check.outputs.changes == 'true' && github.event_name == 'pull_request'
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.name,
body: '✨ Code has been automatically formatted. Please review the changes.'
})
# 남은 문제 확인
- name: Check for remaining issues
if: failure()
run: |
echo "There are still some issues that couldn't be automatically fixed. Please address them manually."
exit 1

0 comments on commit 5754278

Please sign in to comment.