Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ci: Fix reference commit for code size comparison. #16122

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

Merged

Conversation

projectgus
Copy link
Contributor

@projectgus projectgus commented Oct 31, 2024

Summary

Follow-up to #16114 after looking into the details of which commits GitHub checks out in PR actions.

Currently the code size comparison is between the merge base (i.e. where the PR branched), and the generated merge commit into master. If the PR branch is older than current master, this means the size comparison could incorrectly include changes already merged on master but missing from the PR branch.

This PR changes it to compare the generated merge commit against current master, i.e. the size impact if this PR was to be merged.

This commit also disables running the code size check on "push", it now only runs on pull_request events.

This work was funded through GitHub Sponsors.

Testing

Similar to #16114, I set this branch as the default branch on my fork and opened some PRs:

  1. One commit which increases rp2 code size. Reports +96 bytes.
  2. Same commit which increases rp2 code size, on top of an old branch (v1.22). The current size check misreports the increase as 0 bytes, but with this PR it reports reports +96 bytes.

Trade-offs and Alternatives

  • Instead of comparing the "generated merge commit" and master, we could compare the actual PR branch head against its merge base. Then any results should be the same as what the PR author would have seen if comparing sizes locally. However, it's fiddly to find the merge base and it's potentially less useful as an out of date PR branch might not include (for example) an optimisation change which will effect the code size after merging.
  • Could leave the "push" event on and modify it to compare incremental changes in size on a branch as it evolves. A lot more work to store the artifacts and generate a report or a graph, though.

Copy link

codecov bot commented Oct 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.57%. Comparing base (9591b0a) to head (787c424).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #16122   +/-   ##
=======================================
  Coverage   98.57%   98.57%           
=======================================
  Files         164      164           
  Lines       21345    21345           
=======================================
  Hits        21040    21040           
  Misses        305      305           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

@@ -1,7 +1,6 @@
name: Check code size

on:
push:
Copy link
Member

Choose a reason for hiding this comment

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

With this removed, will the code-size report still update when the PR is updated with addition commits, or force pushed?

Copy link
Contributor Author

@projectgus projectgus Oct 31, 2024

Choose a reason for hiding this comment

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

Yes: "By default, a workflow only runs when a pull_request event's activity type is opened, synchronize, or reopened" (ref), and synchronize is the event when someone updates the branch.

Pull request workflows don't run if there is a merge conflict, so we won't get a code size report until the conflict is resolved (but that's also the case with the current config, it runs the job but doesn't issue a report.)

EDIT: Fixed the description of status quo.

Copy link
Member

Choose a reason for hiding this comment

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

OK, great, thanks for checking.

@projectgus projectgus force-pushed the bugfix/ci_code_size_comparison branch from 15be04b to ba8ab19 Compare October 31, 2024 05:28
@dpgeorge dpgeorge added the tools Relates to tools/ directory in source, or other tooling label Oct 31, 2024
Previously the code size comparison was between the merge base (i.e. where
the PR branched), and the generated merge commit into master.  If the PR
branch was older than current master, this meant the size comparison could
incorrectly include changes already merged on master but missing from the
PR branch.

This commit changes it to compare the generated merge commit against
current master, i.e. the size impact if this PR was to be merged.

This commit also disables running the code size check on "push", it now
only runs on pull_request events.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <[email protected]>
@dpgeorge dpgeorge force-pushed the bugfix/ci_code_size_comparison branch from ba8ab19 to 787c424 Compare October 31, 2024 12:20
@dpgeorge dpgeorge merged commit 787c424 into micropython:master Oct 31, 2024
64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tools Relates to tools/ directory in source, or other tooling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants