Skip to content

Conversation

@desi
Copy link
Contributor

@desi desi commented Mar 3, 2025

We (MMIG eng) have decided that PRs greater than 1000 lines are too big and need to be broken down, thus this check will be used in metamask-extension, metamask-mobile and core to prevent PRs which are too big.

https://github.com/MetaMask/MetaMask-planning/issues/3739

@desi desi marked this pull request as ready for review March 3, 2025 22:11
@HowardBraham
Copy link
Contributor

I think this needs override ability. Some PRs have to be very large. And those should also be added to this list MetaMask/metamask-extension#30661

@desi
Copy link
Contributor Author

desi commented Mar 4, 2025

I think this needs override ability. Some PRs have to be very large. And those should also be added to this list MetaMask/metamask-extension#30661

@HowardBraham We discussed that PRs larger than this would require an admin override. Is that sufficient for the edge cases?

cc @sethkfman

@davidmurdoch
Copy link

This should probably ignore yarn.lock (and other lock files) and all lavamoat policy file changes, as those can get big really quickly.

sethkfman
sethkfman previously approved these changes Mar 5, 2025
Copy link
Contributor

@sethkfman sethkfman left a comment

Choose a reason for hiding this comment

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

LGTM

@github-project-automation github-project-automation bot moved this from Needs dev review to Review finalised - Ready to be merged in PR review queue Mar 5, 2025
itsyoboieltr
itsyoboieltr previously approved these changes Mar 5, 2025
@desi
Copy link
Contributor Author

desi commented Mar 5, 2025

This should probably ignore yarn.lock (and other lock files) and all lavamoat policy file changes, as those can get big really quickly.

@davidmurdoch Since this is a shared workflow and other repos might not have lavamoat files should we maybe make the regex for exclude files a param that could be passed in from the calling action?

@davidmurdoch
Copy link

@davidmurdoch Since this is a shared workflow and other repos might not have lavamoat files should we maybe make the regex for exclude files a param that could be passed in from the calling action?

Yeah, that sounds like the best way to do this.

@desi desi dismissed stale reviews from itsyoboieltr and sethkfman via 666a843 March 5, 2025 18:05
@desi
Copy link
Contributor Author

desi commented Mar 5, 2025

@davidmurdoch Since this is a shared workflow and other repos might not have lavamoat files should we maybe make the regex for exclude files a param that could be passed in from the calling action?

Yeah, that sounds like the best way to do this.

Added in new ignore_pattern to the inputs and set .lock files as the default. Calling actions can set whatever other files they would like.

run: |
BASE_BRANCH="${{ steps.get-base-branch.outputs.base_branch }}"
# Fetch the base branch for comparison
git fetch origin "$BASE_BRANCH"
Copy link
Member

@seaona seaona Mar 5, 2025

Choose a reason for hiding this comment

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

mmm so we are fetching the entire repo here right? In Extension, we avoided doing a full fetch, and instead we perform a fetch with depth, to optimize the flow here and we also have this function which increments the depth, in case it's needed (for doing the git-diff operation later on)

I'm wondering if we could re-use some of this? Otherwise we are performing a git fetch with depth, but with this flow, were are now also performing a full fetch 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So would the change here be to update row 46 to git fetch --depth 1 origin "$BASE_BRANCH"? I don't think I need the function referenced but please correct me if I am missing something.

Copy link
Member

Choose a reason for hiding this comment

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

I think you would need to fetch a depth of more than 1, as you need all commits in-between the base branch and the HEAD to be present. I cannot recall the behavior of git diff when the commits needed for the diff are missing, but surely it will either error or return suboptimal results without the commits present that are needed for the diff. I think it errors.

In the function @seaona linked, we increment the depth until the command git merge-base origin/HEAD HEAD succeeds, as the goal is to at least have commits up to the merge-base present. I believe a similar strategy should work here as well. Except that instead of origin/HEAD we may want to use origin/$BASE_BRANCH.

Copy link
Member

Choose a reason for hiding this comment

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

I will say though that fetching the whole repository doesn't take that long. Personally I'd consider this a non-blocking suggestion/optimization, which we could do later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Gudahtt and @seaona I believe I addressed the feedback.

 - Added incremental shallow fetches with depths 1, 10, and 100 to avoid a full repo fetch.
 - Implemented logic to detect when the merge-base is available using the fetched commits.
 - Fall back to fetching the full history (unshallow) if necessary to ensure proper diff calculation.
@desi desi merged commit 0fb1d09 into main Apr 10, 2025
18 checks passed
@desi desi deleted the dm-add-pr-line-check branch April 10, 2025 18:02
@github-project-automation github-project-automation bot moved this from Review finalised - Ready to be merged to Merged, Closed or Archived in PR review queue Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

10 participants