Skip to content

Conversation

@sanya301
Copy link
Contributor

Fixes #1891

Adds a script that iterates through all .go and .sh files and checks if a license exists in the first 4 lines. Similar script to the SDK https://github.com/operator-framework/operator-sdk/blob/master/hack/check-license.sh with some changes.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Dec 17, 2021
@k8s-ci-robot
Copy link
Contributor

Welcome @sanya301!

It looks like this is your first PR to kubernetes-sigs/kubebuilder 🎉. 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-sigs/kubebuilder 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 Dec 17, 2021
@k8s-ci-robot
Copy link
Contributor

Hi @sanya301. Thanks for your PR.

I'm waiting for a kubernetes-sigs 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 size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Dec 17, 2021
@sanya301
Copy link
Contributor Author

The script currently leads to the following files failing the check. @camilamacedo86 let me know if you would like to exclude certain folders from the check, or if we need to add licenses to below.

github.com/kubernetes-sigs/kubebuilder/docs/book/src/cronjob-tutorial/testdata/project/controllers/cronjob_controller_test.go
github.com/kubernetes-sigs/kubebuilder/docs/book/src/cronjob-tutorial/testdata/project/controllers/suite_test.go
github.com/kubernetes-sigs/kubebuilder/pkg/plugins/golang/v3/scaffolds/internal/templates/api/webhook_suitetest.go
github.com/kubernetes-sigs/kubebuilder/pkg/plugins/golang/v3/scaffolds/internal/templates/api/webhook_suitetest.go
github.com/kubernetes-sigs/kubebuilder/pkg/plugins/golang/v3/scaffolds/internal/templates/api/webhook_suitetest.go
github.com/kubernetes-sigs/kubebuilder/pkg/plugins/golang/v3/scaffolds/internal/templates/api/webhook_suitetest.go
github.com/kubernetes-sigs/kubebuilder/pkg/plugins/golang/v3/scaffolds/internal/templates/api/webhook_suitetest.go
github.com/kubernetes-sigs/kubebuilder/pkg/plugins/golang/v3/scaffolds/internal/templates/api/webhook_suitetest.go
github.com/kubernetes-sigs/kubebuilder/pkg/plugins/golang/v3/scaffolds/internal/templates/api/webhook_suitetest.go

@estroz
Copy link
Contributor

estroz commented Dec 21, 2021

@sanya301 yes those files need licenses. Thanks!

/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 Dec 21, 2021
@sanya301
Copy link
Contributor Author

Thanks @estroz! Should I just add the same license as this for the suite test files that don't have them? https://github.com/kubernetes-sigs/kubebuilder/blob/master/pkg/plugins/golang/v3/scaffolds/internal/templates/api/group.go#L1

@estroz
Copy link
Contributor

estroz commented Dec 22, 2021

Yes, with the current year.

Copy link
Member

@camilamacedo86 camilamacedo86 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 your contribution.
Just a few nits are missing for we get this one merged.
a) See that the mojo is not right. It is not a breaking change for any kb user. Could you please update it with Infra/Tests/Other: 🌱 (:seedling:)
b) Could you please give space at the end of the files?
c) Also, we must ensure that the PR pass in the CI. That means that we need to add here the header/license for all missing cases.


.PHONY: test
test: test-unit test-integration test-testdata test-book ## Run the unit and integration tests (used in the CI)
test: test-unit test-integration test-testdata test-book test-license ## Run the unit and integration tests (used in the CI)
Copy link
Member

Choose a reason for hiding this comment

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

Could we have a GA /ci job new only for this one to make it easier for us to know when/if fails?
I mean, i new target + GitHub actions?

Copy link
Contributor Author

@sanya301 sanya301 Jan 28, 2022

Choose a reason for hiding this comment

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

So do you want a Github actions in addition to the script? I thought we wanted one or the other, otherwise it would be repetitive. It didn't seem like a lot of people were using the github action so I decided to go with the script

Copy link
Member

Choose a reason for hiding this comment

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

The suggestion would be to call this one only in a GA that does this check.
Not call the test twice at all. That would mean not adding test-license in this target also.

The reason would be to make it easier for contributors to check why/what is falling in the ci.
However, that is just nit. It is passing on the tests now so I am ok with too.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 28, 2022
@sanya301 sanya301 changed the title ⚠ Script for checking licenses 🌱 Script for checking licenses Jan 28, 2022
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 28, 2022
Copy link
Member

@camilamacedo86 camilamacedo86 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 the contribution 🥇
For we get this one merged, could you please just squash the commits?

/approved

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: camilamacedo86, sanya301

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 30, 2022
@camilamacedo86 camilamacedo86 changed the title 🌱 Script for checking licenses 🌱 Add script for checking licenses Jan 30, 2022
@camilamacedo86
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 31, 2022
@k8s-ci-robot k8s-ci-robot merged commit da74a51 into kubernetes-sigs:master Jan 31, 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. 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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add check to ensure that any new file has the license in the header

4 participants