Skip to content

Commit b7a7af8

Browse files
committed
refactor: let pdd to generate report in JSON rather than convert it manually
1 parent 3bf056f commit b7a7af8

File tree

2 files changed

+16
-60
lines changed

2 files changed

+16
-60
lines changed

.github/workflows/todos-extract-from-code.yml

+16-18
Original file line numberDiff line numberDiff line change
@@ -58,31 +58,28 @@ jobs:
5858
--exclude 'src/test/wiremock/**/*' \
5959
--exclude 'generated-todos/**' \
6060
--verbose \
61-
--file pdd.xml
61+
--format json \
62+
--file pdd.json
6263
63-
- name: Remove the current date from pdd.xml
64-
run: sed -i -E '/<time>[-0-9T:Z]+<\/time>/d;/<puzzles/s| date="[-0-9T:Z]+"||' pdd.xml
65-
66-
# Workaround for #1659
67-
- name: Remove author and email
68-
run: sed -i '/<author>/d;/<email>/d' pdd.xml
64+
- name: Remove the current date from pdd.json
65+
run: sed -i '/"date":/d' pdd.json
6966

7067
- name: Generate todos-in-code.tsv
71-
run: ./src/main/scripts/ci/pdd-xml-to-json.sh pdd.xml | ./src/main/scripts/ci/pdd-json-to-tsv.sh > todos-in-code.tsv
68+
run: ./src/main/scripts/ci/pdd-json-to-tsv.sh < pdd.json > todos-in-code.tsv
7269

7370
# @todo #1610 Close an issue or post a comment when a puzzle got removed from code
7471
# @todo #1610 Post a comment when issue got closed without removing a puzzle
7572
- name: Check whether there are new todos
7673
run: |
7774
PUZZLES_FILES_MODIFIED=no
7875
79-
if [ ! -f generated-todos/pdd.xml ]; then
80-
echo 'pdd.xml has just been created'
81-
mv pdd.xml generated-todos/pdd.xml
76+
if [ ! -f generated-todos/pdd.json ]; then
77+
echo 'pdd.json has just been created'
78+
mv pdd.json generated-todos/pdd.json
8279
PUZZLES_FILES_MODIFIED=yes
83-
elif ! diff --brief generated-todos/pdd.xml pdd.xml >/dev/null; then
84-
echo 'pdd.xml has been modified'
85-
mv pdd.xml generated-todos/pdd.xml
80+
elif ! diff --brief generated-todos/pdd.json pdd.json >/dev/null; then
81+
echo 'pdd.json has been modified'
82+
mv pdd.json generated-todos/pdd.json
8683
PUZZLES_FILES_MODIFIED=yes
8784
fi
8885
@@ -97,10 +94,11 @@ jobs:
9794
fi
9895
9996
if [ "$PUZZLES_FILES_MODIFIED" = 'yes' ]; then
100-
printf 'pdd.xml: %d puzzles\n' "$(grep -c '<puzzle>' generated-todos/pdd.xml)"
97+
printf 'pdd.json: %d puzzles\n' "$(grep -c '<puzzle>' generated-todos/pdd.json)"
98+
printf 'pdd.json: %d puzzles\n' "$(jq '.puzzles | length' generated-todos/pdd.json)"
10199
printf 'todos-in-code.tsv: %d todos\n' "$(sed 1d generated-todos/todos-in-code.tsv | wc -l)"
102100
else
103-
echo 'neither pdd.xml nor todos-in-code.tsv have been modified'
101+
echo 'neither pdd.json nor todos-in-code.tsv have been modified'
104102
fi
105103
106104
# Make variable available for the next steps
@@ -168,7 +166,7 @@ jobs:
168166
NEW_COMMIT_MSG: "chore: processed ${{ env.COMMIT_MSG }}"
169167
working-directory: generated-todos
170168
run: |
171-
git commit pdd.xml todos-in-code.tsv -m "$NEW_COMMIT_MSG"
169+
git commit pdd.json todos-in-code.tsv -m "$NEW_COMMIT_MSG"
172170
git push
173171
174172
- name: Commit updated mapping
@@ -184,6 +182,6 @@ jobs:
184182
- name: Cleanup
185183
if: always()
186184
run: |
187-
[ ! -f pdd.xml ] || rm -fv pdd.xml
185+
[ ! -f pdd.json ] || rm -fv pdd.json
188186
[ ! -f todos-in-code.tsv ] || rm -fv todos-in-code.tsv
189187
[ ! -d generated-todos ] || git worktree remove generated-todos

src/main/scripts/ci/pdd-xml-to-json.sh

-42
This file was deleted.

0 commit comments

Comments
 (0)