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: allow to skip draft prs unless ready for review or /ok-to-test is added #1593

Merged

Conversation

JordanGoasdoue
Copy link
Contributor

@JordanGoasdoue JordanGoasdoue commented Jan 31, 2024

related to #1476 && #886

⚠️ Once this PR merged we will need to

Context:

  • We can't add label when opening a PR so we can only Draft a PR to disable the trigger of pipelines in case we need massive batch opening of PRs in 100+ repositories for instance .
  • Then we can activate manually the pipelines by clicking on 'Ready for Review' or commenting /ok-to-test from a trusted member

How to enable this feature ?
Add skip_draft_pr feature on the Trigger Plug-in from you scheduler:

  • setup skip_draft_pr in scheduler trigger like only_org_members to allow easy migration of multiple team-app repositories in one time (Would be automatically applied to all repositories using the scheduler with this trigger.skip_draft_pr set to true)
  • jx gitops scheduler would need to be run then from your bootjob to edit the plugin configmap

How it works ?

  • trigger pipelines in a Draft PR if skip_draft_pr is false depending if trusted or not (by default)

  • trigger pipelines in a Draft PR if skip_draft_pr is true with ok-to-test label

  • doesn't trigger pipelines in a Draft PR if skip_draft_pr is true but without ok-to-test label

  • trigger pipelines when you click on ready for review if trusted and you don't have the ok-to-test label to avoid triggering the same pipelines than in previous draft mode before clicking the ready for review button

  • doesn't trigger pipelines when you click on convert to draft even if you have the ok-to-test label to avoid triggering the same pipelines than in previous non draft mode before clicking the convert to draft button

Why this feature ?

  • keep costs low when developers don't want to run builds
  • Interesting when we need to open multiple Draft PRs in repositories using Jx without wanting to trigger all the repositories pipelines in same time

👇 👇 👇 👇
I have commented each testing scenarios in pkg/plugins/trigger/pull-request_test.go with the following PR Actions:

  • prAction: scm.ActionReadyForReview
  • prAction: scm.ActionConvertedToDraft

to explain the logic behind when we click the "Ready for Review" or "Convert to Draft" button.
I wanted here to avoid useless rerun of pipelines between both these modes.

go test ./pkg/plugins/trigger/ 
ok      github.com/jenkins-x/lighthouse/pkg/plugins/trigger     0.028s

☝️ ☝️ ☝️ ☝️

@jenkins-x-bot
Copy link
Contributor

Hi @JordanGoasdoue. Thanks for your PR.

I'm waiting for a jenkins-x member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the jenkins-x/lighthouse repository.

pkg/plugins/trigger/pull-request.go Outdated Show resolved Hide resolved
@tomhobson
Copy link
Member

/ok-to-test
/lgtm

Thanks for the PR!

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1593]: [Method Not Allowed]

17 similar comments
@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1593]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1593]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1593]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1593]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1593]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1593]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1593]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1593]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1593]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1593]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1593]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1593]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1593]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1593]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1593]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1593]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1593]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: tomhobson

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@jenkins-x-bot jenkins-x-bot merged commit 552e99c into jenkins-x:main Feb 7, 2024
4 checks passed
@JordanGoasdoue JordanGoasdoue deleted the feat-allow-skip-draft-prs branch February 7, 2024 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants