amap_analyse.yml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. name: 'Analyze .map file with Amap'
  2. on:
  3. push:
  4. branches:
  5. - dev
  6. - "release*"
  7. tags:
  8. - '*'
  9. pull_request:
  10. env:
  11. TARGETS: f7
  12. jobs:
  13. amap_analyse:
  14. if: ${{ !github.event.pull_request.head.repo.fork }}
  15. runs-on: [self-hosted,FlipperZeroMacShell]
  16. timeout-minutes: 15
  17. steps:
  18. - name: 'Wait Build workflow'
  19. uses: fountainhead/action-wait-for-check@v1.0.0
  20. id: wait-for-build
  21. with:
  22. token: ${{ secrets.GITHUB_TOKEN }}
  23. checkName: 'main'
  24. ref: ${{ github.event.pull_request.head.sha || github.sha }}
  25. intervalSeconds: 20
  26. - name: 'Check Build workflow status'
  27. if: steps.wait-for-build.outputs.conclusion == 'failure'
  28. run: |
  29. exit 1
  30. - name: 'Decontaminate previous build leftovers'
  31. run: |
  32. if [ -d .git ]; then
  33. git submodule status || git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
  34. fi
  35. - name: 'Checkout code'
  36. uses: actions/checkout@v2
  37. with:
  38. fetch-depth: 0
  39. ref: ${{ github.event.pull_request.head.sha }}
  40. - name: 'Get commit details'
  41. run: |
  42. if [[ ${{ github.event_name }} == 'pull_request' ]]; then
  43. TYPE="pull"
  44. elif [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
  45. TYPE="tag"
  46. else
  47. TYPE="other"
  48. fi
  49. python3 scripts/get_env.py "--event_file=${{ github.event_path }}" "--type=$TYPE"
  50. - name: 'Make artifacts directory'
  51. run: |
  52. rm -rf artifacts
  53. mkdir artifacts
  54. - name: 'Download build artifacts'
  55. run: |
  56. echo "${{ secrets.RSYNC_DEPLOY_KEY }}" > deploy_key;
  57. chmod 600 ./deploy_key;
  58. rsync -avzP \
  59. -e 'ssh -p ${{ secrets.RSYNC_DEPLOY_PORT }} -i ./deploy_key' \
  60. ${{ secrets.RSYNC_DEPLOY_USER }}@${{ secrets.RSYNC_DEPLOY_HOST }}:"${{ secrets.RSYNC_DEPLOY_BASE_PATH }}${BRANCH_NAME}/" artifacts/;
  61. rm ./deploy_key;
  62. - name: 'Make .map file analyze'
  63. run: |
  64. cd artifacts/
  65. /Applications/amap/Contents/MacOS/amap -f "flipper-z-f7-firmware-${SUFFIX}.elf.map"
  66. - name: 'Upload report to DB'
  67. run: |
  68. FBT_TOOLCHAIN_PATH=/opt source scripts/toolchain/fbtenv.sh
  69. get_size()
  70. {
  71. SECTION="$1";
  72. arm-none-eabi-size \
  73. -A artifacts/flipper-z-f7-firmware-$SUFFIX.elf \
  74. | grep "^$SECTION" | awk '{print $2}'
  75. }
  76. export BSS_SIZE="$(get_size ".bss")"
  77. export TEXT_SIZE="$(get_size ".text")"
  78. export RODATA_SIZE="$(get_size ".rodata")"
  79. export DATA_SIZE="$(get_size ".data")"
  80. export FREE_FLASH_SIZE="$(get_size ".free_flash")"
  81. python3 -m pip install mariadb
  82. python3 scripts/amap_mariadb_insert.py \
  83. ${{ secrets.AMAP_MARIADB_USER }} \
  84. ${{ secrets.AMAP_MARIADB_PASSWORD }} \
  85. ${{ secrets.AMAP_MARIADB_HOST }} \
  86. ${{ secrets.AMAP_MARIADB_PORT }} \
  87. ${{ secrets.AMAP_MARIADB_DATABASE }} \
  88. artifacts/flipper-z-f7-firmware-$SUFFIX.elf.map.all