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

Add GitHub status updates to Pull Request CRD. #995

Merged
merged 1 commit into from
Jul 3, 2019

Conversation

wlynch
Copy link
Member

@wlynch wlynch commented Jun 20, 2019

This adds support for the GitHub Status API
(https://developer.github.com/v3/repos/statuses/).

This accompanies #778 and #895 to complete initial Pull Request support
support for GitHub OAuth.

Changes

Adds GitHub status fetching and updates to Pull Request CRD.

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.

Release Notes

Adds GitHub status fetching and updates to Pull Request CRD.

@googlebot googlebot added the cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit label Jun 20, 2019
@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 20, 2019
@wlynch
Copy link
Member Author

wlynch commented Jun 25, 2019

/retest

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

Looks good to me, question though : right now it's up to the user to write github status or not right (with this PR) ? Do we envision some "automation" around that ?

@wlynch
Copy link
Member Author

wlynch commented Jun 25, 2019

Looks good to me, question though : right now it's up to the user to write github status or not right (with this PR) ? Do we envision some "automation" around that ?

Yup! Great question, I'd love to source more ideas around this. The straight-forward answer would be to provide a runner binary that would wrap test execution and transform status codes and stdout/stderr to the pull request object.

Is there any work being done around passing state between TaskRuns (e.g. for conditional execution or something similar)?

@vdemeester
Copy link
Member

@wlynch yeah we need to think about that, as I think I remember talking about notification as a first-class citizen in Tekton maybe ? (and most likely write on a design docs).

Is there any work being done around passing state between TaskRuns (e.g. for conditional execution or something similar)?

@dibyom ^^ 👼

@dibyom
Copy link
Member

dibyom commented Jun 25, 2019

@wlynch yes, the condition container will have access to some read only metadata. Right now, this is just the pipeline run including the status fields. We could expose this to task runs as well? Or do you need to write additional metadata that needs to be exposed?

@wlynch
Copy link
Member Author

wlynch commented Jun 25, 2019

@dibyom Don't need to write more data, but it would be useful to expose it to TaskRuns to have a binary look for this information and automatically prep PR output as a response. Can you link me to that data and how TaskRuns can access it?

@dlorenc
Copy link
Contributor

dlorenc commented Jun 26, 2019

@wlynch yeah we need to think about that, as I think I remember talking about notification as a first-class citizen in Tekton maybe ? (and most likely write on a design docs).

Yeah, I think the automated use-cases for this would fit into something around either "notification" or "conditional execution".

With the conditional execution approach, a pipeline would have a Task that runs on either success or failure and writes the status to Github/Gitlab.

@afrittoli
Copy link
Member

Yeah, I think the automated use-cases for this would fit into something around either "notification" or "conditional execution".

This could be implemented with the CloudEventPipelineResource as well.
The setup would be:

  • each task that needs to publish test results to the PR has an output resource of type cloudevent, which is sent to a dedicated tekton listener. The TaskRun, including status, is sent as body of the cloudevent.
  • an event binding is defined that accepts TaskRun completion events, and triggers a GitHub PR update Task(Run)
  • The GitHub PR update taskrun uses the PullRequest resource as input and output, and the metadata in the TaskRun (passed as parameter to the Task) to update GitHub

The advantages of using a separate Task/TaskRun are:

  • The status of the original Task is not affected by the outcome of the PR update
  • It doesn't require conditional execution
  • The Task that updates GitHub PRs can be as isolated as we want from the Task that runs the tests, which should make it easier to avoid leaking the GitHub token in logs.

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.

Thank you for this, nice work!

I tried out the code and integrated it in the demo I did last week and it works nicely.

ActionRequired StatusCode = "action_required"
)

// TODO: Add getters to make types nil-safe.
Copy link
Member

Choose a reason for hiding this comment

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

Are you planning this for a follow-up PR?

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! Didn't want to include this in this change since it's going to be a lot of boilerplate 😭

Copy link
Member Author

Choose a reason for hiding this comment

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

cmd/pullrequest-init/github_test.go Show resolved Hide resolved
@afrittoli
Copy link
Member

/retest

@dibyom
Copy link
Member

dibyom commented Jun 26, 2019

@dibyom Don't need to write more data, but it would be useful to expose it to TaskRuns to have a binary look for this information and automatically prep PR output as a response. Can you link me to that data and how TaskRuns can access it?

WIP but its a file (pr-metadata.json) in /workspace for condition containers (sample)

Its exposed to conditional pods at the moment and not regular taskruns. I opened #1016 to track that.

@wlynch
Copy link
Member Author

wlynch commented Jun 26, 2019

/assign @imjasonh

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 26, 2019
@dlorenc
Copy link
Contributor

dlorenc commented Jun 26, 2019

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 26, 2019
@dlorenc
Copy link
Contributor

dlorenc commented Jun 26, 2019

/approve

@wlynch
Copy link
Member Author

wlynch commented Jul 2, 2019

/retest

Copy link
Member

@dibyom dibyom left a comment

Choose a reason for hiding this comment

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

There is a binary checked in cmd/pullrequest-init/pullrequest-init. Is that intentional?

@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Jul 2, 2019
@wlynch
Copy link
Member Author

wlynch commented Jul 2, 2019

There is a binary checked in cmd/pullrequest-init/pullrequest-init. Is that intentional?

Good catch! Removed.

@wlynch wlynch closed this Jul 2, 2019
@wlynch wlynch reopened this Jul 2, 2019
This adds support for the GitHub Status API
(https://developer.github.com/v3/repos/statuses/).

This accompanies tektoncd#778 and tektoncd#895 to complete initial Pull Request support
support for GitHub OAuth.
Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 3, 2019
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: afrittoli, dlorenc, vdemeester, wlynch

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 merged commit 260c227 into tektoncd:master Jul 3, 2019
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. cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants