amap_analyse.yml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. mkdir -p ~/.ssh
  57. ssh-keyscan -p ${{ secrets.RSYNC_DEPLOY_PORT }} -H ${{ secrets.RSYNC_DEPLOY_HOST }} > ~/.ssh/known_hosts
  58. echo "${{ secrets.RSYNC_DEPLOY_KEY }}" > deploy_key;
  59. chmod 600 ./deploy_key;
  60. rsync -avzP \
  61. -e 'ssh -p ${{ secrets.RSYNC_DEPLOY_PORT }} -i ./deploy_key' \
  62. ${{ secrets.RSYNC_DEPLOY_USER }}@${{ secrets.RSYNC_DEPLOY_HOST }}:"${{ secrets.RSYNC_DEPLOY_BASE_PATH }}${BRANCH_NAME}/" artifacts/;
  63. rm ./deploy_key;
  64. - name: 'Make .map file analyze'
  65. run: |
  66. cd artifacts/
  67. /Applications/amap/Contents/MacOS/amap -f "flipper-z-f7-firmware-${SUFFIX}.elf.map"
  68. - name: 'Upload report to DB'
  69. run: |
  70. FBT_TOOLCHAIN_PATH=/opt source scripts/toolchain/fbtenv.sh
  71. get_size()
  72. {
  73. SECTION="$1";
  74. arm-none-eabi-size \
  75. -A artifacts/flipper-z-f7-firmware-$SUFFIX.elf \
  76. | grep "^$SECTION" | awk '{print $2}'
  77. }
  78. export BSS_SIZE="$(get_size ".bss")"
  79. export TEXT_SIZE="$(get_size ".text")"
  80. export RODATA_SIZE="$(get_size ".rodata")"
  81. export DATA_SIZE="$(get_size ".data")"
  82. export FREE_FLASH_SIZE="$(get_size ".free_flash")"
  83. python3 -m pip install mariadb
  84. python3 scripts/amap_mariadb_insert.py \
  85. ${{ secrets.AMAP_MARIADB_USER }} \
  86. ${{ secrets.AMAP_MARIADB_PASSWORD }} \
  87. ${{ secrets.AMAP_MARIADB_HOST }} \
  88. ${{ secrets.AMAP_MARIADB_PORT }} \
  89. ${{ secrets.AMAP_MARIADB_DATABASE }} \
  90. artifacts/flipper-z-f7-firmware-$SUFFIX.elf.map.all