Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bazel,ci: check generated code and docs are up-to-date in CI #89516

Merged
merged 1 commit into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions build/bazelutil/checked_in_genfiles.txt

This file was deleted.

3 changes: 1 addition & 2 deletions build/teamcity/cockroach/ci/builds/build_impl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ EXTRA_TARGETS=
if [ "$CONFIG" == "crosslinux" ]
then
DOC_TARGETS=$(grep '^//' docs/generated/bazel_targets.txt)
GO_TARGETS=$(grep -v '^#' build/bazelutil/checked_in_genfiles.txt | cut -d'|' -f1)
BINARY_TARGETS="@com_github_cockroachdb_go_test_teamcity//:go-test-teamcity //pkg/cmd/dev //pkg/cmd/workload"
EXTRA_TARGETS="$DOC_TARGETS $GO_TARGETS $BINARY_TARGETS"
EXTRA_TARGETS="$DOC_TARGETS $BINARY_TARGETS"
fi

# Extra targets to build on Unix only.
Expand Down
18 changes: 1 addition & 17 deletions build/teamcity/cockroach/ci/builds/build_linux_x86_64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,7 @@ do
FAILED=1
fi
done
# Ensure checked-in generated files are byte-for-byte identical with what's in
# the checkout.
for LINE in $(grep -v '^#' $root/build/bazelutil/checked_in_genfiles.txt)
do
target=$(echo $LINE | cut -d'|' -f1)
dir=$(echo $target | sed 's|//||g' | cut -d: -f1)
old_basename=$(echo $LINE | cut -d'|' -f2)
new_basename=$(echo $LINE | cut -d'|' -f3)
RESULT=$(diff $root/artifacts/bazel-bin/$dir/$old_basename $root/$dir/$new_basename)
if [[ ! $? -eq 0 ]]
then
echo "Generated file $dir/$new_basename does not match with checked-in version. Got diff:"
echo "$RESULT"
echo "Run './dev generate go'"
FAILED=1
fi
done

# docs/generated/redact_safe.md needs special handling.
REAL_REDACT_SAFE=$($root/build/bazelutil/generate_redact_safe.sh)
RESULT=$(diff <(echo "$REAL_REDACT_SAFE") $root/docs/generated/redact_safe.md)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@ if grep TODO DEPS.bzl; then
fi
check_workspace_clean 'dev_generate_bazel' "Run \`./dev generate bazel\` to automatically regenerate these."

# Run `bazel run //pkg/gen` and ensure nothing changes. This ensures
# generated documentation and checked-in go code are up to date.
bazel run //pkg/gen
check_workspace_clean 'dev_generate' "Run \`./dev generate\` to automatically regenerate these."
# Run go mod tidy and ensure nothing changes.
# NB: If files are missing from any packages then `go mod tidy` will
# fail. So we need to make sure that `.pb.go` sources are populated.
bazel run //pkg/gen:go_proto
# This is part of what //pkg/gen does, in addition to generating Go code and
# docs.
bazel run @go_sdk//:bin/go --ui_event_filters=-DEBUG,-info,-stdout,-stderr --noshow_progress mod tidy
check_workspace_clean 'go_mod_tidy' "Run \`go mod tidy\` to automatically regenerate these."

Expand Down