@@ -34,10 +34,10 @@ jobs:
3434 COMPARATORS=$(ls scripts/compare-builds/*.mjs | xargs -n1 basename | sed 's/\.mjs$//' | jq -R -s -c 'split("\n")[:-1]')
3535 echo "comparators=$COMPARATORS" >> $GITHUB_OUTPUT
3636
37- web :
37+ compare :
3838 name : Run ${{ matrix.comparator }} comparator
3939 runs-on : ubuntu-latest
40- needs : [ get-comparators]
40+ needs : get-comparators
4141 strategy :
4242 matrix :
4343 comparator : ${{ fromJSON(needs.get-comparators.outputs.comparators) }}
@@ -82,18 +82,23 @@ jobs:
8282 id : compare
8383 run : |
8484 node scripts/compare-builds/${{ matrix.comparator }}.mjs > result.txt
85+ if [ -s result.txt ]; then
86+ echo "has_output=true" >> "$GITHUB_OUTPUT"
87+ else
88+ echo "has_output=false" >> "$GITHUB_OUTPUT"
89+ fi
8590
8691 - name : Upload comparison artifact
92+ if : steps.compare.outputs.has_output == 'true'
8793 uses : actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
8894 with :
8995 name : ${{ matrix.comparator }}
90- path : result .txt
96+ path : ${{ matrix.comparator }} .txt
9197
9298 aggregate :
9399 name : Aggregate Comparison Results
94100 runs-on : ubuntu-latest
95- needs : [web]
96-
101+ needs : compare
97102 steps :
98103 - name : Download all comparison artifacts
99104 uses : actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
@@ -103,17 +108,25 @@ jobs:
103108 - name : Combine results
104109 id : combine
105110 run : |
106- tree .
107- cat results/**/*.txt > combined.txt
108- echo "combined<<EOF" >> $GITHUB_OUTPUT
109- cat combined.txt >> $GITHUB_OUTPUT
110- echo "EOF" >> $GITHUB_OUTPUT
111+ result_files=(results/*.txt)
112+
113+ if (( ${#result_files[@]} )); then
114+ cat "${result_files[@]}" > combined.txt
115+ {
116+ echo "combined<<EOF"
117+ cat combined.txt
118+ echo "EOF"
119+ echo "has_results=true"
120+ } >> "$GITHUB_OUTPUT"
121+ else
122+ echo "has_results=false" >> "$GITHUB_OUTPUT"
123+ fi
111124
112- - run : echo combined.txt
113125 - name : Add Comment to PR
126+ if : steps.combine.outputs.has_results == 'true'
114127 uses : thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3.0.1
115128 with :
116- comment-tag : ' compared'
129+ comment-tag : compared
117130 message : ${{ steps.combine.outputs.combined }}
118131 pr-number : ${{ github.event.pull_request.number }}
119132 # pr-number: ${{ github.event.workflow_run.pull_requests[0].number }}
0 commit comments