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

Add license automatically #3122

Merged
merged 1 commit into from
Feb 18, 2022
Merged

Conversation

bangqipropel
Copy link
Contributor

@bangqipropel bangqipropel commented Dec 10, 2021

  1. add make add-copyright and make check-copyright in Makefile to add and check copyright for files automatically
  2. check if all needed copyright is added in workflow
  3. add copyright to needed files

This is based on #3100

@bangqipropel bangqipropel changed the base branch from main to feature/multi-cluster December 10, 2021 23:08
@bangqipropel bangqipropel marked this pull request as draft December 10, 2021 23:12
@bangqipropel bangqipropel marked this pull request as ready for review December 10, 2021 23:13
@luolanzone
Copy link
Contributor

@bangqipropel add necessary info to make your commit and PR summary clear. and link it to the right issue. thanks.

@luolanzone luolanzone force-pushed the feature/multi-cluster branch 2 times, most recently from 14f9a10 to f55dbad Compare December 13, 2021 07:16
@bangqipropel
Copy link
Contributor Author

@bangqipropel add necessary info to make your commit and PR summary clear. and link it to the right issue. thanks.

@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?

@luolanzone
Copy link
Contributor

luolanzone commented Dec 13, 2021

@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
btw, your DCO build failed, please check this doc to add your commit and PR sign-off. https://github.com/antrea-io/antrea/blob/main/CONTRIBUTING.md#sign-off-your-work

@bangqipropel bangqipropel force-pushed the addlicense branch 7 times, most recently from d6d9b72 to 2c88847 Compare December 16, 2021 04:28
@codecov-commenter
Copy link

codecov-commenter commented Dec 16, 2021

Codecov Report

Merging #3122 (1546a8d) into main (70fac83) will decrease coverage by 12.06%.
The diff coverage is n/a.

Impacted file tree graph

@@             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     
Flag Coverage Δ
integration-tests 33.98% <ø> (?)
kind-e2e-tests 35.20% <ø> (-11.54%) ⬇️
unit-tests 41.60% <ø> (-0.24%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...uster/controllers/multicluster/controller_utils.go 44.18% <ø> (ø)
pkg/agent/proxy/metrics/metrics.go 100.00% <ø> (ø)
pkg/ovs/openflow/ofctrl_action.go 65.41% <ø> (-2.50%) ⬇️
pkg/ovs/openflow/ofctrl_bridge.go 55.58% <ø> (ø)
pkg/ovs/openflow/ofctrl_flow.go 39.39% <ø> (-1.52%) ⬇️
pkg/agent/controller/networkpolicy/reject.go 0.00% <0.00%> (-87.91%) ⬇️
...g/agent/apiserver/handlers/featuregates/handler.go 0.00% <0.00%> (-82.36%) ⬇️
pkg/apis/controlplane/v1beta2/helper.go 33.33% <0.00%> (-66.67%) ⬇️
pkg/agent/types/networkpolicy.go 16.66% <0.00%> (-66.67%) ⬇️
pkg/controller/networkpolicy/mutate.go 0.00% <0.00%> (-62.07%) ⬇️
... and 279 more

Makefile Outdated
$(CURDIR)/hack/add-license.sh
else
@echo "===> Adding License for files <==="
$(CURDIR)/hack/add-license.sh --add
Copy link
Contributor

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.

@@ -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
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

@luolanzone luolanzone Jan 4, 2022

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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

@luolanzone luolanzone force-pushed the feature/multi-cluster branch from f9e5f48 to fb5ddfc Compare December 22, 2021 01:08
@bangqipropel bangqipropel force-pushed the addlicense branch 2 times, most recently from 9878a9e to 34a67c9 Compare January 4, 2022 09:55
@@ -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
Copy link
Contributor

@luolanzone luolanzone Jan 4, 2022

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.

@@ -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
Copy link
Contributor

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

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)

Copy link
Contributor

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.

Copy link
Contributor Author

@bangqipropel bangqipropel Jan 5, 2022

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.

Copy link
Contributor

@luolanzone luolanzone Jan 5, 2022

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.

@bangqipropel bangqipropel changed the base branch from feature/multi-cluster to main January 6, 2022 08:09
@bangqipropel
Copy link
Contributor Author

why is this being merged into feature/multi-cluster instead of main?

changed

@bangqipropel bangqipropel force-pushed the addlicense branch 2 times, most recently from d1cfbec to 4d68a96 Compare January 6, 2022 22:38
Makefile Outdated
Comment on lines 199 to 204
@echo "==> Installing addlicense <=="
@GO=$(GO) $(CURDIR)/hack/add-license.sh

.PHONY: add-copyright
add-copyright:
@echo "==> Installing addlicense <=="
Copy link
Contributor

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

Copy link
Contributor Author

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

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'"
Copy link
Contributor

@antoninbas antoninbas Jan 8, 2022

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed the message

antoninbas
antoninbas previously approved these changes Jan 10, 2022
@antoninbas
Copy link
Contributor

/skip-all

@luolanzone
Copy link
Contributor

@bangqipropel Could you help to resolve the conflicts? thanks.

@luolanzone
Copy link
Contributor

Hi @antoninbas @tnqn Could you help to review this issue again, @bangqipropel has fixed the code conflicts. thanks.

antoninbas
antoninbas previously approved these changes Feb 15, 2022
@antoninbas
Copy link
Contributor

/skip-all

@antoninbas
Copy link
Contributor

I approved bu looks like the CI checks are not running correctly. You may need to close and re-open the PR?

@bangqipropel
Copy link
Contributor Author

I approved bu looks like the CI checks are not running correctly. You may need to close and re-open the PR?
@antoninbas
Have done this but some of the Jenkins still report errors, I also have this error on other PRs, is there something wrong with Jenkins?

@@ -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
Copy link
Contributor

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)?

@antoninbas
Copy link
Contributor

Most Jenkins jobs a re marked as failed when they do not run. /skip-all should make then "green" but maybe the command doesn't cover all jobs (only the required ones).

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>
@antoninbas
Copy link
Contributor

/skip-all

Copy link
Contributor

@antoninbas antoninbas left a 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

@antoninbas antoninbas merged commit 3f30d84 into antrea-io:main Feb 18, 2022
bangqipropel added a commit to bangqipropel/antrea that referenced this pull request Mar 2, 2022
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants