Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ jobs:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
- name: Test all exercises using java-test-runner
run: bin/test-with-test-runner
- name: Print summary
run: |
if [ -f exercises/build/summary.txt ]; then
echo "===== TEST SUMMARY ====="
cat exercises/build/summary.txt
echo "========================"
else
echo "===== ALL TESTS PASSED ====="
echo "No summary file was generated."
echo "============================="
fi
if: always()
- name: Archive test results
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
with:
Expand All @@ -64,6 +76,18 @@ jobs:
fetch-depth: 0
- name: Test changed exercises using java-test-runner
run: bin/test-changed-exercise
- name: Print summary
run: |
if [ -f exercises/build/summary.txt ]; then
echo "===== TEST SUMMARY ====="
cat exercises/build/summary.txt
echo "========================"
else
echo "===== ALL TESTS PASSED ====="
echo "No summary file was generated."
echo "============================="
fi
if: always()
- name: Archive test results
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
with:
Expand Down
28 changes: 26 additions & 2 deletions bin/test-changed-exercise
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ echo "Changed exercises detected:"
echo "$changed_exercises"
echo "----------------------------------------"

summary_dir="exercises/build"
summary_file="${summary_dir}/summary.txt"
mkdir -p "$summary_dir"

# Run tests
exit_code=0
for dir in $changed_exercises; do
slug=$(basename "$dir")

Expand All @@ -47,8 +52,27 @@ for dir in $changed_exercises; do
mkdir -p "$(dirname "$results_path")"

if [[ $dir == exercises/practice/* ]]; then
./exercises/gradlew -p exercises ":practice:$slug:test" 2>&1 | tee "$results_path"
./exercises/gradlew -p exercises ":practice:$slug:test" 2>&1 | tee "$results_path" || true
elif [[ $dir == exercises/concept/* ]]; then
./exercises/gradlew -p exercises ":concept:$slug:test" 2>&1 | tee "$results_path"
./exercises/gradlew -p exercises ":concept:$slug:test" 2>&1 | tee "$results_path" || true
fi

# Detect failure
if grep -q "FAILED" "$results_path"; then
exit_code=1

# Determine practice/slug or concept/slug
relative_path=$(echo "$dir" | sed 's|^exercises/||')

# Create summary.txt with header only on first failure
if [ ! -f "$summary_file" ]; then
echo "The following exercises have test failures or test errors:" > "$summary_file"
fi

# Append the correct path (practice/slug or concept/slug)
echo "$relative_path" >> "$summary_file"
fi

done

exit $exit_code
16 changes: 16 additions & 0 deletions bin/test-with-test-runner
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ docker pull exercism/java-test-runner

exit_code=0

summary_dir="exercises/build"
summary_file="${summary_dir}/summary.txt"
mkdir -p "$summary_dir"

function run_test_runner() {
local slug=$1
local solution_dir=$2
Expand Down Expand Up @@ -56,6 +60,18 @@ function verify_exercise() {

if [[ $(jq -r '.status' "${results_file}") != "pass" ]]; then
echo "${slug}: ${implementation_file_key} solution did not pass the tests"

# Determine practice/slug or concept/slug
local relative_path=$(echo "$dir" | sed -E 's|.*/exercises/||')

# Create summary.txt with header only on first failure
if [ ! -f "$summary_file" ]; then
echo "The following exercises have test failures or test errors:" > "$summary_file"
fi

# Append the correct path (practice/slug or concept/slug)
echo "$relative_path" >> "$summary_file"

exit_code=1
fi

Expand Down