Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added various features to flash analysis #24072

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alexcekay
Copy link
Member

Solved Problem

There has been feedback regarding the FLASH analysis tool. This PR adds several of the requested features.

  • Use an updated version of bloaty
  • Show the FLASH diff directly, without the user having to scroll through the bloaty output
  • Don't show a comment for small changes
  • The analysis shall also work if the FLASH overflows

Solution

  • To use an updated bloaty version and return the diff to the GH action an adaption of the bloaty-action was required. These changes can be found here: https://github.com/PX4/bloaty-action
  • The action itself has been updated to show the diff and not post a comment if the diff is too small.
  • To avoid no ELF being created due to a FLASH overflow (and thus no option to do the analysis), a new flash-analysis board has been added to v5x and v6x which fakes a large FLASH.

Test coverage

…w, summary in comment output, newer bloaty version, only add comment if change is large enough, ...)
@alexcekay alexcekay marked this pull request as ready for review December 4, 2024 12:29
Copy link
Contributor

@mrpollo mrpollo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice additions!

I left some comments, mainly focused on readability/maintainability for whoever comes after us and tries to figure this out

run: make ${{ matrix.target }}
# Use special flash-analysis target if present. Otherwise fall back to the default target.
run: |
if make list_config_targets | grep ${{ matrix.target }}_flash-analysis; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to check this here? Can we hardcode the target name?

if make list_config_targets | grep ${{ matrix.target }}_flash-analysis; then
cp ./build/${{ matrix.target }}_flash-analysis/${{ matrix.target }}_flash-analysis.elf ./with-change.elf
else
cp ./build/${{ matrix.target }}_default/${{ matrix.target }}_default.elf ./with-change.elf
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you find the elf file by a wildcard search? cp ./build/**/*.elf ./with-change.elf?


post_pr_comment:
name: Publish Results
runs-on: [runs-on,runner=1cpu-linux-x64,image=ubuntu24-full-x64,"run-id=${{ github.run_id }}",spot=false]
needs: [analyze_flash]
env:
V5X-SUMMARY-MAP: ${{ needs.analyze_flash.outputs.px4_fmu-v5x-bloaty-summary-map }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree with the use of env in principle, but I see how it's way cleaner than the uber-long string. I would go one step further and do the fromJSON casting here so you avoid it everywhere else below.

V5X-SUMMARY-MAP: ${{ fromJSON(fromJSON(needs.analyze_flash.outputs.px4_fmu-v5x-bloaty-summary-map).vm-absolute) }}
V5X-SUMMARY-PERC: ${{ fromJSON(fromJSON(needs.analyze_flash.outputs.px4_fmu-v5x-bloaty-summary-map).vm-percentage) }}
V6X-SUMMARY-MAP: ${{ fromJSON(fromJSON(needs.analyze_flash.outputs.px4_fmu-v6x-bloaty-summary-map).vm-absolute) }}
V6X-SUMMARY-PERC: ${{ fromJSON(fromJSON(needs.analyze_flash.outputs.px4_fmu-v6x-bloaty-summary-map).vm-percentage) }}

@@ -92,25 +129,32 @@ jobs:
echo "timestamp=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_OUTPUT

- name: Create or update comment
# This can't be moved to the job-level conditions, as GH actions don't allow a job-level if condition to access the env.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative to using env is to introduce a new step that sets the outputs, but it should be fine as is right now.

uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
## FLASH Analysis
## 🔎 FLASH Analysis
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants