@@ -179,8 +179,24 @@ jobs:
179179 distribution : ' temurin'
180180 java-version : ' 25'
181181
182+ - name : Check for modified files and test presence
183+ id : code-check
184+ run : |
185+ # Check for test files
186+ has_tests=$(find src/test/java -type f -name "*.java" | grep -q . && echo "true" || echo "false")
187+
188+ # Check for modified files in src folders
189+ git fetch origin main
190+ changed_files=$(git diff --name-only origin/main...HEAD | grep -E '^src/(main|test)/java/.*\.java$' || true)
191+ has_changes=$(test -n "$changed_files" && echo "true" || echo "false")
192+
193+ echo "has_tests=$has_tests" >> $GITHUB_OUTPUT
194+ echo "has_changes=$has_changes" >> $GITHUB_OUTPUT
195+ echo "should_grade=$([[ $has_tests == 'true' && $has_changes == 'true' ]] && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
196+
182197 - name : Compilation Check
183198 id : compilation-check
199+ if : ${{ steps.code-check.outputs.has_tests == 'true' && steps.code-check.outputs.has_changes == 'true' }}
184200 uses : classroom-resources/autograding-command-grader@v1
185201 with :
186202 test-name : Compilation Check
@@ -190,6 +206,7 @@ jobs:
190206
191207 - name : Tests
192208 id : basic-tests
209+ if : ${{ steps.code-check.outputs.has_tests == 'true' && steps.code-check.outputs.has_changes == 'true' }}
193210 uses : classroom-resources/autograding-command-grader@v1
194211 with :
195212 test-name : Basic Tests
@@ -198,9 +215,15 @@ jobs:
198215 max-score : 1
199216
200217 - name : Autograding Reporter
218+ if : ${{ steps.code-check.outputs.should_grade == 'true' }}
201219 uses : classroom-resources/autograding-grading-reporter@v1
202220 env :
203221 COMPILATION-CHECK_RESULTS : " ${{steps.compilation-check.outputs.result}}"
204222 BASIC-TESTS_RESULTS : " ${{steps.basic-tests.outputs.result}}"
205223 with :
206224 runners : compilation-check,basic-tests
225+
226+ - name : Reporter Skipped Notice
227+ if : ${{ steps.code-check.outputs.should_grade != 'true' }}
228+ run : |
229+ echo "🛑 Skipping reporter: No grading results available due to missing tests or unchanged code."
0 commit comments