diff --git a/.github/scripts/GUARD_COMMITS.sh b/.github/scripts/GUARD_COMMITS.sh new file mode 100755 index 0000000..c07d553 --- /dev/null +++ b/.github/scripts/GUARD_COMMITS.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +TARGET_FILES=("swift-cinema/Sources/CinemaUI/MovieList.swift" "swift-cinema/Sources/CinemaUI/MovieRow.swift" "swift-cinema/Sources/CinemaUI/SubmissionDetailView.swift" "swift-cinema/Sources/Fetcher/Responses.swift" "swift-cinema/Tests/FetcherTests/MovieCollectionFetcherTests.swift" ".github/workflows/REVIEW_CODE.yml") + +FIRST_COMMIT=$(git rev-list --max-parents=0 HEAD) + +CHANGED_FILES=$(git diff -w --name-only $FIRST_COMMIT HEAD) + +MODIFIED_TARGET_FILES=() +for TARGET_FILE in "${TARGET_FILES[@]}"; do + if [[ $CHANGED_FILES == *"$TARGET_FILE"* ]]; then + MODIFIED_TARGET_FILES+=("$TARGET_FILE") + fi +done + +if [ ${#MODIFIED_TARGET_FILES[@]} -gt 0 ]; then + for MODIFIED_FILE in "${MODIFIED_TARGET_FILES[@]}"; do + echo "::warning:: $MODIFIED_FILE 에서 올바르지 않은 수정이 발견되었습니다." + done +fi + +echo "커밋 가드 종료" diff --git a/.github/workflows/REVIEW_CODE.yml b/.github/workflows/REVIEW_CODE.yml index 1d4910f..5609184 100644 --- a/.github/workflows/REVIEW_CODE.yml +++ b/.github/workflows/REVIEW_CODE.yml @@ -11,7 +11,21 @@ concurrency: cancel-in-progress: true jobs: + guard-commits: + name: 커밋 검증을 시작합니다 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + - name: 커밋 체크 + run: | + chmod +x .github/scripts/GUARD_COMMITS.sh + .github/scripts/GUARD_COMMITS.sh + build-xcproject: + needs: guard-commits name: 앱프로젝트를 빌드합니다 runs-on: macos-13 steps: @@ -31,6 +45,7 @@ jobs: build-package: + needs: guard-commits name: 스위프트 패키지를 빌드 합니다 runs-on: macos-13 steps: @@ -44,6 +59,7 @@ jobs: test-package: + needs: guard-commits name: 스위프트 패키지를 테스트 합니다 runs-on: macos-13 steps: @@ -54,4 +70,3 @@ jobs: run: | cd swift-cinema xcodebuild test -scheme FetcherTests -destination 'platform=iOS Simulator,name=iPhone 15 Pro,OS=latest' -