File tree Expand file tree Collapse file tree 3 files changed +66
-2
lines changed
Expand file tree Collapse file tree 3 files changed +66
-2
lines changed Original file line number Diff line number Diff line change 4747 - uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
4848 - name : Test all exercises using java-test-runner
4949 run : bin/test-with-test-runner
50+ - name : Print summary
51+ run : |
52+ if [ -f exercises/build/summary.txt ]; then
53+ echo "===== TEST SUMMARY ====="
54+ cat exercises/build/summary.txt
55+ echo "========================"
56+ else
57+ echo "===== ALL TESTS PASSED ====="
58+ echo "No summary file was generated."
59+ echo "============================="
60+ fi
61+ if : always()
5062 - name : Archive test results
5163 uses : actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
5264 with :
6476 fetch-depth : 0
6577 - name : Test changed exercises using java-test-runner
6678 run : bin/test-changed-exercise
79+ - name : Print summary
80+ run : |
81+ if [ -f exercises/build/summary.txt ]; then
82+ echo "===== TEST SUMMARY ====="
83+ cat exercises/build/summary.txt
84+ echo "========================"
85+ else
86+ echo "===== ALL TESTS PASSED ====="
87+ echo "No summary file was generated."
88+ echo "============================="
89+ fi
90+ if : always()
6791 - name : Archive test results
6892 uses : actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
6993 with :
Original file line number Diff line number Diff line change @@ -35,7 +35,12 @@ echo "Changed exercises detected:"
3535echo " $changed_exercises "
3636echo " ----------------------------------------"
3737
38+ summary_dir=" exercises/build"
39+ summary_file=" ${summary_dir} /summary.txt"
40+ mkdir -p " $summary_dir "
41+
3842# Run tests
43+ exit_code=0
3944for dir in $changed_exercises ; do
4045 slug=$( basename " $dir " )
4146
@@ -47,8 +52,27 @@ for dir in $changed_exercises; do
4752 mkdir -p " $( dirname " $results_path " ) "
4853
4954 if [[ $dir == exercises/practice/* ]]; then
50- ./exercises/gradlew -p exercises " :practice:$slug :test" 2>&1 | tee " $results_path "
55+ ./exercises/gradlew -p exercises " :practice:$slug :test" 2>&1 | tee " $results_path " || true
5156 elif [[ $dir == exercises/concept/* ]]; then
52- ./exercises/gradlew -p exercises " :concept:$slug :test" 2>&1 | tee " $results_path "
57+ ./exercises/gradlew -p exercises " :concept:$slug :test" 2>&1 | tee " $results_path " || true
58+ fi
59+
60+ # Detect failure
61+ if grep -q " FAILED" " $results_path " ; then
62+ exit_code=1
63+
64+ # Determine practice/slug or concept/slug
65+ relative_path=$( echo " $dir " | sed ' s|^exercises/||' )
66+
67+ # Create summary.txt with header only on first failure
68+ if [ ! -f " $summary_file " ]; then
69+ echo " The following exercises have test failures or test errors:" > " $summary_file "
70+ fi
71+
72+ # Append the correct path (practice/slug or concept/slug)
73+ echo " $relative_path " >> " $summary_file "
5374 fi
75+
5476done
77+
78+ exit $exit_code
Original file line number Diff line number Diff line change @@ -12,6 +12,10 @@ docker pull exercism/java-test-runner
1212
1313exit_code=0
1414
15+ summary_dir=" exercises/build"
16+ summary_file=" ${summary_dir} /summary.txt"
17+ mkdir -p " $summary_dir "
18+
1519function run_test_runner() {
1620 local slug=$1
1721 local solution_dir=$2
@@ -56,6 +60,18 @@ function verify_exercise() {
5660
5761 if [[ $( jq -r ' .status' " ${results_file} " ) != " pass" ]]; then
5862 echo " ${slug} : ${implementation_file_key} solution did not pass the tests"
63+
64+ # Determine practice/slug or concept/slug
65+ local relative_path=$( echo " $dir " | sed -E ' s|.*/exercises/||' )
66+
67+ # Create summary.txt with header only on first failure
68+ if [ ! -f " $summary_file " ]; then
69+ echo " The following exercises have test failures or test errors:" > " $summary_file "
70+ fi
71+
72+ # Append the correct path (practice/slug or concept/slug)
73+ echo " $relative_path " >> " $summary_file "
74+
5975 exit_code=1
6076 fi
6177
You can’t perform that action at this time.
0 commit comments