From 1f0ed093b5f8320f5dad508bd7c73c98b13f7152 Mon Sep 17 00:00:00 2001 From: Matty Evans Date: Thu, 19 Dec 2024 07:15:14 +1000 Subject: [PATCH] style: Update test result merging in workflow file --- .github/workflows/go-test.yml | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/go-test.yml b/.github/workflows/go-test.yml index c3eee73..da0b1cc 100644 --- a/.github/workflows/go-test.yml +++ b/.github/workflows/go-test.yml @@ -66,12 +66,25 @@ jobs: - name: Merge test results run: | - # Ensure we start with an empty file - echo "" > test.json - # Merge all test result files + # Start with an empty array + echo "[" > test.json + + # Merge all test result files, adding commas between them + first=true for f in test.*.json; do - cat "$f" >> test.json + if [ -f "$f" ]; then + if [ "$first" = true ]; then + first=false + else + echo "," >> test.json + fi + # Remove the last newline if it exists and append to test.json + sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/,/g' "$f" >> test.json + fi done + + # Close the array + echo "]" >> test.json - name: Annotate tests uses: guyarb/golang-test-annotations@v0.6.0