amap_analyse.yml 4.6 KB

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