lint-docs-catalog.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. # Compare dependencies and their flags against a ground truth. This serves against accidentally enabling dependencies
  11. # or feature flags.
  12. #
  13. # Example usages:
  14. #
  15. # $ ci/test/lint-docs-catalog.sh
  16. #
  17. # To rewrite the stored files, pass the --rewrite option.
  18. set -euo pipefail
  19. . misc/shlib/shlib.bash
  20. catalog_files=(
  21. doc/user/content/sql/system-catalog/mz_internal.md
  22. doc/user/content/sql/system-catalog/mz_introspection.md
  23. doc/user/content/sql/system-catalog/mz_catalog.md
  24. )
  25. slt_directory=test/sqllogictest/autogenerated
  26. rewrite=false
  27. if [[ "${1:-}" = --rewrite ]]; then
  28. shift
  29. rewrite=true
  30. ci_uncollapsed_heading "Linting catalog docs; rewriting .slt files"
  31. else
  32. ci_uncollapsed_heading "Linting catalog docs, run $0 --rewrite to update .slt files"
  33. fi
  34. for catalog_file in "${catalog_files[@]}"; do
  35. slt="$slt_directory/$(basename "$catalog_file" .md).slt"
  36. if $rewrite; then
  37. try bin/pyactivate ci/test/lint-docs-catalog.py "$catalog_file" > "$slt"
  38. else
  39. try diff "$slt" <(bin/pyactivate ci/test/lint-docs-catalog.py "$catalog_file")
  40. fi
  41. done
  42. try_status_report