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

feat: refactor mergify APIs #1766

Closed
wants to merge 4 commits into from
Closed

Conversation

Chriscbr
Copy link
Contributor

The motivation for this PR is to simplify the APIs for Mergify and AutoMerge. Mergify configuration is currently getting configured from multiple places (both mergifyOptions and autoMergeOptions), which leads to confusion since it's likely many users will only discover one or the other.

In another sense, projen's API is exposing options both through the L2 Mergify (an intent based API for managing Mergify configuration files) and the L3 AutoMerge (and intent based API for managing the concept of auto-merging, which relies on Mergify as an implementation detail). I think this makes the design more complicated / confusing to users.

Instead this PR changes the mental model so we just expose the L3 API (autoMerge and autoMergeOptions) in base project options, so mergify has to be either configured through AutoMerge, or created and managed separately.

BREAKING CHANGE: mergify and mergifyOptions are no longer available to directly configure at the project level. Instead, use autoMerge and autoMergeOptions. If you would like to disable automerging, add autoMerge: false to your project constructor and create a new Mergify component directly.

  • Mergify cannot be accessed through Github or project.github anymore, instead it is a property of AutoMerge or project.autoMerge.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@Chriscbr Chriscbr requested a review from a team April 13, 2022 18:35
@mergify mergify bot added the contribution/core ⚙️ used by automation label Apr 13, 2022
Signed-off-by: github-actions <github-actions@github.com>
@codecov-commenter
Copy link

codecov-commenter commented Apr 13, 2022

Codecov Report

Merging #1766 (53c2f92) into main (d90284c) will increase coverage by 1.89%.
The diff coverage is 91.59%.

@@            Coverage Diff             @@
##             main    #1766      +/-   ##
==========================================
+ Coverage   88.06%   89.95%   +1.89%     
==========================================
  Files         132      153      +21     
  Lines        5109     6234    +1125     
  Branches     1207     1597     +390     
==========================================
+ Hits         4499     5608    +1109     
- Misses        610      621      +11     
- Partials        0        5       +5     
Impacted Files Coverage Δ
src/cdk/consts.ts 100.00% <ø> (+36.36%) ⬆️
src/dev-env.ts 83.33% <0.00%> (ø)
src/java/index.ts 100.00% <ø> (ø)
src/python/index.ts 100.00% <ø> (ø)
src/release/bump-version.ts 98.68% <ø> (+0.05%) ⬆️
src/release/index.ts 100.00% <ø> (ø)
src/release/publisher.ts 98.85% <ø> (-0.38%) ⬇️
src/release/release-trigger.ts 100.00% <ø> (ø)
src/release/release.ts 95.79% <ø> (-2.06%) ⬇️
src/release/tag-version.ts 86.66% <ø> (ø)
... and 184 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update af04922...53c2f92. Read the comment docs.

@pgollucci
Copy link
Contributor

@Mergifyio rebase

@mergify
Copy link
Contributor

mergify bot commented Apr 14, 2022

@pgollucci is not allowed to run commands

@pgollucci
Copy link
Contributor

#1765

Copy link
Contributor

@kaizencc kaizencc left a comment

Choose a reason for hiding this comment

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

Some minor comments, mostly revolving around documentation.

@@ -40,6 +40,19 @@ const project = new javascript.NodeProject({
});
```

## Automatic Merging
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like this doc is missing a code snippet or two. I feel like there should be an example for configuring automatic merging as well as what to do if you want to configure Mergify in your project for something else.


/**
* Configure options for automatic merging pull requests on GitHub. Has no
* effect if `autoMerge` is set to false or `github` is set to false.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not too familiar with projen customs, but should we simply error out if autoMergeOptions is set and autoMerge or github is set to false? Seems odd to just ignore this property. Same goes for autoMerge

*
* @default true
*/
readonly mergify?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is a fairly big API transition and we're removing a few properties (esp the non-deprecated ones like these), I feel like we need to have strong migration docs between projen versions for users who are broken.

I think I understand the vision of projen where we have lots of major versions and you don't really need to upgrade projen in your project. But if I'm a die-hard projen user with some ideas on how to set up mergify in an old project (in projen v0.34 for example) and it now doesn't exist when I'm trying to set up a new project (in projen v0.59 or something), I'm going to want to have some docs that tell me what to do now. I don't really know if there's a right way to achieve this though.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess the BREAKING CHANGE comments go into the changelog? but do people actually rely on the changelog for help?

Copy link
Contributor Author

@Chriscbr Chriscbr Apr 18, 2022

Choose a reason for hiding this comment

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

I think putting all breaking changes / migration suggestions in the changelog is probably okay since it's a single source of truth for high-level API changes and it's easy to ctrl+f for some API name. But I agree it's a good idea to link to detailed docs as well. It could also be nice if the docs of any component listed the latest changes / versions of projen it was changed in etc.

We don't generate a single changelog file anywhere right now, so maybe that should be addressed first...

approvedReviews: 2,
blockingLabels: ["draft"],
});
autoMerge.mergify.addRule({
Copy link
Contributor

Choose a reason for hiding this comment

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

is exposing mergify a leaky abstraction? especially if we plan on providing other auto-merging backends in the future (per the docs you wrote).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmmmm, yeah you're totally right.

In that case I'm not sure how much the API in this PR makes sense anymore. 😅 Maybe I'll put this back on hold for now

@Chriscbr Chriscbr marked this pull request as draft April 18, 2022 20:40
@Chriscbr Chriscbr closed this Apr 19, 2022
mergify bot pushed a commit that referenced this pull request Apr 21, 2022
Supersedes #1766
Fixes #1765

---
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
@mrgrain mrgrain deleted the rybickic/refactor-automerge branch June 29, 2023 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core ⚙️ used by automation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants