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

bug: update PR runs even if PR is up-to-date with main branch #304

Closed
bcoe opened this issue Feb 20, 2020 · 1 comment
Closed

bug: update PR runs even if PR is up-to-date with main branch #304

bcoe opened this issue Feb 20, 2020 · 1 comment
Assignees
Labels
bot: merge on green priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. 🚨 This issue needs some love. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@bcoe
Copy link
Contributor

bcoe commented Feb 20, 2020

Now that merge-on-green is a trusted contributor (hooray, thanks @chingor13 and @sofisl) I noticed that we never merge PRs, because every time we update a branch it re-kicks-off-tests.

There seem to be two potential fixes, a quick fix is to only update the branch if the merge fails:

    if (checkReview === true && checkStatus === true) {
		let merged = false;
        try {
          	console.info(`attempt to merge ${owner}/${repo}`);
        	await mergeOnGreen.merge(owner, repo, pr, github);
          	merged = true;
        } catch (err) {
          console.info(err);
            await mergeOnGreen.updateBranch(owner, repo, pr, github);
        }
      	return merged;      
    }

This works because when an attempt is made to merge a PR that isn't up-to-date, the following error is thrown:

A 2020-02-20T06:20:50.733Z merge_on_green mz3c7l1c3kdv { HttpError: Pull Request is not mergeable merge_on_green mz3c7l1c3kdv 
A 2020-02-20T06:20:50.733Z merge_on_green mz3c7l1c3kdv     at response.text.then.message (/srv/functions/node_modules/@octokit/request/dist-node/index.js:66:23) merge_on_green mz3c7l1c3kdv 
A 2020-02-20T06:20:50.733Z merge_on_green mz3c7l1c3kdv     at process._tickCallback (internal/process/next_tick.js:68:7) merge_on_green mz3c7l1c3kdv 
A 2020-02-20T06:20:50.733Z merge_on_green mz3c7l1c3kdv   name: 'HttpError', merge_on_green mz3c7l1c3kdv 

A better fix might be to eventually determine whether or not a branch is up-to-date with master, and only call update if necessary.

I suggest that we land the quick fix first, but with our sights set to the more thorough fix.

@bcoe bcoe added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. labels Feb 20, 2020
@sofisl
Copy link
Contributor

sofisl commented Feb 20, 2020

Hope it's ok to close these issues, assuming we've addressed the issues :)

@sofisl sofisl closed this as completed Feb 20, 2020
@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Apr 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: merge on green priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. 🚨 This issue needs some love. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

4 participants