Skip to content

use single to keep json quotes #35

use single to keep json quotes

use single to keep json quotes #35

name: FLASH usage analysis
on:
push:
branches:
- 'main'
pull_request:
branches:
- '*'
env:
MIN_FLASH_POS_DIFF_FOR_COMMENT: 50
MIN_FLASH_NEG_DIFF_FOR_COMMENTS: -50
jobs:
analyze_flash:
name: FLASH usage analysis
runs-on: ubuntu-latest
container:
image: px4io/px4-dev-nuttx-focal
strategy:
matrix:
target: [px4_fmu-v5x, px4_fmu-v6x]
outputs:
px4_fmu-v5x-bloaty-output-encoded: ${{ steps.gen-output.outputs.px4_fmu-v5x-bloaty-output-encoded }}
px4_fmu-v5x-bloaty-summary-map: ${{ steps.gen-output.outputs.px4_fmu-v5x-bloaty-summary-map }}
px4_fmu-v6x-bloaty-output-encoded: ${{ steps.gen-output.outputs.px4_fmu-v6x-bloaty-output-encoded }}
px4_fmu-v6x-bloaty-summary-map: ${{ steps.gen-output.outputs.px4_fmu-v6x-bloaty-summary-map }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Git ownership workaround
run: git config --system --add safe.directory '*'
- name: Build
run: make ${{ matrix.target }}
- name: Store the ELF with the change
run: cp ./build/${{ matrix.target }}_default/${{ matrix.target }}_default.elf ./with-change.elf
- name: Clean previous build
run: |
make clean
make distclean
- name: If it's a PR checkout the base commit
if: ${{ github.event.pull_request }}
run: git checkout ${{ github.event.pull_request.base.sha }}
- name: If it's a push checkout the previous commit
if: github.event_name == 'push'
run: git checkout ${{ github.event.before }}
- name: Update submodules
run: make submodulesupdate
- name: Build
run: make ${{ matrix.target }}
- name: Store the ELF before the change
run: cp ./build/${{ matrix.target }}_default/${{ matrix.target }}_default.elf ./before-change.elf
- name: bloaty-action
uses: PX4/[email protected]
id: bloaty-step
with:
bloaty-file-args: ./with-change.elf -- ./before-change.elf
bloaty-additional-args: -d sections,compileunits -s vm -n 0
output-to-summary: true
- name: Generate output
id: gen-output
run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "${{ matrix.target }}-bloaty-output-encoded<<$EOF" >> $GITHUB_OUTPUT
echo "${{ steps.bloaty-step.outputs.bloaty-output-encoded }}" >> $GITHUB_OUTPUT
echo "$EOF" >> $GITHUB_OUTPUT
echo "${{ matrix.target }}-bloaty-summary-map<<$EOF" >> $GITHUB_OUTPUT
echo '${{ steps.bloaty-step.outputs.bloaty-summary-map }}' >> $GITHUB_OUTPUT
echo "$EOF" >> $GITHUB_OUTPUT
post_pr_comment:
name: Post PR comment
runs-on: ubuntu-latest
needs: [analyze_flash]
env:
V5X-SUMMARY-MAP: ${{ needs.analyze_flash.outputs.px4_fmu-v5x-bloaty-summary-map }}
V6X-SUMMARY-MAP: ${{ needs.analyze_flash.outputs.px4_fmu-v6x-bloaty-summary-map }}
steps:
- name: If it's a PR and the FLASH diff is large enough, add a comment with the bloaty output
if: |
github.event.pull_request &&
(
fromJSON(fromJSON(env.V5X-SUMMARY-MAP).vm-absolute) > fromJSON(env.MIN_FLASH_POS_DIFF_FOR_COMMENT) ||
fromJSON(fromJSON(env.V5X-SUMMARY-MAP).vm-absolute) < fromJSON(env.MIN_FLASH_NEG_DIFF_FOR_COMMENTS) ||
fromJSON(fromJSON(env.V6X-SUMMARY-MAP).vm-absolute) > fromJSON(env.MIN_FLASH_POS_DIFF_FOR_COMMENT) ||
fromJSON(fromJSON(env.V6X-SUMMARY-MAP).vm-absolute) < fromJSON(env.MIN_FLASH_NEG_DIFF_FOR_COMMENTS)
)
uses: actions/github-script@v6
with:
script: |
const comment = [
'## 🔎 FLASH Analysis',
'<details>',
'<summary>px4_fmu-v5x [Total VM Diff: ${{ fromJSON(env.V5X-SUMMARY-MAP).vm-absolute }} (${{ fromJSON(env.V5X-SUMMARY-MAP).vm-percentage }})]</summary>',
'',
'```',
`${{ needs.analyze_flash.outputs.px4_fmu-v5x-bloaty-output-encoded }}`,
'```',
'</details>',
'',
'<details>',
'<summary>px4_fmu-v6x [Total VM Diff: ${{ fromJSON(env.V6X-SUMMARY-MAP).vm-absolute }} (${{ fromJSON(env.V6X-SUMMARY-MAP).vm-percentage }})]</summary>',
'',
'```',
`${{ needs.analyze_flash.outputs.px4_fmu-v6x-bloaty-output-encoded }}`,
'```',
'</details>'
]
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment.join('\n')
})