From 83b244de95673b3c1211f5a93d9c81f4e360fe20 Mon Sep 17 00:00:00 2001 From: Simon Legrand Date: Sun, 16 Nov 2025 17:51:44 +0100 Subject: [PATCH] [CI] Tests failed properly and logs are printed --- .github/workflows/full-mpich.yml | 7 ++----- .github/workflows/full-msmpi.yml | 4 +--- .github/workflows/full-openmpi.yml | 4 +--- .github/workflows/minimal.yml | 10 +++------- .github/workflows/sequential.yml | 10 +++------- etc/actions/failed_tests_logs.sh | 26 +++++++++++++++++++------- 6 files changed, 29 insertions(+), 32 deletions(-) diff --git a/.github/workflows/full-mpich.yml b/.github/workflows/full-mpich.yml index 8444a4908..8e966db53 100644 --- a/.github/workflows/full-mpich.yml +++ b/.github/workflows/full-mpich.yml @@ -6,7 +6,6 @@ on: branches: - develop - master - - slegrand-actions-debug pull_request: branches: @@ -73,8 +72,7 @@ jobs: - name: Check run: | - make check - echo "Tests failed: " $(grep :test-result examples/*/*.trs | grep FAIL | wc -l) + make check -i ./etc/actions/failed_tests_logs.sh - name: Install @@ -150,8 +148,7 @@ jobs: - name: Check run: | - make check - echo "Tests failed: " $(grep :test-result examples/*/*.trs | grep FAIL | wc -l) + make check -i ./etc/actions/failed_tests_logs.sh - name: Install diff --git a/.github/workflows/full-msmpi.yml b/.github/workflows/full-msmpi.yml index 457707fda..ed3dfce8e 100644 --- a/.github/workflows/full-msmpi.yml +++ b/.github/workflows/full-msmpi.yml @@ -6,7 +6,6 @@ on: branches: - develop - master - - slegrand-actions-debug pull_request: branches: @@ -106,6 +105,5 @@ jobs: - name: Check run: | - make check - echo "Tests failed: " $(grep :test-result examples/*/*.trs | grep FAIL | wc -l) + make check -i ./etc/actions/failed_tests_logs.sh diff --git a/.github/workflows/full-openmpi.yml b/.github/workflows/full-openmpi.yml index b9e6636c4..e65886f44 100644 --- a/.github/workflows/full-openmpi.yml +++ b/.github/workflows/full-openmpi.yml @@ -6,7 +6,6 @@ on: branches: - develop - master - - slegrand-actions-debug pull_request: branches: @@ -73,8 +72,7 @@ jobs: - name: Check run: | - make check - echo "Tests failed: " $(grep :test-result examples/*/*.trs | grep FAIL | wc -l) + make check -i ./etc/actions/failed_tests_logs.sh - name: Install diff --git a/.github/workflows/minimal.yml b/.github/workflows/minimal.yml index bb9f8fc4e..75d189697 100644 --- a/.github/workflows/minimal.yml +++ b/.github/workflows/minimal.yml @@ -5,7 +5,6 @@ on: branches: - develop - master - - slegrand-actions-debug pull_request: branches: @@ -49,8 +48,7 @@ jobs: - name: Check run: | - make check - echo "Tests failed: " $(grep :test-result examples/*/*.trs | grep FAIL | wc -l) + make check -i ./etc/actions/failed_tests_logs.sh - name: Install @@ -88,8 +86,7 @@ jobs: - name: Check run: | - make check - echo "Tests failed: " $(grep :test-result examples/*/*.trs | grep FAIL | wc -l) + make check -i ./etc/actions/failed_tests_logs.sh - name: Install @@ -139,6 +136,5 @@ jobs: - name: Check run: | - make check - echo "Tests failed: " $(grep :test-result examples/*/*.trs | grep FAIL | wc -l) + make check -i ./etc/actions/failed_tests_logs.sh diff --git a/.github/workflows/sequential.yml b/.github/workflows/sequential.yml index fdd860f57..61e3f4dfb 100644 --- a/.github/workflows/sequential.yml +++ b/.github/workflows/sequential.yml @@ -5,7 +5,6 @@ on: branches: - develop - master - - slegrand-actions-debug pull_request: branches: @@ -51,8 +50,7 @@ jobs: - name: Check run: | - make check - echo "Tests failed: " $(grep :test-result examples/*/*.trs | grep FAIL | wc -l) + make check -i ./etc/actions/failed_tests_logs.sh - name: Install @@ -89,8 +87,7 @@ jobs: - name: Check run: | - make check - echo "Tests failed: " $(grep :test-result examples/*/*.trs | grep FAIL | wc -l) + make check -i ./etc/actions/failed_tests_logs.sh - name: Install @@ -146,6 +143,5 @@ jobs: - name: Check run: | - make check - echo "Tests failed: " $(grep :test-result examples/*/*.trs | grep FAIL | wc -l) + make check -i ./etc/actions/failed_tests_logs.sh diff --git a/etc/actions/failed_tests_logs.sh b/etc/actions/failed_tests_logs.sh index 21dc9fd2c..53f4ac124 100755 --- a/etc/actions/failed_tests_logs.sh +++ b/etc/actions/failed_tests_logs.sh @@ -1,12 +1,24 @@ #!/usr/bin/env bash -FAILED_TESTS=( $(grep :test-result examples/*/*.trs | grep FAIL) ) +# This script checks if tests have failed. If yes, it prints the content of the +# failed tests log, and returns 1. +# +# It allows keeping the '-i' option for 'make check', print the failed +# tests, and only then, return exit 1 to interrupt the CI pipeline. -for val in ${FAILED_TESTS[@]/#*FAIL/} -do - IFS="::" - read -ra path <<< $val +FAILED_TESTS=$(grep ":test-result: FAIL" examples/*/*.trs) + +if [ -z "$FAILED_TESTS" ]; then + exit 0; +fi + +NB_FAILED_TESTS=$(echo "$FAILED_TESTS" | wc -l) +echo "$NB_FAILED_TESTS tests failed:" + +echo "$FAILED_TESTS" | while IFS= read -r line; do + path="${line%::test-result: FAIL}" printf "\n******** ${path%.*}.log ********\n\n" tail -n 100 ${path%.*}.log - unset IFS -done; +done + +exit 1