Skip to content

Commit

Permalink
fix(auto-merge): Mergify is not merging pull requests (#2517)
Browse files Browse the repository at this point in the history
Mergify is deprecating[1] pull request rebasing with random users. We don't use that, but because we don't have a default for update_method mergify thinks we might be trying to rebase. We aren't, and explicitly saying update_method: merge should solve the problem.

[1] https://changelog.mergify.com/changelog/rebasing-pull-requests-with-a-random-user-is-deprecated
  • Loading branch information
mrgrain committed Mar 21, 2023
1 parent 7c3fc85 commit 25add2c
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 1 deletion.
1 change: 1 addition & 0 deletions .mergify.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions docs/api/API.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/github/auto-merge.ts
Expand Up @@ -71,6 +71,7 @@ export class AutoMerge extends Component {

mergify.addQueue({
name: "default",
updateMethod: "merge",
conditions: (() => this.renderConditions()) as any,
});

Expand Down
29 changes: 28 additions & 1 deletion src/github/mergify.ts
@@ -1,5 +1,6 @@
import { GitHub } from "./github";
import { Component } from "../component";
import { snakeCaseKeys } from "../util";
import { YamlFile } from "../yaml";

/**
Expand Down Expand Up @@ -39,6 +40,32 @@ export interface MergifyQueue {
* The name of the queue.
*/
readonly name: string;

/**
* Merge method to use.
*
* Possible values are `merge`, `squash`, `rebase` or `fast-forward`.
* `fast-forward` is not supported on queues with `speculative_checks` > 1, `batch_size` > 1, or with `allow_inplace_checks` set to false.
*
* @default "merge"
*/
readonly mergeMethod?: string;

/**
* Method to use to update the pull request with its base branch when the speculative check is done in-place.
*
* Possible values:
* - `merge` to merge the base branch into the pull request.
* - `rebase` to rebase the pull request against its base branch.
*
* Note that the `rebase` method has some drawbacks, see Mergify docs for details.
*
* @see https://docs.mergify.com/actions/queue/#queue-rules
*
* @default - `merge` for all merge methods except `fast-forward` where `rebase` is used
*/
readonly updateMethod?: string;

/**
* A list of Conditions string that must match against the
* pull request for the pull request to be added to the queue.
Expand Down Expand Up @@ -74,7 +101,7 @@ export class Mergify extends Component {
if (this.yamlFile == null) {
this.yamlFile = new YamlFile(this.project, ".mergify.yml", {
obj: {
queue_rules: this.queues,
queue_rules: () => this.queues.map((q) => snakeCaseKeys(q, false)),
pull_request_rules: this.rules,
},
// Mergify needs to read the file from the repository in order to work.
Expand Down
2 changes: 2 additions & 0 deletions test/__snapshots__/integ.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/cdk/__snapshots__/jsii.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions test/github/__snapshots__/mergify.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/typescript/__snapshots__/typescript.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/web/__snapshots__/nextjs-project.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/web/__snapshots__/nextjs-ts-project.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/web/__snapshots__/react-project.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/web/__snapshots__/react-ts-project.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 25add2c

Please sign in to comment.