lint_and_submodule_check.yml 2.3 KB

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