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

Don't treat renovate/stability-days as passing status check #7800

Closed
rarkins opened this issue Nov 24, 2020 · 29 comments
Closed

Don't treat renovate/stability-days as passing status check #7800

rarkins opened this issue Nov 24, 2020 · 29 comments
Assignees
Labels
help wanted Help is needed or welcomed on this issue priority-2-high Bugs impacting wide number of users or very important features status:in-progress Someone is working on implementation type:feature Feature (new functionality)

Comments

@rarkins
Copy link
Collaborator

rarkins commented Nov 24, 2020

If the only passing status check is renovate/stability-days then we should consider that as zero passing status checks and therefore still "pending". Original:

@andrewgies17 in my instance I use an external CI pipeline (Jenkins) which reports to GitLab. The Jenkins jobs sometimes take a while to start and if the stability days status check gets applied first, the MR can be merged before the Jenkins job has started. It would be useful if there was an option to only apply the stability days status check if there is already a passing pipeline.

Originally posted by @grit96 in #5743 (comment)

@rarkins rarkins added priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others type:feature Feature (new functionality) labels Nov 24, 2020
@rarkins
Copy link
Collaborator Author

rarkins commented Nov 24, 2020

This may be platform-specific though, possibly we cannot access the details to perform this type of filtering per-platform.

Also it might be worthwhile to move pass/pending/fail logic up from the platform layer (where we duplicate a lot of logic) to the worker layer.

@viceice
Copy link
Member

viceice commented Nov 24, 2020

Maybe a better option is to remove the stabillity check status instead of add it as passing?

@rarkins
Copy link
Collaborator Author

rarkins commented Nov 24, 2020

Maybe, but we're probably going to end up with a few renovate/* checks before too long - stability, confidence, automerge. So best if we learn to exclude them from counting

@geraintwhite
Copy link
Contributor

The trouble with having the stability status check is that using GitLab's "Pipelines must succeed" feature, it is possible to manually merge MRs prematurely as well as renovate automerging if using external pipelines like I described in #5743 (comment)

@rarkins
Copy link
Collaborator Author

rarkins commented Nov 24, 2020

The proposed solution would stop undesirable automerging. However we can't stop all undesirable manual behavior.

@geraintwhite
Copy link
Contributor

geraintwhite commented Nov 24, 2020

True, but removing the status check as @viceice suggested would prevent the manual merging in this case. Although based on your prediction of future status checks, excluding them from counting is the more sensible solution.

@rarkins
Copy link
Collaborator Author

rarkins commented Nov 24, 2020

Are either of you sure that's even possible? I only see adding and updating here: https://docs.gitlab.com/ee/api/commits.html#commit-status

@geraintwhite
Copy link
Contributor

@rarkins doesn't look like it so I guess that option is ruled out!

@rarkins
Copy link
Collaborator Author

rarkins commented Nov 24, 2020

Hopefully GitLab will support mandatory status checks soon

@geraintwhite
Copy link
Contributor

Could this be tied into https://github.com/renovatebot/renovate/issues/1853 (and the closed PR #4597)?

