Skip to content

Commit 72ad3d1

Browse files
Arm backend: Check generated documentation edits before pushing (pytorch#23049)
Run docgen when a commit changes generated documentation. Rebuild the pages from their templates and compare them with the committed versions. This catches edits made only to generated pages in the original patch, before they cause failures for later changes. Include deleted files in the trigger check and reject untracked outputs recreated by docgen, since git diff does not report them. Signed-off-by: Sebastian Larsson <sebastian.larsson@arm.com>
1 parent c2e8d64 commit 72ad3d1

1 file changed

Lines changed: 22 additions & 6 deletions

File tree

‎backends/arm/scripts/pre-push‎

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ RUN_DOCGEN=0
4141

4242
is_docgen_trigger_file() {
4343
local file_path="$1"
44+
local output_path
45+
for output_path in "${DOCGEN_OUTPUTS[@]}"; do
46+
if [[ "$file_path" == "$output_path" ]]; then
47+
return 0
48+
fi
49+
done
50+
4451
case "${file_path}" in
4552
backends/arm/common/arm_compile_spec.py|\
4653
backends/arm/ethosu/*.py|\
@@ -57,21 +64,30 @@ is_docgen_trigger_file() {
5764
}
5865

5966
run_docgen_check() {
60-
local FAILED=0
67+
local docgen_status=0
6168

6269
echo -e "${INFO} Running Arm docgen"
6370
if ! python backends/arm/scripts/docgen/docgen.py; then
6471
echo -e "${ERROR} Failed to run Arm docgen"
65-
FAILED=1
66-
elif ! git diff --quiet HEAD -- "${DOCGEN_OUTPUTS[@]}"; then
72+
return 1
73+
fi
74+
75+
local untracked_outputs
76+
untracked_outputs=$(git ls-files --others -- "${DOCGEN_OUTPUTS[@]}")
77+
if ! git diff --quiet HEAD -- "${DOCGEN_OUTPUTS[@]}" || \
78+
[[ -n "$untracked_outputs" ]]; then
6779
echo -e "${ERROR} Arm docgen updated generated documentation." >&2
6880
echo -e "${INFO} Review and commit the regenerated docs before pushing."
6981
git diff HEAD -- "${DOCGEN_OUTPUTS[@]}"
70-
FAILED=1
82+
if [[ -n "$untracked_outputs" ]]; then
83+
echo -e "${INFO} Untracked generated documentation:"
84+
echo "$untracked_outputs"
85+
fi
86+
docgen_status=1
7187
else
7288
echo -e "${SUCCESS} Arm docgen OK"
7389
fi
74-
return "$FAILED"
90+
return "$docgen_status"
7591
}
7692

7793
run_op_support_checks() {
@@ -190,7 +206,7 @@ for COMMIT in ${COMMITS}; do
190206
fi
191207

192208
commit_files=$(git diff-tree --no-commit-id --name-only \
193-
--diff-filter=ACMR ${COMMIT} -r)
209+
--diff-filter=ACDMR ${COMMIT} -r)
194210
if [[ $RUN_DOCGEN -eq 0 ]]; then
195211
for committed_file in $commit_files; do
196212
if is_docgen_trigger_file "${committed_file}"; then

0 commit comments

Comments
 (0)