Skip to content

Commit 6bf5d74

Browse files
edburnsCopilot
andcommitted
fix: use grep -m 1 instead of grep | head -1 to avoid broken pipe
The shell runs with 'set -e -o pipefail', so when head -1 closes the pipe early, grep exits with SIGPIPE (exit 141) and pipefail propagates that as the pipeline's exit status, failing the step. Using 'grep -m 1' makes grep stop after the first match itself, eliminating the broken pipe entirely. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent c974c00 commit 6bf5d74

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

.github/actions/java-test-report/action.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ runs:
6666
for file in ${{ inputs.report-path }}; do
6767
if [ -f "$file" ]; then
6868
CLASS=$(basename "$file" .xml | sed 's/TEST-//')
69-
T=$(grep -o 'tests="[0-9]*"' "$file" | head -1 | sed 's/[^0-9]//g')
70-
F=$(grep -o 'failures="[0-9]*"' "$file" | head -1 | sed 's/[^0-9]//g')
71-
E=$(grep -o 'errors="[0-9]*"' "$file" | head -1 | sed 's/[^0-9]//g')
72-
TIME=$(grep -o 'time="[0-9.]*"' "$file" | head -1 | sed 's/[^0-9.]//g')
69+
T=$(grep -m 1 -o 'tests="[0-9]*"' "$file" | sed 's/[^0-9]//g')
70+
F=$(grep -m 1 -o 'failures="[0-9]*"' "$file" | sed 's/[^0-9]//g')
71+
E=$(grep -m 1 -o 'errors="[0-9]*"' "$file" | sed 's/[^0-9]//g')
72+
TIME=$(grep -m 1 -o 'time="[0-9.]*"' "$file" | sed 's/[^0-9.]//g')
7373
P=$((T - F - E))
7474
7575
STATUS="✅"

0 commit comments

Comments
 (0)