Skip to content

Commit 8fc6186

Browse files
committed
WIP
1 parent ec808a7 commit 8fc6186

File tree

1 file changed

+41
-27
lines changed

1 file changed

+41
-27
lines changed

.github/workflows/comment_coverage.yaml

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ on: [pull_request]
44

55
name: Comment Coverage
66

7-
env:
8-
CARGO_TERM_COLOR: always
7+
#env:
8+
# CARGO_TERM_COLOR: always
99

1010
jobs:
1111
check-lint-build-stable:
@@ -34,17 +34,23 @@ jobs:
3434
- name: Missing docs warnings (PR)
3535
id: missing_docs_warnings_pr
3636
run: |
37-
cargo -q clippy --message-format=short -- \
38-
-Aclippy::all \
39-
-Wclippy::missing_errors_doc \
40-
-Wclippy::missing_panics_doc \
41-
-Wclippy::missing_safety_doc \
42-
-Wclippy::missing_docs_in_private_items \
43-
-Wmissing_docs \
44-
2>&1 \
45-
| awk -F"[\` ]" \
46-
'/warning: `.+?` \(lib\) generated [0-9]+ warning[s]?/ { print $3 ": " $7 }' \
47-
| sort
37+
# use a random EOF, as per GitHub security recommendations
38+
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
39+
WARNINGS=$(\
40+
cargo -q clippy --message-format=short -- \
41+
-Aclippy::all \
42+
-Wclippy::missing_errors_doc \
43+
-Wclippy::missing_panics_doc \
44+
-Wclippy::missing_safety_doc \
45+
-Wclippy::missing_docs_in_private_items \
46+
-Wmissing_docs \
47+
2>&1)
48+
echo "$WARNINGS"
49+
AWKSTR='/warning: `.+` \(lib\) generated [0-9]+ warnings?/ { print $3 ": " $7 }'
50+
WARNINGS=$(echo "$WARNINGS" | awk -F"[\` ]" "$AWKSTR" | sort)
51+
echo "PR_WARNINGS<<$EOF" >> "$GITHUB_OUTPUT"
52+
echo "$WARNINGS" >> "$GITHUB_OUTPUT"
53+
echo "$EOF" >> "$GITHUB_OUTPUT"
4854
4955
- name: Checkout target branch
5056
uses: actions/checkout@v2
@@ -54,22 +60,30 @@ jobs:
5460
- name: Missing docs warnings (Target)
5561
id: missing_docs_warnings_target
5662
run: |
57-
cargo -q clippy --message-format=short -- \
58-
-Aclippy::all \
59-
-Wclippy::missing_errors_doc \
60-
-Wclippy::missing_panics_doc \
61-
-Wclippy::missing_safety_doc \
62-
-Wclippy::missing_docs_in_private_items \
63-
-Wmissing_docs \
64-
2>&1 \
65-
| awk -F"[\` ]" \
66-
'/warning: `.+?` \(lib\) generated [0-9]+ warning[s]?/ { print $3 ": " $7 }' \
67-
| sort
63+
# use a random EOF, as per GitHub security recommendations
64+
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
65+
WARNINGS=$(\
66+
cargo -q clippy --message-format=short -- \
67+
-Aclippy::all \
68+
-Wclippy::missing_errors_doc \
69+
-Wclippy::missing_panics_doc \
70+
-Wclippy::missing_safety_doc \
71+
-Wclippy::missing_docs_in_private_items \
72+
-Wmissing_docs \
73+
2>&1)
74+
echo "$WARNINGS"
75+
AWKSTR='/warning: `.+` \(lib\) generated [0-9]+ warnings?/ { print $3 ": " $7 }'
76+
WARNINGS=$(echo "$WARNINGS" | awk -F"[\` ]" "$AWKSTR" | sort)
77+
echo "TARGET_WARNINGS<<$EOF" >> "$GITHUB_OUTPUT"
78+
echo "$WARNINGS" >> "$GITHUB_OUTPUT"
79+
echo "$EOF" >> "$GITHUB_OUTPUT"
6880
6981
- name: Compare comment coverage
7082
run: |
71-
IFS=$'\n' read -rd '' -a missing_docs_warnings_pr_arr <<< "${{steps.missing_docs_warnings_pr.outcome}}"
72-
IFS=$'\n' read -rd '' -a missing_docs_warnings_target_arr <<< "${{steps.missing_docs_warnings_target.outcome}}"
83+
PR_WARNINGS="${{steps.missing_docs_warnings_pr.outputs.PR_WARNINGS}}"
84+
TARGET_WARNINGS="${{ steps.missing_docs_warnings_target.outputs.TARGET_WARNINGS }}"
85+
readarray -t missing_docs_warnings_pr_arr <<< "$PR_WARNINGS"
86+
readarray -t missing_docs_warnings_target_arr <<< "$TARGET_WARNINGS"
7387
for pr_warnings_line in "${missing_docs_warnings_pr_arr[@]}"
7488
do
7589
# Extract the libname and number of warnings from the line
@@ -94,7 +108,7 @@ jobs:
94108
IFS=': ' read -r _ nwarnings_target <<< "$target_warning_line"
95109
96110
# Compare the values
97-
if [ "$nwarnings_target" -ge "$nwarnings_pr" ]
111+
if [ "$nwarnings_target" -gt "$nwarnings_pr" ]
98112
then
99113
echo "Too many warnings for \`${libname}\` (${nwarnings_pr}): must be less than $nwarnings_target"
100114
exit 1

0 commit comments

Comments
 (0)