@@ -690,6 +690,14 @@ jobs:
690690
691691 if [ "${CHECKS_EXIT:-0}" -ne 0 ]; then
692692 echo "❌ Pre-commit checks failed with exit code: ${CHECKS_EXIT}"
693+ # Persist cleaned output to log file for summary and artifact upload
694+ # Use printf to avoid echo misinterpreting leading -n/-e in output
695+ printf '%s\n' "$CHECKS_OUTPUT" | \
696+ sed -E 's/\x1b\[[0-9;]*[mGKH]//g' | \
697+ sed 's/\xc2\x9b\[[0-9;]*[mGKH]//g' | \
698+ sed 's/�\[[0-9;]*[mGKH]//g' | \
699+ sed 's/�//g' | \
700+ tr -d '\033' > pre-commit-output.log
693701 # Emit GitHub annotation for visibility at top of summary
694702 echo "::error title=Pre-commit Checks Failed::Code quality issues detected - formatting, linting, or other pre-commit checks failed"
695703 exit ${CHECKS_EXIT}
@@ -843,15 +851,35 @@ jobs:
843851 fi
844852 done
845853 echo "" >> $GITHUB_STEP_SUMMARY
846- if [[ "${{ env.GO_PRE_COMMIT_ALL_FILES }}" == "true" ]]; then
847- echo "🎯 **All pre-commit checks passed successfully on all repository files.**" >> $GITHUB_STEP_SUMMARY
848- elif [[ "${{ steps.detect-files.outputs.files_found }}" == "true" ]]; then
849- FILE_COUNT=$(echo "${{ steps.detect-files.outputs.changed_files }}" | wc -l | tr -d ' ')
850- echo "🎯 **All pre-commit checks passed successfully on $FILE_COUNT changed files.**" >> $GITHUB_STEP_SUMMARY
854+ # Show failure details or success summary based on run-checks outcome + log presence
855+ if [[ -f pre-commit-output.log ]]; then
856+ # Normal failure: log file was created, show full error details
857+ echo "### 🚨 Error Details" >> $GITHUB_STEP_SUMMARY
851858 echo "" >> $GITHUB_STEP_SUMMARY
852- echo "⚡ **Performance**: Fast CI execution by checking only changed files instead of entire repository." >> $GITHUB_STEP_SUMMARY
859+ echo "<details>" >> $GITHUB_STEP_SUMMARY
860+ echo "<summary>Click to expand full output</summary>" >> $GITHUB_STEP_SUMMARY
861+ echo "" >> $GITHUB_STEP_SUMMARY
862+ echo '```' >> $GITHUB_STEP_SUMMARY
863+ head -200 pre-commit-output.log >> $GITHUB_STEP_SUMMARY
864+ echo '```' >> $GITHUB_STEP_SUMMARY
865+ echo "</details>" >> $GITHUB_STEP_SUMMARY
866+ elif [[ "${{ steps.run-checks.outcome }}" == "failure" ]]; then
867+ # Early failure: step failed before the log file could be written
868+ # (e.g. invalid binary path, mktemp failure, etc.)
869+ echo "### 🚨 Error Details" >> $GITHUB_STEP_SUMMARY
870+ echo "" >> $GITHUB_STEP_SUMMARY
871+ echo "Pre-commit checks failed before an output log could be generated. Review the **Run pre-commit checks** step logs for details." >> $GITHUB_STEP_SUMMARY
853872 else
854- echo "🎯 **Pre-commit checks completed (no files required checking).**" >> $GITHUB_STEP_SUMMARY
873+ if [[ "${{ env.GO_PRE_COMMIT_ALL_FILES }}" == "true" ]]; then
874+ echo "🎯 **All pre-commit checks passed successfully on all repository files.**" >> $GITHUB_STEP_SUMMARY
875+ elif [[ "${{ steps.detect-files.outputs.files_found }}" == "true" ]]; then
876+ FILE_COUNT=$(echo "${{ steps.detect-files.outputs.changed_files }}" | wc -l | tr -d ' ')
877+ echo "🎯 **All pre-commit checks passed successfully on $FILE_COUNT changed files.**" >> $GITHUB_STEP_SUMMARY
878+ echo "" >> $GITHUB_STEP_SUMMARY
879+ echo "⚡ **Performance**: Fast CI execution by checking only changed files instead of entire repository." >> $GITHUB_STEP_SUMMARY
880+ else
881+ echo "🎯 **Pre-commit checks completed (no files required checking).**" >> $GITHUB_STEP_SUMMARY
882+ fi
855883 fi
856884 else
857885 echo "### ⚠️ Fallback Mode" >> $GITHUB_STEP_SUMMARY
@@ -860,6 +888,18 @@ jobs:
860888 echo "- ✅ magex tidy" >> $GITHUB_STEP_SUMMARY
861889 fi
862890
891+ # --------------------------------------------------------------------
892+ # Upload pre-commit results (only present on failure)
893+ # --------------------------------------------------------------------
894+ - name : 📤 Upload pre-commit results
895+ if : always()
896+ uses : ./.github/actions/upload-artifact-resilient
897+ with :
898+ artifact-name : pre-commit-results
899+ artifact-path : pre-commit-output.log
900+ retention-days : " 7"
901+ if-no-files-found : ignore
902+
863903 # --------------------------------------------------------------------
864904 # Collect cache statistics
865905 # --------------------------------------------------------------------
0 commit comments