lint-ci.sh 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/usr/bin/env bash
  2. set -e
  3. script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
  4. cd "${script_path}/.." || exit 1
  5. ports=true
  6. if [ "$1" == "--no-ports" ]; then
  7. ports=false
  8. shift
  9. fi
  10. RED='\033[0;31m'
  11. GREEN='\033[0;32m'
  12. NC='\033[0m' # No Color
  13. FAILURES=0
  14. set +e
  15. for cmd in \
  16. Meta/check-ak-test-files.sh \
  17. Meta/check-debug-flags.sh \
  18. Meta/check-markdown.sh \
  19. Meta/check-newlines-at-eof.py \
  20. Meta/check-style.py \
  21. Meta/lint-executable-resources.sh \
  22. Meta/lint-keymaps.py \
  23. Meta/lint-shell-scripts.sh \
  24. Meta/lint-prettier.sh \
  25. Meta/lint-python.sh; do
  26. echo "Running ${cmd}... "
  27. if "${cmd}" "$@"; then
  28. echo -e "[${GREEN}OK${NC}]: ${cmd}"
  29. else
  30. echo -e "[${RED}FAIL${NC}]: ${cmd}"
  31. ((FAILURES+=1))
  32. fi
  33. done
  34. if [ -x ./Build/lagom/Tools/IPCMagicLinter/IPCMagicLinter ]; then
  35. if git ls-files '*.ipc' | xargs ./Build/lagom/Tools/IPCMagicLinter/IPCMagicLinter; then
  36. echo -e "[${GREEN}OK${NC}]: IPCMagicLinter (in Meta/lint-ci.sh)"
  37. else
  38. echo -e "[${RED}FAIL${NC}]: IPCMagicLinter (in Meta/lint-ci.sh)"
  39. ((FAILURES+=1))
  40. fi
  41. else
  42. echo -e "[${GREEN}SKIP${NC}]: IPCMagicLinter (in Meta/lint-ci.sh)"
  43. fi
  44. echo "Running Meta/lint-clang-format.sh"
  45. if Meta/lint-clang-format.sh --overwrite-inplace "$@" && git diff --exit-code; then
  46. echo -e "[${GREEN}OK${NC}]: Meta/lint-clang-format.sh"
  47. else
  48. echo -e "[${RED}FAIL${NC}]: Meta/lint-clang-format.sh"
  49. ((FAILURES+=1))
  50. fi
  51. # lint-ports.py is handled separately as it scans all Ports/ all the time.
  52. # This is fine when running lint-ci.sh from the PR validation workflow.
  53. # However when running from the pre-commit workflow it takes an excessive
  54. # amount of time. This condition allows the pre-commit program to detect
  55. # when Ports/ files have changed and only invoke lint-ports.py when needed.
  56. #
  57. if [ "$ports" = true ]; then
  58. if Meta/lint-ports.py; then
  59. echo -e "[${GREEN}OK${NC}]: Meta/lint-ports.py"
  60. else
  61. echo -e "[${RED}FAIL${NC}]: Meta/lint-ports.py"
  62. ((FAILURES+=1))
  63. fi
  64. fi
  65. echo "(Not running lint-missing-resources.sh due to high false-positive rate.)"
  66. echo "(Also look out for check-symbols.sh, which can only be executed after the build!)"
  67. exit "${FAILURES}"