diff --git a/build/teamcity-check-genfiles.sh b/build/teamcity-check-genfiles.sh index 34e7a63776b0..d0e53bd1a0d6 100755 --- a/build/teamcity-check-genfiles.sh +++ b/build/teamcity-check-genfiles.sh @@ -9,6 +9,8 @@ tc_prepare tc_start_block "Ensure generated code is up-to-date" +begin_check_generated_code_tests + # NOTE(ricky): Please make sure any changes to the Bazel-related checks here are # propagated to build/teamcity/cockroach/ci/tests/check_generated_code_impl.sh # as well. @@ -29,24 +31,26 @@ if grep TODO DEPS.bzl; then echo "Missing TODO comment in DEPS.bzl. Did you run \`./dev generate bazel --mirror\`?" exit 1 fi -check_workspace_clean "Run \`./dev generate bazel\` to automatically regenerate these." +check_workspace_clean 'dev_generate_bazel' "Run \`./dev generate bazel\` to automatically regenerate these." run build/builder.sh make generate &> artifacts/generate.log || (cat artifacts/generate.log && false) rm artifacts/generate.log -check_workspace_clean "Run \`make generate\` to automatically regenerate these." +check_workspace_clean 'make_generate' "Run \`make generate\` to automatically regenerate these." run build/builder.sh make buildshort &> artifacts/buildshort.log || (cat artifacts/buildshort.log && false) rm artifacts/buildshort.log -check_workspace_clean "Run \`make buildshort\` to automatically regenerate these." +check_workspace_clean 'make_buildshort' "Run \`make buildshort\` to automatically regenerate these." tc_end_block "Ensure generated code is up-to-date" # generated code can generate new dependencies; check dependencies after generated code. tc_start_block "Ensure dependencies are up-to-date" # Run go mod tidy and `make -k vendor_rebuild` and ensure nothing changes. run build/builder.sh go mod tidy -check_workspace_clean "Run \`go mod tidy\` and \`make -k vendor_rebuild\` to automatically regenerate these." +check_workspace_clean 'go_mod_tidy' "Run \`go mod tidy\` and \`make -k vendor_rebuild\` to automatically regenerate these." run build/builder.sh make -k vendor_rebuild cd vendor -check_workspace_clean "Run \`make -k vendor_rebuild\` to automatically regenerate these." +check_workspace_clean 'vendor_rebuild' "Run \`make -k vendor_rebuild\` to automatically regenerate these." cd .. + +end_check_generated_code_tests tc_end_block "Ensure dependencies are up-to-date" tc_start_block "Test web UI" diff --git a/build/teamcity-support.sh b/build/teamcity-support.sh index 70b0afa0317a..1638c7ac46eb 100755 --- a/build/teamcity-support.sh +++ b/build/teamcity-support.sh @@ -307,9 +307,18 @@ generate_ssh_key() { fi } -# Call this function with one argument, the error message to print if the -# workspace is dirty. +begin_check_generated_code_tests() { + echo "##teamcity[testSuiteStarted name='CheckGeneratedCode']" +} + +end_check_generated_code_tests() { + echo "##teamcity[testSuiteFinished name='CheckGeneratedCode']" +} + +# Call this function with two arguments: the name of the "test" that will be +# reported to teamcity and the error message to print if the workspace is dirty. check_workspace_clean() { + echo "##teamcity[testStarted name='CheckGeneratedCode/$1' captureStandardOutput='true']" # The workspace is clean iff `git status --porcelain` produces no output. Any # output is either an error message or a listing of an untracked/dirty file. if [[ "$(git status --porcelain 2>&1)" != "" ]]; then @@ -317,7 +326,10 @@ check_workspace_clean() { git diff -a >&2 || true echo "====================================================" >&2 echo "Some automatically generated code is not up to date." >&2 - echo $1 >&2 + echo $2 >&2 + echo "##teamcity[testFailed name='CheckGeneratedCode/$1']" + echo "##teamcity[testFinished name='CheckGeneratedCode/$1']" exit 1 fi + echo "##teamcity[testFinished name='CheckGeneratedCode/$1']" } diff --git a/build/teamcity/cockroach/ci/tests/check_generated_code_impl.sh b/build/teamcity/cockroach/ci/tests/check_generated_code_impl.sh index ed7e27822aa1..9aa5593d64ee 100755 --- a/build/teamcity/cockroach/ci/tests/check_generated_code_impl.sh +++ b/build/teamcity/cockroach/ci/tests/check_generated_code_impl.sh @@ -8,6 +8,8 @@ source "$dir/teamcity-support.sh" # For $root, check_workspace_clean mkdir -p artifacts +begin_check_generated_code_tests + # Buffer noisy output and only print it on failure. if ! (./build/bazelutil/check.sh &> artifacts/buildshort.log || (cat artifacts/buildshort.log && false)); then # The command will output instructions on how to fix the error. @@ -24,11 +26,13 @@ if grep TODO DEPS.bzl; then echo "Missing TODO comment in DEPS.bzl. Did you run \`./dev generate bazel --mirror\`?" exit 1 fi -check_workspace_clean "Run \`./dev generate bazel\` to automatically regenerate these." +check_workspace_clean 'dev_generate_bazel' "Run \`./dev generate bazel\` 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 bazel run @go_sdk//:bin/go --ui_event_filters=-DEBUG,-info,-stdout,-stderr --noshow_progress mod tidy -check_workspace_clean "Run \`go mod tidy\` to automatically regenerate these." +check_workspace_clean 'go_mod_tidy' "Run \`go mod tidy\` to automatically regenerate these." + +end_check_generated_code_tests