Skip to content

Commit

Permalink
[WIP] ci: check that generated documentation is up-to-date
Browse files Browse the repository at this point in the history
Closes: #137133

Epic: none
Release note: None
  • Loading branch information
rickystewart committed Dec 10, 2024
1 parent 95d95a6 commit cedd44d
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions build/github/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,57 @@ bazel build \
//pkg/cmd/cockroach-short //pkg/cmd/cockroach \
//pkg/cmd/cockroach-sql $GEOS_TARGET $EXTRA_TARGETS

# We don't have to exercise the checks below on every configuration, only
# bother with Linux.
if [ "$CONFIG" != "crosslinux" ]
then
exit 0
fi

BAZEL_BIN=$(bazel info bazel-bin --config "$CONFIG")
FAILED=
# Ensure all generated docs are byte-for-byte identical with the checkout.
for FILE in $(find $BAZEL_BIN/docs -type f)
do
RESULT=$(diff $FILE ${FILE##$BAZEL_BIN/})
if [[ ! $? -eq 0 ]]
then
echo "File $FILE does not match with checked-in version. Got diff:"
echo "$RESULT"
echo "Run './dev generate docs'"
FAILED=1
fi
done
# Ensure the generated docs are inclusive of what we have in tree: list all
# generated files in a few subdirectories and make sure they're all in the
# build output.
for FILE in $(ls docs/generated/http/*.md | xargs -n1 basename)
do
if [[ ! -f $BAZEL_BIN/docs/generated/http/$FILE ]]
then
echo "File $BAZEL_BIN/docs/generated/http/$FILE does not exist as a generated artifact. Is docs/generated/http/BUILD.bazel up-to-date?"
FAILED=1
fi
done
for FILE in $(ls docs/generated/sql/*.md | xargs -n1 basename)
do
if [[ ! -f $BAZEL_BIN/docs/generated/sql/$FILE ]]
then
echo "File $BAZEL_BIN/docs/generated/sql/$FILE does not exist as a generated artifact. Is docs/generated/sql/BUILD.bazel up-to-date?"
FAILED=1
fi
done
for FILE in $(ls docs/generated/sql/bnf/*.bnf | xargs -n1 basename)
do
if [[ ! -f $BAZEL_BIN/docs/generated/sql/bnf/$FILE ]]
then
echo "File $BAZEL_BIN/docs/generated/sql/bnf/$FILE does not exist as a generated artifact. Is docs/generated/sql/bnf/BUILD.bazel up-to-date?"
FAILED=1
fi
done

if [[ ! -z "$FAILED" ]]
then
echo 'Generated files do not match! Are the checked-in generated files up-to-date?'
exit 1
fi

0 comments on commit cedd44d

Please sign in to comment.