Repository: xsuite/xsuite (language: python)

Issue:
Create Job summaries results in GitHub Actions runner and Analyze results from CSV to graph
## Description
<!-- I Create Job summary results in GitHub Actions runner changed the script of both test_sh.yaml and dailytest_sh.yaml to show the summary results with Markdown format, and created the Analyze results script in the scripts folder to Analyze raw data from CSV file of tests to summary tests results in CSV and graph format  -->

Closes # .

## Checklist

Mandatory: 

- [ ] I have added tests to cover my changes
- [ ] All the tests are passing, including my new ones
- [ ] I described my changes in this PR description

Optional:

- [ ] The code I wrote follows good style practices (see [PEP 8](https://peps.python.org/pep-0008/) and [PEP 20](https://peps.python.org/pep-0020/)).
- [ ] I have updated the docs in relation to my changes, if applicable
- [ ] I have tested also GPU contexts



Discussion / hints:

Fix patch:
diff --git a/.github/scripts/generate_summary.sh b/.github/scripts/generate_summary.sh
new file mode 100644
index 00000000..84a7da76
--- /dev/null
+++ b/.github/scripts/generate_summary.sh
@@ -0,0 +1,52 @@
+#!/bin/bash
+# copyright ############################### #
+# This file is part of the Xsuite project.  #
+# Copyright (c) CERN, 2024.                 #
+# ######################################### #
+set -xe
+
+echo "## Test Summary $1"
+
+results_file="reports/$1/results.txt"
+
+if [ -f "$results_file" ]; then
+  # Results file found, processing...
+  sed -i -e 's/\x1b\[[0-9;]*m//g' -e 's/^> /\\> /g' $results_file
+
+  passed=$(grep -c PASSED $results_file || true)
+  failed=$(grep "FAILED.*xsuite" $results_file | grep -P 'FAILED.* - ' | sed -E 's/.*\] (.*::[^ ]+).* - .*/\1/' | sort | uniq | wc -l)
+  skipped=$(grep -c SKIPPED $results_file || true)
+
+  echo "| Result     | Number   |"
+  echo "|------------|----------|"
+  echo "| Passed ✅  | $passed  |"
+  echo "| Failed ❌  | $failed  |"
+  echo "| Skipped ⏭️ | $skipped |"
+
+  if [ $failed -ne 0 ]; then
+    echo "### 🔴 Failed Tests"
+    grep "FAILED.*xsuite" $results_file | grep -P 'FAILED.* - ' | sed -E 's/.*\] (.*::[^ ]+).* - (.*)/\1 - \2/' | sort | uniq | while read -r failure; do
+      echo "- $failure"
+
+      echo "<details><summary>Click here to view the error details</summary><code>"
+      # Extract the failure name
+      test_name=$(echo "$failure" | sed -E 's/.*::([^\-]+).* - .*/\1/' | sed -E 's/\x1b\[[0-9;]*m//g' )
+      test_name=$(echo "$test_name" | sed 's/[][]/\\&/g')
+      # Find the start of the error block
+      error_start_line=$(grep -n "____________________ ${test_name} ____________________" $results_file | cut -d: -f1)
+      # Debug: Start line found at $error_start_line
+      error_end_line=$(tail -n +$((error_start_line + 1)) $results_file | grep -nm 1 "^-.*Captured stdout call.*-$" | cut -d: -f1)
+      if [[ ! -z "$error_start_line" ]]; then
+        error_end_line=$(tail -n +$((error_start_line + 1)) $results_file | grep -nm 1 "^-.*Captured stdout call.*-$" | cut -d: -f1)
+        if [[ ! -z "$error_end_line" ]]; then
+            # Find the end of the error block
+            absolute_error_end_line=$((error_start_line + error_end_line - 1))
+            sed -n "${error_start_line},${absolute_error_end_line}p" $results_file | sed 's/^>/\\>/'
+        fi
+      fi
+      echo "</code></details>"
+    done
+  fi
+else
+  echo "No test results found."
+fi


Test patch:
diff --git a/.github/workflows/test_sh.yaml b/.github/workflows/test_sh.yaml
index 215b2532..e3d7fe73 100644
--- a/.github/workflows/test_sh.yaml
+++ b/.github/workflows/test_sh.yaml
@@ -104,13 +104,17 @@ jobs:
         test_contexts: ${{ inputs.test_contexts }}
         pytest_options: ${{ inputs.pytest_options }}
       run: |
-          mkdir -p reports/${{ matrix.test-suite }}
-          docker run --rm --gpus all \
-            --env XOBJECTS_TEST_CONTEXTS="${test_contexts}" \
-            --env PYTEST_ADDOPTS="${pytest_options}" \
-            -v $PWD/reports/${{ matrix.test-suite }}:/opt/reports:Z \
-            ${image_id} \
-            /opt/run_tests.sh /opt/xsuite/${{ matrix.test-suite }}/tests
+        mkdir -p reports/${{ matrix.test-suite }}
+        docker run --rm --gpus all \
+          --env XOBJECTS_TEST_CONTEXTS="${test_contexts}" \
+          --env PYTEST_ADDOPTS="${pytest_options}" \
+          -v $PWD/reports/${{ matrix.test-suite }}:/opt/reports:Z \
+          ${image_id} \
+          /opt/run_tests.sh /opt/xsuite/${{ matrix.test-suite }}/tests \
+            | tee reports/${{ matrix.test-suite }}/results.txt
+
+    - name: Generate Summary Report
+      run: bash .github/scripts/generate_summary.sh ${{ matrix.test-suite }} >> $GITHUB_STEP_SUMMARY
 
   wait:
     runs-on: [self-hosted, "${{ inputs.platform }}"]