-
Notifications
You must be signed in to change notification settings - Fork 40k
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
shifiting verify publishing bot from python to golang #118727
shifiting verify publishing bot from python to golang #118727
Conversation
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. 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. |
@sbdtu5498: The label(s) In response to this:
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. |
Welcome @sbdtu5498! |
Hi @sbdtu5498. 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 Once the patch is verified, the new status will be reflected by the 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. |
a6fc770
to
2b1ffbd
Compare
Signed-off-by: Sanskar Bhushan <sbdtu5498@gmail.com>
2b1ffbd
to
551569c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A general comment on this. Instead of type casting and using map[interface{}]interface{}
, you can use the types from https://github.com/kubernetes/publishing-bot/blob/master/cmd/publishing-bot/config/rules.go which define the rules.yaml config.
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: sbdtu5498 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/sig release |
/release-note none |
/ok-to-test |
@sbdtu5498: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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. |
ret=0 | ||
run-checks "${KUBE_ROOT}/hack/verify-*.sh" bash | ||
run-checks "${KUBE_ROOT}/hack/verify-*.py" python3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will still be required as there is another verify script in python. https://github.com/kubernetes/kubernetes/blob/master/hack/verify-flags-underscore.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And that script is fine because it doesn't have non-stdlib dependencies
ret=0 | ||
run-checks "${KUBE_ROOT}/hack/verify-*.sh" bash | ||
run-checks "${KUBE_ROOT}/hack/verify-*.py" python3 | ||
run-checks "${KUBE_ROOT}/hack/tools/verify/verify-publishing-bot" binary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of directly calling the binary, can we have a thin shell script that wraps the go run verify-publishing-bot.go
along with setting up the go envs needed as mentioned here. That shell script can be invoked here using bash
runner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, we should have a verify-publishing-bot.sh
that handles the usual go env setup etc and can be invoked directly without using verify.sh
missing-target-checks | ||
|
||
# cleaning up the go binary once the execution is done | ||
rm "${KUBE_ROOT}/hack/tools/verify/verify-publishing-bot" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of go run verify-publishing-bot.go
instead of building the binary and running it.
@@ -1 +1,2 @@ | |||
/vendor/ | |||
verify/verify-publishing-bot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may not be needed as we are not committing during the verify stage
} | ||
|
||
func getRulesDependencies(rulesFile string) map[string]interface{} { | ||
data := make(map[string]interface{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/kubernetes/publishing-bot/blob/master/cmd/publishing-bot/config/rules.go#L78 can be used for parsing as suggested above.
lines := strings.Split(string(content), "\n") | ||
uniqueLines := make(map[string]bool) | ||
for _, line := range lines { | ||
uniqueLines[line] = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need uniqueLines
?
for _, rule := range rulesDependencies["rules"].([]interface{}) { | ||
ruleData := rule.(map[interface{}]interface{}) | ||
destination := ruleData["destination"].(string) | ||
branches := ruleData["branches"].([]interface{}) | ||
branch := branches[0].(map[interface{}]interface{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be simplified by using the RepositoryRules
struct mentioned above.
destination := ruleData["destination"].(string) | ||
branches := ruleData["branches"].([]interface{}) | ||
branch := branches[0].(map[interface{}]interface{}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment why we need this check
|
||
for _, b := range branches { | ||
branchData := b.(map[interface{}]interface{}) | ||
sourceDir := branchData["source"].(map[interface{}]interface{})["dir"].(string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dir field has been deprecated in favour of dirs. That change also have to be accomodated. Ref: kubernetes/publishing-bot#337
PR needs rebase. 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. |
There are changes in the verify script that has been introduced as part of #120822. Can you please take care of that also in this PR? |
I will take a look on them in the weekends |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /close |
@k8s-triage-robot: Closed this PR. In response to this:
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. |
@sbdtu5498 Will you be able to take this up further ? |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Currently make verify has a script called verify-publishing-bot.py that relies on an external dependency that needs to be downloaded by the end user. This PR replaces verify-publishing-bot.py with verify-publishing-bot.go which eases dependency management.
Which issue(s) this PR fixes:
Fixes kubernetes/publishing-bot#345
Does this PR introduce a user-facing change?
None
cc: @BenTheElder