@@ -244,19 +244,19 @@ jobs:
244
244
# Copy artifacts to the repository:
245
245
- name : ' Copy artifacts to the repository'
246
246
run : |
247
- cp -R ./artifacts/* ./www-test-code-coverage
247
+ cp -R ./artifacts/* ./www-test-code-coverage
248
248
249
- # Get commit SHA and timestamp:
250
- commit_sha=$(git rev-parse HEAD)
251
- commit_timestamp=$(git show -s --format=%ci $commit_sha)
249
+ # Get commit SHA and timestamp:
250
+ commit_sha=$(git rev-parse HEAD)
251
+ commit_timestamp=$(git show -s --format=%ci $commit_sha)
252
252
253
- # Append coverage to ndjson files:
254
- files=$(find ./artifacts -name 'index.html')
255
- for file in $files; do
256
- sed -i 's/\ /artifacts\//\/ www-test-code-coverage\//g' $file
257
- coverage=$(echo -n '['; grep -oP "(?<=class='fraction'>)[0-9]+/[0-9]+" $file | awk -F/ '{ print $1 "," $2 "," ($1/$2)*100 }' | tr '\n' ',' | sed 's/,$//'; echo -n ",\"$commit_sha\",\"$commit_timestamp\"]")
258
- echo $coverage >> $(dirname $file)/coverage.ndjson
259
- done
253
+ # Append coverage to ndjson files:
254
+ files=$(find ./artifacts -name 'index.html')
255
+ for file in $files; do
256
+ file=${file/ /artifacts/ www-test-code-coverage}
257
+ 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\"]")
258
+ echo $coverage >> $(dirname $file)/coverage.ndjson
259
+ done
260
260
261
261
# Commit and push changes:
262
262
- name : ' Commit and push changes'
@@ -270,4 +270,3 @@ jobs:
270
270
git add .
271
271
git commit -m "Update artifacts"
272
272
git push "https://$USER_NAME:$REPO_GITHUB_TOKEN@github.com/stdlib-js/www-test-code-coverage.git" $BRANCH_NAME
273
-
0 commit comments