-
Notifications
You must be signed in to change notification settings - Fork 389
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 license automatically #3122
Conversation
@bangqipropel add necessary info to make your commit and PR summary clear. and link it to the right issue. thanks. |
14f9a10
to
f55dbad
Compare
@luolanzone Hi, I see, but it seems like the "Linked issues", "Assignees" or something like that is not editable for me, seems like no permission for me, for the antrea main fork, you have any idea whom I should ask the permission for? |
@bangqipropel , you don't need such permission, please update the description to link the issue, you can take a look at this help doc: https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword |
d6d9b72
to
2c88847
Compare
Codecov Report
@@ Coverage Diff @@
## main #3122 +/- ##
===========================================
- Coverage 59.08% 47.02% -12.07%
===========================================
Files 331 397 +66
Lines 28444 42069 +13625
===========================================
+ Hits 16806 19781 +2975
- Misses 9804 20134 +10330
- Partials 1834 2154 +320
Flags with carried forward coverage won't be shown. Click here to find out more.
|
2c88847
to
86be0df
Compare
Makefile
Outdated
$(CURDIR)/hack/add-license.sh | ||
else | ||
@echo "===> Adding License for files <===" | ||
$(CURDIR)/hack/add-license.sh --add |
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.
I feel it's unecessary to add add-license.sh
, Could you just add the CLI here? we can already tell if it's check
or add
action in Makefile.
.github/workflows/go.yml
Outdated
@@ -84,6 +84,8 @@ jobs: | |||
- name: Run golangci-lint for netpol | |||
working-directory: hack/netpol | |||
run: make golangci | |||
- name: Check copyright | |||
run: ./ci/check-copyright.sh |
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 should be a make target, not a shell script.
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.
@luolanzone I think we need a check step here? So we just need a shell script to generate git diff and return some err message like manifest? And we just check this in one step, so we don't need two shell scripts within one make target like test-tidy?
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.
I didn't mean there is unnecessary for check step, I mean you can add a check target in Makefile instead of a separate shell file considering you only have one parameter to determine if it's check or not. I personally think it would be simpler if it's just a few lines.
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.
I don't think a Makefile target is strictly necessary (we don't have one for codegen, manifests). However I don't know why the CI step is part of the golangci-lint
job and not part of the tidy-codegen-manifest
job.
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.
yes, I talked with bangqi offline, after check the codes, I feel it's OK to keep them in a shell script.
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.
will move to the tidy-codegen-manifest
, I think this job makes more sense
f9e5f48
to
fb5ddfc
Compare
9878a9e
to
34a67c9
Compare
.github/workflows/go.yml
Outdated
@@ -84,6 +84,8 @@ jobs: | |||
- name: Run golangci-lint for netpol | |||
working-directory: hack/netpol | |||
run: make golangci | |||
- name: Check copyright | |||
run: ./ci/check-copyright.sh |
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.
I didn't mean there is unnecessary for check step, I mean you can add a check target in Makefile instead of a separate shell file considering you only have one parameter to determine if it's check or not. I personally think it would be simpler if it's just a few lines.
34a67c9
to
4bcb0da
Compare
4bcb0da
to
6d9d741
Compare
6d9d741
to
b9cdf2e
Compare
.github/workflows/go.yml
Outdated
@@ -84,6 +84,8 @@ jobs: | |||
- name: Run golangci-lint for netpol | |||
working-directory: hack/netpol | |||
run: make golangci | |||
- name: Check copyright | |||
run: ./ci/check-copyright.sh |
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.
I don't think a Makefile target is strictly necessary (we don't have one for codegen, manifests). However I don't know why the CI step is part of the golangci-lint
job and not part of the tidy-codegen-manifest
job.
Makefile
Outdated
add-copyright: | ||
@echo "==> Installing addlicense <==" | ||
@$(GO) install github.com/google/addlicense@latest | ||
ifeq ($(check), 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.
I don't think this is very user-friendly (having to define the check variable)
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.
maybe we can define two targets, one is check-copyright
, one is add-copyright
? or @bangqipropel can change back to original code which was using check-copyright --add
to add copy right, then developer can use check-copyright
for checking only.
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.
I think check-copyright
and add-copyright
is better one, for now.
I think the key is here: we don't want to set var by the format "XX=YY" but the format "--XX" in the make command, but dealing with arg with dash is complicated in Makefile command, (like here). It will make the code much more complicated or let the command as make add-copyright -- --check
, two double-dash also seems like unfriendly to user, either.
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.
I am OK to add two targets.
a6d6387
to
144d8d6
Compare
changed |
d1cfbec
to
4d68a96
Compare
Makefile
Outdated
@echo "==> Installing addlicense <==" | ||
@GO=$(GO) $(CURDIR)/hack/add-license.sh | ||
|
||
.PHONY: add-copyright | ||
add-copyright: | ||
@echo "==> Installing addlicense <==" |
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.
I don't think the "Installing addlicense" is necessary or even makes sense here
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.
moved to the shell script before the "go install" line
hack/add-license.sh
Outdated
else | ||
echo "===> Checking License for files <===" | ||
addlicense -c "Antrea Authors." -check `find . -type f -name "*.go"` `find . -type f -name "*.sh"` | ||
echo "Have checked out files without copyright, if you want to add them, please run 'make add-copyright'" |
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.
If the previous command fails the script exists immediately and the message is never printed, so it's not right
you can do something like this if you want
rc=0
addlicense -c "Antrea Authors." -check `find . -type f -name "*.go"` `find . -type f -name "*.sh"` || rc=1
if [[ $rc -ne 0 ]]; then
echo "Some files do not have a correct copyright"
exit $rc
fi
or you can omit the message altogether. The current message ("if you want to add them, please run 'make add-copyright'") is not ideal in my opinion because there is no reason to refer to a make target from this script.
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.
removed the message
4d68a96
to
6ea168f
Compare
/skip-all |
@bangqipropel Could you help to resolve the conflicts? thanks. |
17bd71f
to
b6fb678
Compare
Hi @antoninbas @tnqn Could you help to review this issue again, @bangqipropel has fixed the code conflicts. thanks. |
/skip-all |
I approved bu looks like the CI checks are not running correctly. You may need to close and re-open the PR? |
|
.github/workflows/go.yml
Outdated
@@ -164,6 +164,8 @@ jobs: | |||
run: ./ci/check-codegen.sh | |||
- name: Check manifest | |||
run: ./ci/check-manifest.sh | |||
- name: Check copyright | |||
run: ./ci/check-copyright.sh |
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.
I notice that there is a formatting issue here. Could it be why the CI jobs are not running for your PR (I notice that the jobs not running are the ones defined in this file)?
Most Jenkins jobs a re marked as failed when they do not run. |
1. add make check-copyright and add-copyright in Makefile to check and add copyright for files automatically 2. check if all needed copyright is added in workflow 3. add copyright for files Closes antrea-io#3100 Signed-off-by: zbangqi <zbangqi@vmware.com>
b6fb678
to
1546a8d
Compare
/skip-all |
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.
Looks like CI issues have been resolved
1. add make check-copyright and add-copyright in Makefile to check and add copyright for files automatically 2. check if all needed copyright headers have been added with workflow 3. add missing copyright headers Closes antrea-io#3100 Signed-off-by: zbangqi <zbangqi@vmware.com>
make add-copyright
andmake check-copyright
in Makefile to add and check copyright for files automaticallyThis is based on #3100