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

CI: Add workflow to calculate build size diff before & after PR/commit. #262

Merged
merged 1 commit into from
Feb 14, 2023

Conversation

microbit-carlos
Copy link
Collaborator

@microbit-carlos microbit-carlos commented Feb 2, 2023

This PR uses Google's Bloaty McBloatface to analyse the MICROBIT elf file for memory consumption.

It also builds the PR base commit, or the commit parent, to do a diff and see the additional memory consumed or saved.

In the case of being a PR from a branch in this repository (not forks) it will post the diff as a comment as well.

To show an example diff in this PR (instead of an output just showing "no change in size"), the initial commit will contain a bit of code in MicroBit.cpp to create a 4000 byte array and a loop to write some data into it. So, the first bot comment will show the PR as increasing the .bss and .text sections.
I will then force push an update removing this code and the bot will post another comment showing a zero size increase.

Both bloaty analysis outputs are added to to the Action work summary, so even PRs from forks will have this info (even if they don't get a PR comment):

image

@github-actions
Copy link

github-actions bot commented Feb 2, 2023

Build diff

Base commit: 6c1433e877e570f9958c1edab77062d4ed9220fd
Action run: https://github.com/lancaster-university/codal-microbit-v2/actions/runs/4074154437

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0   +44% +3.91Ki    .bss
  +0.0%     +16  +0.0%     +16    .text
  +0.0%     +32  [ = ]       0    .debug_abbrev
  +0.0%    +103  [ = ]       0    .debug_info
  +0.0%     +48  [ = ]       0    .debug_line
  +0.0%     +19  [ = ]       0    .debug_loc
  +0.0%     +24  [ = ]       0    .debug_ranges
  +0.0%     +20  [ = ]       0    .debug_str
  +0.0%     +20  [ = ]       0    .strtab
  +0.0%     +32  [ = ]       0    .symtab
  -0.0%     -18  [ = ]       0    [Unmapped]
  [ = ]       0  -3.6% -3.91Ki    .heap
  +0.0%    +296  +0.0%     +16    TOTAL

@microbit-carlos
Copy link
Collaborator Author

microbit-carlos commented Feb 2, 2023

Okay, so now I'll force push without the test C++ code and the bot should add another comment after this, indicating the build size for this PR hasn't changed vs the base commit.

https://github.com/lancaster-university/codal-microbit-v2/compare/971d6c59b66015612f17f3f7a69c1f217eed3325..7843574ae2a196029527eb79cfb004d23e0be385
image

@github-actions
Copy link

Build diff

Base commit: fd3bde3c71e381ce2f6fd732433bdba5c528782e
Action run: https://github.com/lancaster-university/codal-microbit-v2/actions/runs/4167952013

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL

Copy link
Collaborator Author

@microbit-carlos microbit-carlos left a comment

Choose a reason for hiding this comment

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

I've tweaked a bit the order of the workflow steps and how the codal.json file is modified and this PR is now ready to be merged 🎉

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