static_checks.yml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. name: 📊 Static Checks
  2. on:
  3. workflow_call:
  4. concurrency:
  5. group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-static
  6. cancel-in-progress: true
  7. jobs:
  8. static-checks:
  9. name: Code style, file formatting, and docs
  10. runs-on: ubuntu-22.04
  11. steps:
  12. - name: Checkout
  13. uses: actions/checkout@v4
  14. with:
  15. fetch-depth: 2
  16. - name: Install APT dependencies
  17. uses: awalsh128/cache-apt-pkgs-action@latest
  18. with:
  19. packages: dos2unix libxml2-utils moreutils
  20. - name: Install Python dependencies and general setup
  21. run: |
  22. pip3 install black==23.3.0 pytest==7.1.2 mypy==0.971
  23. git config diff.wsErrorHighlight all
  24. - name: Get changed files
  25. id: changed-files
  26. env:
  27. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  28. run: |
  29. if [ "${{ github.event_name }}" == "pull_request" ]; then
  30. files=$(git diff-tree --no-commit-id --name-only -r HEAD^1..HEAD 2> /dev/null || true)
  31. elif [ "${{ github.event_name }}" == "push" -a "${{ github.event.forced }}" == "false" -a "${{ github.event.created }}" == "false" ]; then
  32. files=$(git diff-tree --no-commit-id --name-only -r ${{ github.event.before }}..${{ github.event.after }} 2> /dev/null || true)
  33. fi
  34. echo "$files" >> changed.txt
  35. cat changed.txt
  36. files=$(echo "$files" | grep -v 'thirdparty' | xargs -I {} sh -c 'echo "./{}"' | tr '\n' ' ')
  37. echo "CHANGED_FILES=$files" >> $GITHUB_ENV
  38. - name: File formatting checks (file_format.sh)
  39. run: |
  40. bash ./misc/scripts/file_format.sh changed.txt
  41. - name: Header guards formatting checks (header_guards.sh)
  42. run: |
  43. bash ./misc/scripts/header_guards.sh changed.txt
  44. - name: Python style checks via black (black_format.sh)
  45. run: |
  46. if grep -qE '\.py$|SConstruct|SCsub' changed.txt || [ -z "$(cat changed.txt)" ]; then
  47. bash ./misc/scripts/black_format.sh
  48. else
  49. echo "Skipping Python formatting as no Python files were changed."
  50. fi
  51. - name: Python scripts static analysis (mypy_check.sh)
  52. run: |
  53. if grep -qE '\.py$|SConstruct|SCsub' changed.txt || [ -z "$(cat changed.txt)" ]; then
  54. bash ./misc/scripts/mypy_check.sh
  55. else
  56. echo "Skipping Python static analysis as no Python files were changed."
  57. fi
  58. - name: Python builders checks via pytest (pytest_builders.sh)
  59. run: |
  60. bash ./misc/scripts/pytest_builders.sh
  61. - name: JavaScript style and documentation checks via ESLint and JSDoc
  62. run: |
  63. if grep -q "platform/web" changed.txt || [ -z "$(cat changed.txt)" ]; then
  64. cd platform/web
  65. npm ci
  66. npm run lint
  67. npm run docs -- -d dry-run
  68. else
  69. echo "Skipping JavaScript formatting as no Web/JS files were changed."
  70. fi
  71. - name: Class reference schema checks
  72. run: |
  73. xmllint --noout --schema doc/class.xsd doc/classes/*.xml modules/*/doc_classes/*.xml platform/*/doc_classes/*.xml
  74. - name: Documentation checks
  75. run: |
  76. doc/tools/make_rst.py --dry-run --color doc/classes modules platform
  77. - name: Style checks via clang-format (clang_format.sh)
  78. run: |
  79. clang-format --version
  80. bash ./misc/scripts/clang_format.sh changed.txt
  81. - name: Style checks via dotnet format (dotnet_format.sh)
  82. run: |
  83. if grep -q "modules/mono" changed.txt || [ -z "$(cat changed.txt)" ]; then
  84. bash ./misc/scripts/dotnet_format.sh
  85. else
  86. echo "Skipping dotnet format as no C# files were changed."
  87. fi
  88. - name: Spell checks via codespell
  89. if: github.event_name == 'pull_request' && env.CHANGED_FILES != ''
  90. uses: codespell-project/actions-codespell@v2
  91. with:
  92. skip: "./bin,./thirdparty,*.desktop,*.gen.*,*.po,*.pot,*.rc,./AUTHORS.md,./COPYRIGHT.txt,./DONORS.md,./core/input/gamecontrollerdb.txt,./core/string/locales.h,./editor/project_converter_3_to_4.cpp,./misc/scripts/codespell.sh,./platform/android/java/lib/src/com,./platform/web/node_modules,./platform/web/package-lock.json"
  93. ignore_words_list: "breaked,checkin,curvelinear,doubleclick,expct,findn,gird,hel,inout,labelin,lod,mis,nd,numer,ot,pointin,requestor,te,textin,thirdparty,vai"
  94. path: ${{ env.CHANGED_FILES }}