Skip to content

Commit 3b3ceed

Browse files
committed
Update workflow
1 parent 54f355d commit 3b3ceed

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

.github/workflows/append_ndjson_coverage.yml

+19-6
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,26 @@ jobs:
5454
lfs: false
5555
timeout-minutes: 10
5656

57-
# Update the repository:
58-
- name: 'Update repository'
57+
# Get list of changed files:
58+
- name: 'Get list of changed files'
59+
id: changed-files
5960
run: |
60-
FILES=$(git diff --name-only HEAD^ HEAD | grep -E '^index\.html$')
61-
for FILE in $FILES; do
62-
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 ']')
63-
echo $coverage >> $(dirname $FILE)/coverage.ndjson
61+
# Get changed files by comparing the current commit to the commit before the push event or with its parent:
62+
if [ "${{ github.event.before }}" == "0000000000000000000000000000000000000000" ]; then
63+
files=$(git diff --diff-filter=AM --name-only HEAD~ ${{ github.event.after }})
64+
else
65+
files=$(git diff --diff-filter=AM --name-only ${{ github.event.before }} ${{ github.event.after }})
66+
fi
67+
files=$(echo "$files" | grep -E '^index\.html$')
68+
echo "files=${files}" >> $GITHUB_OUTPUT
69+
70+
# Update coverage data:
71+
- name: 'Update coverage data'
72+
run: |
73+
files=$(echo "${{ steps.changed-files.outputs.files }}" | tr '\n' ' ')
74+
for file in $files; do
75+
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 ']')
76+
echo $coverage >> $(dirname $file)/coverage.ndjson
6477
done
6578
6679
# Configure Git:

0 commit comments

Comments
 (0)