-
Notifications
You must be signed in to change notification settings - Fork 381
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,9 @@ import { Project, ProjectOptions, ProjectType } from "../project"; | |
import { SampleReadme, SampleReadmeProps } from "../readme"; | ||
import { DevContainer, VsCode } from "../vscode"; | ||
import { AutoApprove, AutoApproveOptions } from "./auto-approve"; | ||
import { AutoMergeOptions } from "./auto-merge"; | ||
import { AutoMerge, AutoMergeOptions } from "./auto-merge"; | ||
import { GitHub, GitHubOptions } from "./github"; | ||
import { GithubCredentials } from "./github-credentials"; | ||
import { MergifyOptions } from "./mergify"; | ||
import { Stale, StaleOptions } from "./stale"; | ||
|
||
/** | ||
|
@@ -46,22 +45,6 @@ export interface GitHubProjectOptions extends ProjectOptions { | |
*/ | ||
readonly githubOptions?: GitHubOptions; | ||
|
||
/** | ||
* Whether mergify should be enabled on this repository or not. | ||
* | ||
* @default true | ||
* @deprecated use `githubOptions.mergify` instead | ||
*/ | ||
readonly mergify?: boolean; | ||
|
||
/** | ||
* Options for mergify | ||
* | ||
* @default - default options | ||
* @deprecated use `githubOptions.mergifyOptions` instead | ||
*/ | ||
readonly mergifyOptions?: MergifyOptions; | ||
|
||
/** | ||
* Add a VSCode development environment (used for GitHub Codespaces) | ||
* | ||
|
@@ -97,8 +80,17 @@ export interface GitHubProjectOptions extends ProjectOptions { | |
readonly autoApproveOptions?: AutoApproveOptions; | ||
|
||
/** | ||
* Configure options for automatic merging on GitHub. Has no effect if | ||
* `github.mergify` is set to false. | ||
* Enable automatic merging pull requests on GitHub. Currently, this only | ||
* supports using Mergify to merge pull requests. Has no effect if `github` is | ||
* set to false. | ||
* | ||
* @default true | ||
*/ | ||
readonly autoMerge?: boolean; | ||
|
||
/** | ||
* Configure options for automatic merging pull requests on GitHub. Has no | ||
* effect if `autoMerge` is set to false or `github` is set to false. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
* | ||
* @default - see defaults in `AutoMergeOptions` | ||
*/ | ||
|
@@ -181,6 +173,11 @@ export class GitHubProject extends Project { | |
*/ | ||
public readonly projectType: ProjectType; | ||
|
||
/** | ||
* Auto merging pull requests for this project. | ||
*/ | ||
public readonly autoMerge?: AutoMerge; | ||
|
||
/** | ||
* Auto approve set up for this project. | ||
*/ | ||
|
@@ -196,8 +193,6 @@ export class GitHubProject extends Project { | |
? new GitHub(this, { | ||
projenTokenSecret: options.projenTokenSecret, | ||
projenCredentials: options.projenCredentials, | ||
mergify: options.mergify, | ||
mergifyOptions: options.mergifyOptions, | ||
...options.githubOptions, | ||
}) | ||
: undefined; | ||
|
@@ -223,6 +218,11 @@ export class GitHubProject extends Project { | |
); | ||
} | ||
|
||
const autoMerge = options.autoMerge ?? true; | ||
if (autoMerge && this.github) { | ||
this.autoMerge = new AutoMerge(this.github, options.autoMergeOptions); | ||
} | ||
|
||
const stale = options.stale ?? false; | ||
if (stale && this.github) { | ||
new Stale(this.github, options.staleOptions); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,26 +2,11 @@ import { Component } from "../component"; | |
import { Project } from "../project"; | ||
import { Dependabot, DependabotOptions } from "./dependabot"; | ||
import { GithubCredentials } from "./github-credentials"; | ||
import { Mergify, MergifyOptions } from "./mergify"; | ||
import { PullRequestTemplate } from "./pr-template"; | ||
import { PullRequestLint, PullRequestLintOptions } from "./pull-request-lint"; | ||
import { GithubWorkflow } from "./workflows"; | ||
|
||
export interface GitHubOptions { | ||
/** | ||
* Whether mergify should be enabled on this repository or not. | ||
* | ||
* @default true | ||
*/ | ||
readonly mergify?: boolean; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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... |
||
|
||
/** | ||
* Options for Mergify. | ||
* | ||
* @default - default options | ||
*/ | ||
readonly mergifyOptions?: MergifyOptions; | ||
|
||
/** | ||
* Enables GitHub workflows. If this is set to `false`, workflows will not be created. | ||
* | ||
|
@@ -72,12 +57,6 @@ export class GitHub extends Component { | |
return project.components.find(isGitHub); | ||
} | ||
|
||
/** | ||
* The `Mergify` configured on this repository. This is `undefined` if Mergify | ||
* was not enabled when creating the repository. | ||
*/ | ||
public readonly mergify?: Mergify; | ||
|
||
/** | ||
* Are workflows enabled? | ||
*/ | ||
|
@@ -111,10 +90,6 @@ export class GitHub extends Component { | |
}); | ||
} | ||
|
||
if (options.mergify ?? true) { | ||
this.mergify = new Mergify(this, options.mergifyOptions); | ||
} | ||
|
||
if (options.pullRequestLint ?? true) { | ||
new PullRequestLint(this, options.pullRequestLintOptions); | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
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.