Skip to content

Commit 647ac96

Browse files
adrienthebothefirstofthe300
authored andcommitted
Add a check_generate_docs target
Currently we have no automatic way of determining if a given commit or pull request has stale documentation; this leads to buildups in changes that tend to tag along with other fixes. This commit resolves the issue by adding a check that verifies that a fresh copy of the repository does not have a diff present after docs generation.
1 parent ff61512 commit 647ac96

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ DOCKER_TAG_KITCHEN_TERRAFORM ?= ${DOCKER_TAG_BASE_KITCHEN_TERRAFORM}
2424
DOCKER_IMAGE_KITCHEN_TERRAFORM := cft/kitchen-terraform_terraform-google-kubernetes-engine
2525

2626
# All is the first target in the file so it will get picked up when you just run 'make' on its own
27-
all: check_shell check_python check_golang check_terraform check_docker check_base_files test_check_headers check_headers check_trailing_whitespace generate_docs
27+
.PHONY: all
28+
all: check generate_docs
29+
30+
.PHONY: check
31+
check: check_shell check_python check_golang check_terraform check_docker check_base_files test_check_headers check_headers check_trailing_whitespace check_generate_docs
2832

2933
# The .PHONY directive tells make that this isn't a real target and so
3034
# the presence of a file named 'check_shell' won't cause this target to stop
@@ -71,6 +75,10 @@ check_headers:
7175
@echo "Checking file headers"
7276
@python test/verify_boilerplate.py
7377

78+
.PHONY: check_generate_docs
79+
check_generate_docs: ## Check that `make generate_docs` does not generate a diff
80+
@source test/make.sh && check_generate_docs
81+
7482
# Integration tests
7583
.PHONY: test_integration
7684
test_integration:

test/make.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,22 @@ function generate_docs() {
9696
done
9797
rm -f "$TMPFILE"
9898
}
99+
100+
function check_generate_docs() {
101+
TMPDIR=$(mktemp -d)
102+
git worktree add --detach "$TMPDIR"
103+
cd "$TMPDIR" || exit 1
104+
105+
make generate_docs
106+
git diff --stat --exit-code
107+
rc=$?
108+
cd - || exit 1
109+
110+
if [[ $rc -ne 0 ]]; then
111+
echo '"make generate_docs" creates a diff, run "make generate_docs" and commit the results'
112+
fi
113+
rm -rf "$TMPDIR"
114+
git worktree prune
115+
116+
exit $rc
117+
}

0 commit comments

Comments
 (0)