amap_analyse.yml 4.5 KB

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