amap_analyse.yml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. runs-on: [self-hosted,FlipperZeroMacShell]
  15. timeout-minutes: 15
  16. steps:
  17. - name: 'Wait Build workflow'
  18. uses: fountainhead/action-wait-for-check@v1.0.0
  19. id: wait-for-build
  20. with:
  21. token: ${{ secrets.GITHUB_TOKEN }}
  22. checkName: 'main'
  23. ref: ${{ github.event.pull_request.head.sha || github.sha }}
  24. intervalSeconds: 20
  25. - name: 'Check Build workflow status'
  26. if: steps.wait-for-build.outputs.conclusion == 'failure'
  27. run: |
  28. exit 1
  29. - name: 'Decontaminate previous build leftovers'
  30. run: |
  31. if [ -d .git ]; then
  32. git submodule status \
  33. || 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: 'Generate prefixes by commit'
  41. id: names
  42. run: |
  43. REF="${{github.ref}}"
  44. COMMIT_HASH="$(git rev-parse HEAD)"
  45. SHA="$(git rev-parse --short HEAD)"
  46. COMMIT_MSG="${{github.event.head_commit.message}}"
  47. if [[ ${{ github.event_name }} == 'pull_request' ]]; then
  48. REF="${{github.head_ref}}"
  49. COMMIT_HASH="$(git log -1 --pretty=oneline | awk '{print $1}')"
  50. SHA="$(cut -c -8 <<< "$COMMIT_HASH")"
  51. COMMIT_MSG="$(git log -1 --pretty=format:"%s")"
  52. PULL_ID="${{github.event.pull_request.number}}"
  53. PULL_NAME="${{github.event.pull_request.title}}"
  54. fi
  55. BRANCH_NAME=${REF#refs/*/}
  56. SUFFIX=${BRANCH_NAME//\//_}-$(date +'%d%m%Y')-${SHA}
  57. if [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
  58. SUFFIX=${BRANCH_NAME//\//_}
  59. fi
  60. echo "::set-output name=commit-hash::${COMMIT_HASH}"
  61. echo "::set-output name=commit-msg::${COMMIT_MSG}"
  62. echo "::set-output name=pull-id::${PULL_ID}"
  63. echo "::set-output name=pull-name::${PULL_NAME}"
  64. echo "::set-output name=branch-name::${BRANCH_NAME}"
  65. echo "::set-output name=suffix::${SUFFIX}"
  66. - name: 'Make artifacts directory'
  67. run: |
  68. rm -rf artifacts
  69. mkdir artifacts
  70. - name: 'Download build artifacts'
  71. if: ${{ !github.event.pull_request.head.repo.fork }}
  72. run: |
  73. echo "${{ secrets.RSYNC_DEPLOY_KEY }}" > deploy_key;
  74. chmod 600 ./deploy_key;
  75. rsync -avzP \
  76. -e 'ssh -p ${{ secrets.RSYNC_DEPLOY_PORT }} -i ./deploy_key' \
  77. ${{ secrets.RSYNC_DEPLOY_USER }}@${{ secrets.RSYNC_DEPLOY_HOST }}:"${{ secrets.RSYNC_DEPLOY_BASE_PATH }}${{steps.names.outputs.branch-name}}/" artifacts/;
  78. rm ./deploy_key;
  79. - name: 'Make .map file analyse'
  80. run: |
  81. cd artifacts/
  82. /Applications/amap/Contents/MacOS/amap -f flipper-z-f7-firmware-${{steps.names.outputs.suffix}}.elf.map
  83. - name: 'Upload report to DB'
  84. run: |
  85. FBT_TOOLCHAIN_PATH=/opt source scripts/toolchain/fbtenv.sh
  86. get_size()
  87. {
  88. SECTION="$1";
  89. arm-none-eabi-size \
  90. -A artifacts/flipper-z-f7-firmware-${{steps.names.outputs.suffix}}.elf \
  91. | grep "^$SECTION" | awk '{print $2}'
  92. }
  93. export COMMIT_HASH="${{steps.names.outputs.commit-hash}}"
  94. export COMMIT_MSG="${{steps.names.outputs.commit-msg}}"
  95. export BRANCH_NAME="${{steps.names.outputs.branch-name}}"
  96. export BSS_SIZE="$(get_size ".bss")"
  97. export TEXT_SIZE="$(get_size ".text")"
  98. export RODATA_SIZE="$(get_size ".rodata")"
  99. export DATA_SIZE="$(get_size ".data")"
  100. export FREE_FLASH_SIZE="$(get_size ".free_flash")"
  101. if [[ ${{ github.event_name }} == 'pull_request' ]]; then
  102. export PULL_ID="${{steps.names.outputs.pull-id}}"
  103. export PULL_NAME="${{steps.names.outputs.pull-name}}"
  104. fi
  105. python3 -m pip install mariadb
  106. python3 scripts/amap_mariadb_insert.py \
  107. ${{ secrets.AMAP_MARIADB_USER }} \
  108. ${{ secrets.AMAP_MARIADB_PASSWORD }} \
  109. ${{ secrets.AMAP_MARIADB_HOST }} \
  110. ${{ secrets.AMAP_MARIADB_PORT }} \
  111. ${{ secrets.AMAP_MARIADB_DATABASE }} \
  112. artifacts/flipper-z-f7-firmware-${{steps.names.outputs.suffix}}.elf.map.all