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

shifiting verify publishing bot from python to golang #118727

Conversation

sbdtu5498
Copy link

@sbdtu5498 sbdtu5498 commented Jun 17, 2023

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

@k8s-ci-robot
Copy link
Contributor

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.

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 17, 2023
@k8s-ci-robot
Copy link
Contributor

@sbdtu5498: The label(s) kind//sig, kind/release cannot be applied, because the repository doesn't have them.

In response to this:

What type of PR is this?

/kind feature /sig release

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

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.

@k8s-ci-robot k8s-ci-robot added do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jun 17, 2023
@k8s-ci-robot
Copy link
Contributor

Welcome @sbdtu5498!

It looks like this is your first PR to kubernetes/kubernetes 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kubernetes has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jun 17, 2023
@k8s-ci-robot
Copy link
Contributor

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

@k8s-ci-robot k8s-ci-robot added the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Jun 17, 2023
@k8s-ci-robot k8s-ci-robot requested review from hwdef and thockin June 17, 2023 16:25
@sbdtu5498 sbdtu5498 force-pushed the shifting-verify-publishing-bot-to-go branch from a6fc770 to 2b1ffbd Compare June 17, 2023 16:40
Signed-off-by: Sanskar Bhushan <sbdtu5498@gmail.com>
@sbdtu5498 sbdtu5498 force-pushed the shifting-verify-publishing-bot-to-go branch from 2b1ffbd to 551569c Compare June 17, 2023 16:53
Copy link
Member

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.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: sbdtu5498
Once this PR has been reviewed and has the lgtm label, please assign thockin for approval. For more information see the Kubernetes Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@palnabarun
Copy link
Member

/sig release
/priority important-longterm
/triage accepted

@k8s-ci-robot k8s-ci-robot added sig/release Categorizes an issue or PR as relevant to SIG Release. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. labels Aug 16, 2023
@palnabarun
Copy link
Member

/release-note none

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Aug 16, 2023
@palnabarun
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 16, 2023
@k8s-ci-robot
Copy link
Contributor

@sbdtu5498: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubernetes-verify 551569c link true /test pull-kubernetes-verify

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
Copy link
Member

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

Copy link
Member

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
Copy link
Member

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.

Copy link
Member

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"
Copy link
Member

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
Copy link
Member

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{})
Copy link
Member

Choose a reason for hiding this comment

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

lines := strings.Split(string(content), "\n")
uniqueLines := make(map[string]bool)
for _, line := range lines {
uniqueLines[line] = true
Copy link
Member

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 ?

Comment on lines +125 to +129
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{})
Copy link
Member

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{})

Copy link
Member

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)
Copy link
Member

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

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 5, 2023
@k8s-ci-robot
Copy link
Contributor

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.

@akhilerm
Copy link
Member

akhilerm commented Oct 6, 2023

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?

@sbdtu5498
Copy link
Author

I will take a look on them in the weekends

@dims dims added the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Oct 24, 2023
@k8s-triage-robot
Copy link

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:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Reopen this PR with /reopen
  • Mark this PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

@k8s-ci-robot
Copy link
Contributor

@k8s-triage-robot: Closed this PR.

In response to this:

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:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Reopen this PR with /reopen
  • Mark this PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

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.

@akhilerm
Copy link
Member

akhilerm commented Feb 8, 2024

@sbdtu5498 Will you be able to take this up further ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. kind/feature Categorizes issue or PR as related to a new feature. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. sig/release Categorizes an issue or PR as relevant to SIG Release. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rewrite verify-publishing-bot.py in go
7 participants