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

Use a Mermaid graph in the backmerge PR body #594

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from

Conversation

mokagio
Copy link
Contributor

@mokagio mokagio commented Sep 16, 2024

What does it do?

I was waiting for CI to finish on a backmerge PR looking at the ASCII art describing the merge and got side tracked into this nerd indulgence:

image
  • Pros: It's neat and colorful and "pro"
  • Cons: It's bound to break or change if/when there's a Mermaid syntax

Checklist before requesting a review

  • Run bundle exec rubocop to test for code style violations and recommendations
  • Add Unit Tests (aka specs/*_spec.rb) if applicable - N.A.
  • Run bundle exec rspec to run the whole test suite and ensure all your tests pass
  • Make sure you added an entry in the CHANGELOG.md file to describe your changes under the appropriate existing ### subsection of the existing ## Trunk section.
  • If applicable, add an entry in the MIGRATION.md file to describe how the changes will affect the migration from the previous major version and what the clients will need to change and consider. - N.A.

commit
branch #{intermediate_branch}
checkout #{intermediate_branch}
commit
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Technically, at this time, there is no commit on the integration branch. However, without the commit, I don't think the Mermaid graph doesn't convey the idea of the integration branch as well:

without commit

image

with commit

image

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, that was also a limitation I remember seeing when I tried it a while ago. It I think it makes sense and is ok to have that commit visually added there anyway.

Technically, at this time, there is no commit on the integration branch

Besides, this is not entirely true. For example, on Tumblr there is a commit done on the intermediate branch after it is cut from release/—the goal of that extra commit being to git checkout $basebranch -- version.xcconfig to auto-resolve the conflict that would otherwise be present on that file due to it evolving separately on release/* branch (for daily betas) vs develop (for daily alphas).

This is also why this Fastlane action has a ConfigItem allowing you to pass a Proc to add arbitrary commits on the intermediate branch after it's cut but before the PR is created, btw 😉

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO the fonts and the overall size of the chart look too big for me (or maybe I'm too used to the ASCII art 😄 ), taking a lot of space of the PR text block. Is there a way to make it a bit smaller?

Copy link
Contributor

Choose a reason for hiding this comment

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

It also feels strange that the commits on trunk seem to have happened only after the commits from release/4.53 in the screenshot above; It's like if the 3 commits from trunk that were illustrated in this Mermaid graph were only pushed after release/* and merge/release-*-into-* had been created, instead of suggesting that the trunk branch has been existing and living its life for way longer before release/* branch… 🤔

Comment on lines +159 to +164
<details>
<summary>Expand to see an ASCII representation of the Git graph above</summary>

#{ascii_git_graph}

</details>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe we can mitigate the "disruption" of the graph not rendering correctly in GitHub for whichever reason by having the ASCII as a fallback here.

@mokagio mokagio added this to the 2️⃣ Next Minor Release milestone Sep 16, 2024
@mokagio mokagio added the enhancement New feature or request label Sep 16, 2024
@mokagio mokagio marked this pull request as ready for review September 16, 2024 22:08
@mokagio mokagio requested a review from a team September 23, 2024 21:16
@AliSoftware
Copy link
Contributor

AliSoftware commented Sep 23, 2024

To be honest I remember trying using Mermaid for that a while back (I think at the time I initially introduced the ASCII art in backmerge PRs a while ago actually, as I tried to do that using Mermaid first)

The issues I remember having back then is that some characters in some branch names broke the mermaid interpreter—which was then unable to render the graph at all.

I don't remember what were those problematic characters that caused this during my testing back then (maybe / as in release/12.3? Or was it -? Can't remember) but that's what made be decide to avoid using Mermaid here in case some custom branch names could sometimes cause trouble.


That being said, maybe they fixed that bug since (it was quite some time ago, after all); or maybe such issue won't occur in the context of this backmerge-pr action because the branch names are already deterministic (should all be in the form of release/xx.y or release/xx.y.z, merge/release-xx.y-into-trunk and trunk/default/main/…; so as long as characters from [a-zA-Z0-9/.-] don't cause trouble (anymore?) that should be ok to use now?

@AliSoftware AliSoftware requested a review from a team September 23, 2024 23:55
@wzieba
Copy link
Contributor

wzieba commented Sep 24, 2024

I just came here to say: nice!

GRAPH

pr_body = <<~BODY
Merging `#{head_branch}` into `#{base_branch}`.
Copy link
Contributor

Choose a reason for hiding this comment

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

wdyt about adding the chart type as a parameter? Something like :image, :ascii, :both.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My first instinct was to say thatI'd rather always have both in case the Mermaid one fails, which is something we cannot know at the time we generated the body because it depends on GitHub.

But, it's good to build flexible systems (unopinionated tools, opinionated golden path) and the adding a parameter like this does only makes the code a tiny bit more complex (simple is usually better).

I'll update 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll update 👍

Spawned #596 to not slow this down while waiting for that.

@iangmaia
Copy link
Contributor

iangmaia commented Oct 2, 2024

as long as characters from [a-zA-Z0-9/.-] don't cause trouble (anymore?) that should be ok to use now?

This seems to be the case as the images @mokagio generated so far contained these characters (I think the capital letters are the only exception)?

@AliSoftware
Copy link
Contributor

AliSoftware commented Oct 2, 2024

as long as characters from [a-zA-Z0-9/.-] don't cause trouble (anymore?) that should be ok to use now?

This seems to be the case as the images @mokagio generated so far contained these characters (I think the capital letters are the only exception)?

Yeah, seems they fixed the bug since last time I tried it? 🤷

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

Successfully merging this pull request may close these issues.

4 participants