|
43 | 43 | outputs: |
44 | 44 | approved: ${{ steps.check-approval.outputs.approved }} |
45 | 45 | steps: |
| 46 | + - name: Checkout pull request branch |
| 47 | + if: github.event.pull_request != null |
| 48 | + uses: actions/checkout@v3 |
| 49 | + with: |
| 50 | + ref: ${{ github.event.pull_request.head.sha }} |
| 51 | + repository: ${{ github.event.pull_request.head.repo.full_name }} |
| 52 | + fetch-depth: 0 |
| 53 | + |
46 | 54 | - name: Check if PR needs approval |
47 | 55 | id: check-approval |
48 | 56 | run: | |
@@ -96,6 +104,28 @@ jobs: |
96 | 104 | echo "needs_approval=false" >> $GITHUB_OUTPUT |
97 | 105 | echo "comment_needed=false" >> $GITHUB_OUTPUT |
98 | 106 | fi |
| 107 | +
|
| 108 | + - name: Prevent fork modifications to test infrastructure |
| 109 | + if: github.event.pull_request.head.repo.fork == true |
| 110 | + run: | |
| 111 | + log_info() { echo "ℹ️ $1"; } |
| 112 | + log_error() { echo "❌ $1"; } |
| 113 | + log_success() { echo "✅ $1"; } |
| 114 | + |
| 115 | + log_info "Checking for modifications to asimParsersTest folder in fork PR..." |
| 116 | + |
| 117 | + # Get the list of modified files |
| 118 | + modified_files=$(git diff --name-only ${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }}) |
| 119 | + |
| 120 | + # Check if any files in .script/tests/asimParsersTest/ have been modified |
| 121 | + if echo "$modified_files" | grep -E "\.script/tests/asimParsersTest/" > /dev/null; then |
| 122 | + log_error "Fork PRs cannot modify the asimParsersTest test infrastructure folder" |
| 123 | + log_error "Modified test files detected:" |
| 124 | + echo "$modified_files" | grep "\.script/tests/asimParsersTest/" | sed 's/^/ - /' |
| 125 | + exit 1 |
| 126 | + fi |
| 127 | + |
| 128 | + log_success "No modifications to asimParsersTest folder detected" |
99 | 129 | |
100 | 130 | - name: Comment on fork PR for approval guidance |
101 | 131 | if: | |
|
0 commit comments