Skip to content

Commit a88c294

Browse files
committed
build: append coverage NDJSON with SHA and timestamp
1 parent e29732d commit a88c294

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

.github/workflows/run_tests_coverage.yml

+12
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,18 @@ jobs:
246246
run: |
247247
cp -R ./artifacts/* ./www-test-code-coverage
248248
249+
# Get commit SHA and timestamp:
250+
commit_sha=$(git rev-parse HEAD)
251+
commit_timestamp=$(git show -s --format=%ci $commit_sha)
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
260+
249261
# Commit and push changes:
250262
- name: 'Commit and push changes'
251263
env:

0 commit comments

Comments
 (0)