check-bazel.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env bash
  2. # Copyright Materialize, Inc. and contributors. All rights reserved.
  3. #
  4. # Use of this software is governed by the Business Source License
  5. # included in the LICENSE file at the root of this repository.
  6. #
  7. # As of the Change Date specified in that file, in accordance with
  8. # the Business Source License, use of this software will be governed
  9. # by the Apache License, Version 2.0.
  10. #
  11. # check-bazel.sh — check for Bazel issues (e.g., ensure all of our generated files are up to date).
  12. set -euo pipefail
  13. cd "$(dirname "$0")/../../../.."
  14. . misc/shlib/shlib.bash
  15. if [[ ! "${MZDEV_NO_BAZEL_CHECK:-}" ]]; then
  16. if try bin/bazel gen; then
  17. :
  18. else
  19. if [ $? -eq 32 ]; then
  20. # Network problems, retry in a bit
  21. sleep 20
  22. try bin/bazel gen
  23. fi
  24. fi
  25. # Make sure we didn't generate any changes.
  26. try git diff --compact-summary --exit-code -- '*/BUILD.bazel'
  27. if try_last_failed; then
  28. echo "lint: $(red error:) discrepancies found in generated 'BUILD.bazel' files"
  29. echo "lint: $(green hint:) run $(white bin/bazel gen)" >&2
  30. fi
  31. fi
  32. try_status_report