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

Reimplement the add-pr-body interceptor as a ClusterInterceptor #967

Merged
merged 1 commit into from
Apr 28, 2022

Conversation

dibyom
Copy link
Member

@dibyom dibyom commented Dec 15, 2021

Changes

This commit adds a cluster interceptor flavor of the add pr body interceptor.
The old webhook interceptor has been left untouched.

BREAKING: For the ClusterInterceptor flavor, the PR url input has to now come
in via the request.extensions field instead of the old request.body field.
Similarly, the output pr-body is part of the extensions field instead of being
merged back into the body.

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

See the contribution guide
for more details.

@tekton-robot tekton-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 15, 2021
@tekton-robot tekton-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Dec 15, 2021
@afrittoli
Copy link
Member

/kind feature

@tekton-robot tekton-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Dec 15, 2021
afrittoli added a commit to afrittoli/plumbing that referenced this pull request Dec 15, 2021
Old style interceptors won't work with trigger groups.
Until tektoncd#967 is merged,
leave the add-pr-body interceptor out of the trigger group.

Signed-off-by: Andrea Frittoli <andrea.frittoli@uk.ibm.com>
afrittoli added a commit to afrittoli/plumbing that referenced this pull request Dec 16, 2021
Old style interceptors won't work with trigger groups.
Until tektoncd#967 is merged,
leave the add-pr-body interceptor out of the trigger group.

Signed-off-by: Andrea Frittoli <andrea.frittoli@uk.ibm.com>
tekton-robot pushed a commit that referenced this pull request Dec 16, 2021
Old style interceptors won't work with trigger groups.
Until #967 is merged,
leave the add-pr-body interceptor out of the trigger group.

Signed-off-by: Andrea Frittoli <andrea.frittoli@uk.ibm.com>
@afrittoli
Copy link
Member

Hi @dibyom, thank you for starting this! Are you still working on it? I could try and pick up your PR if you don't have time to work on it anymore. Thank you!

@dibyom
Copy link
Member Author

dibyom commented Feb 10, 2022

Hi @dibyom, thank you for starting this! Are you still working on it? I could try and pick up your PR if you don't have time to work on it anymore. Thank you!

hey @afrittoli almost done, just need to test + update the docs. I'll update this PR in the next couple of days.

@afrittoli
Copy link
Member

/test plumbing-yamllint

@afrittoli
Copy link
Member

@dibyom Any update on this one? Anything I can do to help?

@dibyom dibyom marked this pull request as ready for review March 31, 2022 19:09
@tekton-robot tekton-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 31, 2022
@dibyom
Copy link
Member Author

dibyom commented Mar 31, 2022

Any update on this one? Anything I can do to help?

@afrittoli Sorry for the major delay. Should be ready for a look now 🙏

Copy link
Member

@afrittoli afrittoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. I a couple of comments on the docs but mostly looks great!
The existing interceptor has nightly builds, and I wonder if we should replace it with the new one instead of having two in the same folder, which will make the nightly builds harder to manage. Alternatively we could have two separate folders... wdyt?

Comment on lines 53 to 62
interceptors:
- cel:
filter: >- // TODO: This can be part of the interceptor itself
body.action == 'created' &&
in('pull_request', body.issue) &&
&& body.issue.state == 'open' &&
body.comment.body.matches('^/test($| [^ ]*$)')
overlays:
- key: add-pr-body.pull-request-url
expression: "body.issue.pull_request.url"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the new syntax looks something like:

      interceptors:
        - name: "Filter the GitHub org and actions and add git_clone_depth"
          ref:
            name: "cel"

Should the add-pr-body interceptor be used in this example?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, it should :)

@dibyom
Copy link
Member Author

dibyom commented Apr 1, 2022

Thanks, I think I'm going to move this to a separate folder then to make it easier.

@dibyom dibyom force-pushed the addprbody branch 2 times, most recently from b0ab941 to 5ad1b8d Compare April 4, 2022 18:33
This commit adds a cluster interceptor flavor of the add pr body interceptor.
The old webhook interceptor has been left untouched.

BREAKING: For the ClusterInterceptor flavor, the PR url input has to now come
in via the `request.extensions ` field instead of the old `request.body` field.
Similarly, the output pr-body is part of the extensions field instead of being
merged back into the body.

Signed-off-by: Dibyo Mukherjee <dibyo@google.com>
@dibyom
Copy link
Member Author

dibyom commented Apr 5, 2022

@afrittoli I updated the PR. I also added a couple of TODOs around making this easier to use. Also, we could potentially merge this code with the packaged GitHub interceptor tektoncd/triggers#1339

Copy link
Member

@afrittoli afrittoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @dibyom for this!
I really like the idea to embed this as opt-in in the cluster interceptor.

If no-one does that before I will start testing this on dogfooding once I'm back from PTO.
I will try to repeat the process for the other interceptor as well - and for that one too I wonder if that's something we could get into core interceptors as well, as it's a pretty common use case to filter based on the owner of the PR.

Copy link
Member

@afrittoli afrittoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

@tekton-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: afrittoli

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

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 6, 2022
@afrittoli
Copy link
Member

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 28, 2022
@tekton-robot tekton-robot merged commit 3307bff into tektoncd:main Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants