lint_and_submodule_check.yml 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. name: 'Lint sources & check submodule integrity'
  2. on:
  3. push:
  4. branches:
  5. - dev
  6. - "release*"
  7. tags:
  8. - '*'
  9. pull_request:
  10. env:
  11. TARGETS: f7
  12. FBT_TOOLCHAIN_PATH: /runner/_work
  13. SET_GH_OUTPUT: 1
  14. jobs:
  15. lint_sources_check_submodules:
  16. runs-on: [self-hosted,FlipperZeroShell]
  17. steps:
  18. - name: 'Wipe workspace'
  19. run: find ./ -mount -maxdepth 1 -exec rm -rf {} \;
  20. - name: 'Checkout code'
  21. uses: actions/checkout@v3
  22. with:
  23. fetch-depth: 1
  24. ref: ${{ github.event.pull_request.head.sha }}
  25. - name: 'Check protobuf branch'
  26. run: |
  27. git submodule update --init
  28. SUB_PATH="assets/protobuf";
  29. SUB_BRANCH="dev";
  30. SUB_COMMITS_MIN=40;
  31. cd "$SUB_PATH";
  32. SUBMODULE_HASH="$(git rev-parse HEAD)";
  33. BRANCHES=$(git branch -r --contains "$SUBMODULE_HASH");
  34. COMMITS_IN_BRANCH="$(git rev-list --count dev)";
  35. if [ $COMMITS_IN_BRANCH -lt $SUB_COMMITS_MIN ]; then
  36. echo "name=fails::error" >> $GITHUB_OUTPUT;
  37. echo "::error::Error: Too low commits in $SUB_BRANCH of submodule $SUB_PATH: $COMMITS_IN_BRANCH(expected $SUB_COMMITS_MIN+)";
  38. exit 1;
  39. fi
  40. if ! grep -q "/$SUB_BRANCH" <<< "$BRANCHES"; then
  41. echo "name=fails::error" >> $GITHUB_OUTPUT;
  42. echo "::error::Error: Submodule $SUB_PATH is not on branch $SUB_BRANCH";
  43. exit 1;
  44. fi
  45. - name: 'Check Python code formatting'
  46. id: syntax_check_py
  47. run: ./fbt lint_py 2>&1 >/dev/null || echo "errors=1" >> $GITHUB_OUTPUT
  48. - name: 'Check C++ code formatting'
  49. if: always()
  50. id: syntax_check_cpp
  51. run: ./fbt lint 2>&1 >/dev/null || echo "errors=1" >> $GITHUB_OUTPUT
  52. - name: Report code formatting errors
  53. if: ( steps.syntax_check_py.outputs.errors || steps.syntax_check_cpp.outputs.errors ) && github.event.pull_request
  54. run: |
  55. echo "Code formatting errors found";
  56. echo "Please run './fbt format' or './fbt format_py' to fix them";
  57. exit 1;