lint_and_submodule_check.yml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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: 'Decontaminate previous build leftovers'
  19. run: |
  20. if [ -d .git ]; then
  21. git submodule status || git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
  22. fi
  23. - name: 'Checkout code'
  24. uses: actions/checkout@v3
  25. with:
  26. fetch-depth: 1
  27. ref: ${{ github.event.pull_request.head.sha }}
  28. - name: 'Check protobuf branch'
  29. run: |
  30. git submodule update --init
  31. SUB_PATH="assets/protobuf";
  32. SUB_BRANCH="dev";
  33. SUB_COMMITS_MIN=40;
  34. cd "$SUB_PATH";
  35. SUBMODULE_HASH="$(git rev-parse HEAD)";
  36. BRANCHES=$(git branch -r --contains "$SUBMODULE_HASH");
  37. COMMITS_IN_BRANCH="$(git rev-list --count dev)";
  38. if [ $COMMITS_IN_BRANCH -lt $SUB_COMMITS_MIN ]; then
  39. echo "name=fails::error" >> $GITHUB_OUTPUT;
  40. echo "::error::Error: Too low commits in $SUB_BRANCH of submodule $SUB_PATH: $COMMITS_IN_BRANCH(expected $SUB_COMMITS_MIN+)";
  41. exit 1;
  42. fi
  43. if ! grep -q "/$SUB_BRANCH" <<< "$BRANCHES"; then
  44. echo "name=fails::error" >> $GITHUB_OUTPUT;
  45. echo "::error::Error: Submodule $SUB_PATH is not on branch $SUB_BRANCH";
  46. exit 1;
  47. fi
  48. - name: 'Check Python code formatting'
  49. id: syntax_check_py
  50. run: ./fbt lint_py 2>&1 >/dev/null || echo "errors=1" >> $GITHUB_OUTPUT
  51. - name: 'Check C++ code formatting'
  52. if: always()
  53. id: syntax_check_cpp
  54. run: ./fbt lint 2>&1 >/dev/null || echo "errors=1" >> $GITHUB_OUTPUT
  55. - name: Report code formatting errors
  56. if: ( steps.syntax_check_py.outputs.errors || steps.syntax_check_cpp.outputs.errors ) && github.event.pull_request
  57. run: |
  58. echo "Code formatting errors found";
  59. echo "Please run './fbt format' or './fbt format_py' to fix them";
  60. exit 1;