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

Port docs-no-retest from munge to prow #4895

Merged
merged 2 commits into from
Oct 9, 2017

Conversation

paradigm
Copy link
Contributor

@paradigm paradigm commented Oct 5, 2017

From what I understand, there is an effort to move from munge to prow for github integration. This ports munge's docs-no-retest functionality to prow. It also adds test coverage, as munge's docs-no-retest was not tested.

/cc @Kargakis @stevekuznetsov
/assign @Kargakis

@paradigm paradigm requested a review from cjwagner as a code owner October 5, 2017 20:00
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 5, 2017
@k8s-ci-robot
Copy link
Contributor

Hi @paradigm. Thanks for your PR.

I'm waiting for a kubernetes 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.

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 kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Oct 5, 2017
@BenTheElder
Copy link
Member

Awesome!
/assign @cjwagner
/ok-to-test
/area prow
/area mungegithub

@k8s-ci-robot k8s-ci-robot added area/prow Issues or PRs related to prow area/mungegithub and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 5, 2017
)

var (
docFilesRegex = regexp.MustCompile("^.*\\.(md|png|svg|dia)$")
Copy link
Member

Choose a reason for hiding this comment

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

Using back ticks instead of quotes for regexps will avoid the need to double escape. `^.*\.(md|png|svg|dia)$`

GetPullRequestChanges(org, repo string, number int) ([]github.PullRequestChange, error)
}

func handlePR(gc githubClient, pe github.PullRequestEvent) error {
Copy link
Member

Choose a reason for hiding this comment

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

This function should start by checking that the event's Action is opened, reopened, or synchronized, and return early if not.


if docsOnly && !hasTargetLabel {
if err := gc.AddLabel(owner, repo, num, labelSkipRetest); err != nil {
return fmt.Errorf("error adding label to %s/%s PR #%d: %v", owner, repo, num, err)
Copy link
Member

Choose a reason for hiding this comment

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

The convention Prow uses for referencing github issues is fmt.Sprintf("%s/%s#%d", owner, repo, num)

Filename: "/path/to/file/foo.go",
},
},
getIssueLabelsErr: testError,
Copy link
Member

Choose a reason for hiding this comment

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

s/getIssueLabelsErr/getPullRequestChangesErr/


type ghc struct {
*testing.T
labels map[github.Label]bool
Copy link
Member

Choose a reason for hiding this comment

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

Just store the label name instead of the entire Label struct since the Color and ID fields are ignored.

@paradigm paradigm force-pushed the docs-no-retest-munge-to-prow branch from 4af474f to ba38c7d Compare October 6, 2017 17:28
@paradigm
Copy link
Contributor Author

paradigm commented Oct 6, 2017

All those changes made sense to me, applied here.

num = pe.PullRequest.Number
)

switch pe.Action {
Copy link
Contributor

Choose a reason for hiding this comment

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

Generally more idiomatic golang to do this with an if statement like here

c.T.Logf("RemoveLabel: %s", targetLabel)
for label := range c.labels {
if label == targetLabel {
delete(c.labels, label)
Copy link
Contributor

Choose a reason for hiding this comment

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

You're doing a deletion here so you don't really need the bool, can just use map[string]interface{} (the k8s set.String utility)

@paradigm paradigm force-pushed the docs-no-retest-munge-to-prow branch from ba38c7d to ee12b73 Compare October 6, 2017 18:22
@cjwagner
Copy link
Member

cjwagner commented Oct 6, 2017

The configs need to be updated as well.
Please remove docs-need-no-retest from the kubernetes misc-mungers config and also add the docs-no-retest plugin to the kubernetes/kubernetes repo in plugins.yaml.

This will also require a hook bump. Please run ./bump.sh hook from the prow directory and commit the changes to a new commit.

@stevekuznetsov
Copy link
Contributor

@paradigm paradigm force-pushed the docs-no-retest-munge-to-prow branch from ee12b73 to bfbe1f9 Compare October 6, 2017 20:27
@cjwagner
Copy link
Member

cjwagner commented Oct 6, 2017

Looks like you need to rebase before running ./bump.sh hook.

@paradigm paradigm force-pushed the docs-no-retest-munge-to-prow branch from bfbe1f9 to dd2fb44 Compare October 6, 2017 20:35
@cjwagner
Copy link
Member

cjwagner commented Oct 6, 2017

@paradigm paradigm force-pushed the docs-no-retest-munge-to-prow branch from dd2fb44 to 87a33a9 Compare October 6, 2017 20:59
err := handlePR(client, event)

if err != nil && c.err == nil {
t.Errorf("test case \"%s\": unexpected handlePR error: %v", c.name, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: you can use %q instead of "%s"

@0xmichalis
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 9, 2017
@@ -51,6 +51,7 @@ plugins:
kubernetes/kubernetes:
- trigger
- release-note
- docs-no-retest
Copy link
Contributor

Choose a reason for hiding this comment

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

@cjwagner I am sure you already know that this will require you to redeploy instantly.

Copy link
Member

Choose a reason for hiding this comment

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

Yep, I'll merge and redeploy Prow and the kubernetes misc-mungers deployment now.
/approve

@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cjwagner, kargakis, paradigm

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

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 9, 2017
@cjwagner cjwagner merged commit 98eec4a into kubernetes:master Oct 9, 2017
@k8s-ci-robot
Copy link
Contributor

@paradigm: I updated Prow plugins config for you!

In response to this:

From what I understand, there is an effort to move from munge to prow for github integration. This ports munge's docs-no-retest functionality to prow. It also adds test coverage, as munge's docs-no-retest was not tested.

/cc @Kargakis @stevekuznetsov
/assign @Kargakis

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 kubernetes/test-infra repository.

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. area/prow Issues or PRs related to prow cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants