@@ -169,18 +169,20 @@ jobs:
169169 id : create-report
170170 run : |
171171 table="${{ steps.extract-coverage.outputs.table }}"
172-
173- if [ "${{ github.event_name }}" == "pull_request" ]; then
174- compare_url="https://github.com/stdlib-js/stdlib/compare/${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }}"
175- compare_txt="The above coverage report was generated for the [changes in this PR]($compare_url)."
176- elif [ "${{ github.event_name }}" == "push" ]; then
177- compare_url="https://github.com/stdlib-js/stdlib/compare/${{ github.event.before }}...${{ github.event.after }}"
178- compare_txt="The above coverage report was generated for the [changes in this push]($compare_url)."
172+ if [ -z "$table" ]; then
173+ report="## Coverage Report\n\nNo coverage information available."
179174 else
180- compare_txt=""
175+ if [ "${{ github.event_name }}" == "pull_request" ]; then
176+ compare_url="https://github.com/stdlib-js/stdlib/compare/${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }}"
177+ compare_txt="The above coverage report was generated for the [changes in this PR]($compare_url)."
178+ elif [ "${{ github.event_name }}" == "push" ]; then
179+ compare_url="https://github.com/stdlib-js/stdlib/compare/${{ github.event.before }}...${{ github.event.after }}"
180+ compare_txt="The above coverage report was generated for the [changes in this push]($compare_url)."
181+ else
182+ compare_txt=""
183+ fi
184+ report="## Coverage Report\n\n${table}\n\n${compare_txt}"
181185 fi
182-
183- report="## Coverage Report\n\n${table}\n\n${compare_txt}"
184186 echo "report=$report" >> $GITHUB_OUTPUT
185187
186188 # Post report as comment to PR:
@@ -249,19 +251,23 @@ jobs:
249251 # Copy artifacts to the repository:
250252 - name : ' Copy artifacts to the repository'
251253 run : |
252- cp -R ./artifacts/* ./www-test-code-coverage
253-
254- # Get commit SHA and timestamp:
255- commit_sha=$(git rev-parse HEAD)
256- commit_timestamp=$(git show -s --format=%ci $commit_sha)
257-
258- # Append coverage to ndjson files:
259- files=$(find ./artifacts -name 'index.html')
260- for file in $files; do
261- file=${file//artifacts/www-test-code-coverage}
262- coverage=$(echo -n '['; grep -oP "(?<=class='fraction'>)[0-9]+/[0-9]+" $file | awk -F/ '{ if ($2 != 0) print $1 "," $2 "," ($1/$2)*100; else print $1 "," $2 ",100" }' | tr '\n' ',' | sed 's/,$//'; echo -n ",\"$commit_sha\",\"$commit_timestamp\"]")
263- echo $coverage >> $(dirname $file)/coverage.ndjson
264- done
254+ if [ -d "./artifacts" ]; then
255+ cp -R ./artifacts/* ./www-test-code-coverage
256+
257+ # Get commit SHA and timestamp:
258+ commit_sha=$(git rev-parse HEAD)
259+ commit_timestamp=$(git show -s --format=%ci $commit_sha)
260+
261+ # Append coverage to ndjson files:
262+ files=$(find ./artifacts -name 'index.html')
263+ for file in $files; do
264+ file=${file//artifacts/www-test-code-coverage}
265+ coverage=$(echo -n '['; grep -oP "(?<=class='fraction'>)[0-9]+/[0-9]+" $file | awk -F/ '{ if ($2 != 0) print $1 "," $2 "," ($1/$2)*100; else print $1 "," $2 ",100" }' | tr '\n' ',' | sed 's/,$//'; echo -n ",\"$commit_sha\",\"$commit_timestamp\"]")
266+ echo $coverage >> $(dirname $file)/coverage.ndjson
267+ done
268+ else
269+ echo "The artifacts directory does not exist."
270+ fi
265271
266272 # Commit and push changes:
267273 - name : ' Commit and push changes'
0 commit comments