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

ICFY: migrate icfy-stats task from master branch to trunk #47620

Merged
merged 1 commit into from
Nov 20, 2020

Conversation

jsnajdr
Copy link
Member

@jsnajdr jsnajdr commented Nov 20, 2020

When calculating stats for a branch build and submitting them to ICFY via a webhook, one of the things that the task computes is the "ancestor" commit SHA, i.e., the point in the trunk branch from where the PR branch was created.

This will now have to look at trunk instead of master. If we don't do this, bundle size diffs will be calculated against the last master commit instead of the trunk one. As master will be frozen and will stop moving forward, the diffs would be increasingly incorrect.

As a drive-by fix, I'm changing the URL of the webhook endpoint. The api. prefix and the 5000 port have been optional for a long time now.

Looking at #45234, this change is not there.

When calculating stats for a branch build and submitting them to ICFY via a
webhook, one of the things that the task computes is the "ancestor" commit
SHA, i.e., the point in the `trunk` branch from where the PR branch is created.

This will now have to look at `trunk` instead of `master`. If we don't do this,
bundle size diffs will be calculated against that last `master` commit instead
of the `trunk` one. As `master` will be frozen and will stop moving forward,
the diffs would be increasingly incorrect.

As a drive-by fix, I'm changing the URL of the webhook endpoint. The `api.`
prefix and the 5000 port have been optional for a long time now.
@jsnajdr jsnajdr requested review from sarayourfriend and a team November 20, 2020 13:53
@matticbot
Copy link
Contributor

@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Nov 20, 2020
@jsnajdr
Copy link
Member Author

jsnajdr commented Nov 20, 2020

Of course the icfy-stats job fails now because it can't find the trunk branch 🙂

fatal: Not a valid object name origin/trunk

@@ -42,12 +42,12 @@ jobs:
env:
ICFY_SECRET: ${{ secrets.ICFY_SECRET }}
run: |
ANCESTOR_SHA1=$(git merge-base HEAD origin/master)
ANCESTOR_SHA1=$(git merge-base HEAD origin/trunk)
Copy link
Contributor

Choose a reason for hiding this comment

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

I have not tested it, but StackOverflow says you can use ${{ github.event.pull_request.base.ref }} to get the target of the PR. This will make ICFY works for branches targeting branches other than master/trunk

https://stackoverflow.com/questions/62331829/how-to-get-the-target-branch-of-the-github-pull-request-from-an-actions

Copy link
Member Author

Choose a reason for hiding this comment

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

@scinos It's a long time since I last looked at this in detail, but I think that github.event.pull_request.base.ref describes the tip of the base branch where we want to merge the PR -- master or another PR branch for stacked PRs. The tip is useful, for example, for detecting merge conflicts.

About the merge base, the git merge-base man page says:

Note that there can be more than one merge base for a pair of commits.

And shows this criss-cross merge as an example:

---1---o---A
    \ /
     X
    / \
---2---o---o---B

where 1 and 2 are equally good merge bases for A and B.

This is very unlikely to happen in our repo, as we don't use merges, and also the two histories need to be independent (we have a few of these after importing packages like wpcom from other repos), without a common ancestor.

But it's probably a reason why merge-base is not exposed by the GitHub API.

@sarayourfriend sarayourfriend changed the base branch from master to trunk November 20, 2020 16:09
@sarayourfriend sarayourfriend merged commit c5fff69 into trunk Nov 20, 2020
@sarayourfriend sarayourfriend deleted the icfy/migrate-trunk-branch branch November 20, 2020 16:38
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Nov 20, 2020
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.

None yet

4 participants