geraintwhite pushed a commit to geraintwhite/renovate that referenced this issue Dec 3, 2020
excludes renovate/* status checks when counting successfull checks

fixes renovatebot#7800
@rarkins rarkins added the status:in-progress Someone is working on implementation label Jan 12, 2021
@rarkins rarkins added status:blocked Issue is blocked by another issue or external requirement and removed status:in-progress Someone is working on implementation labels Oct 22, 2021
@rarkins

This comment was marked as outdated.

@philippe-granet
Copy link

@rarkins In Gitlab API: https://docs.gitlab.com/ee/api/commits.html#post-the-build-status-to-a-commit

|pipeline_id | integer | no | The ID of the pipeline to set status. Use in case of several pipeline on same SHA.
I think you should replace this:

await gitlabApi.postJson(url, { body: options });

by something like:

  • polling to retrieve pipeline id of branchSha, started less than x seconds
  • pass pipeline_id to commit status api

@rarkins rarkins added priority-2-high Bugs impacting wide number of users or very important features status:ready status:requirements Full requirements are not yet known, so implementation should not be started and removed priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others status:blocked Issue is blocked by another issue or external requirement status:ready labels May 28, 2022
@rarkins
Copy link
Collaborator Author

rarkins commented May 28, 2022

The main reason for this is for preventing automerge. There's probably some people who would like to use this still in prCreation=not-pending

@rarkins
Copy link
Collaborator Author

rarkins commented May 28, 2022

Today if someone has internalChecksFilter=strict, stabilityDays=x and automerge=true, then this can happen:

  • Branch created after x days
  • stabilityDays check set to green
  • PR created
  • PR automerged because the PR is green

If instead we say that to use prCreation=not-pending requires you to have your own tests (and not just rely on our stability days), then I think we can solve this as described.

@Gabriel-Ladzaretti
Copy link
Collaborator

Gabriel-Ladzaretti commented May 31, 2022

Is the stability test cross-platform or GitHub only?

@viceice
Copy link
Member

viceice commented May 31, 2022

cross platform

@viceice
Copy link
Member

viceice commented May 31, 2022

currently every platform handles status checks on its own. we should refactor it to return massaged status checks, like we do with PR / issues and handle all other in worker code. that way we can filter some status checks more easy

@rarkins
Copy link
Collaborator Author

rarkins commented May 31, 2022

I think we have it had an open issue to refactor status checks to the worker layer. I got a feeling I closed it recently, maybe thinking it was too hard in GitHub's case due to both status checks and check runs.

@nabeelsaabna
Copy link
Contributor

what about the new suggested approach ?

Suggested solution:
Use the stability days test as a failing check, this means we will never set the status to green, but we will set it to red when failing to prevent anyone from merging, and also indicate that this check failed (this is needed regardless IMHO).

@viceice
Copy link
Member

viceice commented Jun 1, 2022

what about the new suggested approach ?

Suggested solution:
Use the stability days test as a failing check, this means we will never set the status to green, but we will set it to red when failing to prevent anyone from merging, and also indicate that this check failed (this is needed regardless IMHO).

doesn't work, as it can't be deleted when it was red and should be green now. so we need to update it to green.

bigpopakap added a commit to projitect/renovate-config that referenced this issue Jun 19, 2022
This reverts commit 61d68fa.

I no longer think this was the problem with Renovate closing the PR too early
I think the problem was renovatebot/renovate#7800
@brennerm
Copy link

Can I somehow support in getting this issue fixed? We had a few cases were Renovate decided to automerge although our pipeline was pending or even failing.
We are using a self-hosted Gitlab and Renovate creates a pipeline containing the stability-days check only and automerges after it turns green.
image

@rarkins rarkins added status:requirements Full requirements are not yet known, so implementation should not be started and removed status:ready labels Dec 16, 2022
@rarkins
Copy link
Collaborator Author

rarkins commented Dec 16, 2022

The getBranchStatus() function in each platform determines whether a branch is considered green or not. Example for github: https://github.com/renovatebot/renovate/blob/main/lib/modules/platform/github/index.ts#L818

To close this issue, each platform's getBranchStatus() would need to exclude any passing renovate/ checks, although it only really matters if those are the only checks.

One possible problem - and why I just set this back to requirements - is that there may be users who have no tests but rely on something like stability days before automerging. Technically this change would be backwards incompatible for them, so we need to decide:

  • Change the default behavior, with no way to revert it, or
  • Change the default behavior, with a new config option to revert it, or
  • Keep default behavior, with a new config option to change to the desired functionality in this issue

I think the second option is probably best for Renovate users overall, because of the bad impact the current behavior can have on users. So therefore the plan would be:

  • Create new option internalChecksAsSuccess which defaults to false
  • This option is passed to getBranchStatus() and determines if renovate/* checks are counted as green
  • Needs to be supported in every platform which supports getBranchStatus()
  • Issue a major release for the change

If nobody has any strong objections to that, we can set this back to status:ready

@brennerm
Copy link

@rarkins Sounds great, would work for our use case.

@viceice viceice added status:ready and removed status:requirements Full requirements are not yet known, so implementation should not be started labels Dec 16, 2022
@XFNeo
Copy link

XFNeo commented Jan 9, 2023

Hi @rarkins ! When do you plan to release this feature?

@rarkins rarkins added the help wanted Help is needed or welcomed on this issue label Jan 9, 2023
@rarkins rarkins self-assigned this Feb 22, 2023
@rarkins rarkins added status:in-progress Someone is working on implementation and removed status:ready labels Feb 22, 2023
rarkins added a commit that referenced this issue Mar 10, 2023
Adds new config option `internalChecksAsSuccess`, defaulting to `false`.

Closes #7800

BREAKING CHANGE: Internal checks such as `renovate/stability-days` will no longer count as passing/green, meaning that actions such as `automerge` won't
occur if the only checks are Renovate internal ones. Set `internalChecksAsSuccess=true` to restore existing behavior.
@brennerm
Copy link

Thanks @rarkins for solving this issue. 🙏

@renovate-release
Copy link
Collaborator

🎉 This issue has been resolved in version 35.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@XFNeo
Copy link

XFNeo commented Mar 30, 2023

@rarkins Hi! It looks like this feature does not work. Bot still provides green pipeline for stasbility-days and merges such MRs.
Version 35.25.0

renovatebot_log.txt

Screenshot_295

@rarkins
Copy link
Collaborator Author

rarkins commented Mar 30, 2023

Please create a new Discussion (not issue) with reproduction and logs from a public gitlab.com repo to demonstrate

@renovatebot renovatebot locked and limited conversation to collaborators Mar 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Help is needed or welcomed on this issue priority-2-high Bugs impacting wide number of users or very important features status:in-progress Someone is working on implementation type:feature Feature (new functionality)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants