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 PR labeler based on LoC #50

Merged
merged 3 commits into from Jan 30, 2023

Conversation

dilyar85
Copy link
Member

@dilyar85 dilyar85 commented Jan 29, 2023

This patch adds a new GitHub action that automatically attaches labels to PRs based on their LoC.
It can also be served as a reminder for developers to conduct necessary testing for PRs with large LoC.

Testing Done:

  • Updated my fork main branch with this change pushed
  • Created a PR against my fork with different LoC changing
  • Confirmed the labels are added/removed in the PR accordingly

Screenshot of the above PR in my fork:
image

@dilyar85
Copy link
Member Author

dilyar85 commented Jan 29, 2023

Hmm looks like there is some permission issue for the Action app to access this repo:

2023/01/29 12:19:07 Setting labels to vmware-tanzu/vm-operator#50: [small-diff]
2023/01/29 12:19:07 Unable to execute action: PUT https://api.github.com/repos/vmware-tanzu/vm-operator/issues/50/labels: 403 Resource not accessible by integration []

After a quick research, it looks like GitHub Action's token will be downgraded to read-only in PRs from forked repos.
Will try resolving this on Monday.

.github/configs/labeler.yml Outdated Show resolved Hide resolved
.github/configs/labeler.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
Copy link
Collaborator

@akutz akutz left a comment

Choose a reason for hiding this comment

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

Hi @dilyar85,

Thank you for owning and driving this! I really appreciate it! In addition to the feedback I have already provided, I would also like you to update all of the size labels to exclude:

- "*_generated.go"       # generated Go sources
- "config/crd/bases/.*"  # generated CRDs
- "docs/apis/v*.md"      # generated API documentation,
                         # ex. docs/apis/v1alpha1.md

The problem is that the labeler action does not currently support an exclude option. There is an issue from November 2021 requesting this feature -- srvaroa/labeler#33. Apparently the following does not work:

files:
- "^*_generated.go"       # generated Go sources
- "^config/crd/bases/.*"  # generated CRDs
- "^docs/apis/v*.md"      # generated API documentation,
                         # ex. docs/apis/v1alpha1.md

The standard GitHub labeler action does support exclusions -- actions/labeler#22. However, it does not support labeling based on the size of the diff, although an enhancement request for this was filed last week -- actions/labeler#486.

For now I think we go with srvaroa/labeler@v0.9 and acknowledge that the generated files cannot be easily ignored. I'm not sure if it's worth maintaining a list of all the files to include -- that will inevitably miss something as files are added/removed.

Please update the labeler action workflow YAML with some comments/notes regarding the concerns in this feedback so that others can track that we had this discussion. Thanks!

@akutz
Copy link
Collaborator

akutz commented Jan 29, 2023

Hmm looks like there is some permission issue for the Action app to access this repo:

2023/01/29 12:19:07 Setting labels to vmware-tanzu/vm-operator#50: [small-diff]
2023/01/29 12:19:07 Unable to execute action: PUT https://api.github.com/repos/vmware-tanzu/vm-operator/issues/50/labels: 403 Resource not accessible by integration []

After a quick research, it looks like GitHub Action's token will be downgraded to read-only in PRs from forked repos. Will try resolving this on Monday.

Hi @dilyar85,

Let's chat about this before you do anything. I already mentioned that you'll need to validate this in your fork. The reason is the perms. There is a reason https://github.com/vmware-tanzu/vm-operator/blob/main/.github/workflows/post-coverage-to-pr.yml exists the way it does -- actions spawned as a result of a PR from a fork do not have permission to write to the PR on the primary repo. Thus the workflow_action pattern documented at https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_run.

However, in the case of this workflow, you should merge it to main in your fork. That's what I did to get the workflows correct for this repo in the first place. I kept rebasing main in my fork to validate the configurations. Then I would open PRs against my fork to validate PR workflows, etc. Once I was happy with everything, I would then open a PR against the primary repo from a branch on my fork, ensuring my fork's main branch was once again reset to the same as the primary repo.

@github-actions
Copy link

Code Coverage

Package Line Rate Health
github.com/vmware-tanzu/vm-operator/controllers 0%
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/clustercontentlibraryitem 76%
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/contentlibraryitem 75%
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/contentsource 88%
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/utils 97%
github.com/vmware-tanzu/vm-operator/controllers/infracluster 75%
github.com/vmware-tanzu/vm-operator/controllers/infraprovider 75%
github.com/vmware-tanzu/vm-operator/controllers/providerconfigmap 74%
github.com/vmware-tanzu/vm-operator/controllers/util/encoding 73%
github.com/vmware-tanzu/vm-operator/controllers/util/remote 41%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachine 57%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineclass 31%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinepublishrequest 86%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineservice 83%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineservice/providers 96%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineservice/providers/simplelb 66%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineservice/utils 82%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinesetresourcepolicy 80%
github.com/vmware-tanzu/vm-operator/controllers/volume 87%
github.com/vmware-tanzu/vm-operator/controllers/webconsolerequest 72%
github.com/vmware-tanzu/vm-operator/pkg/builder 70%
github.com/vmware-tanzu/vm-operator/pkg/conditions 90%
github.com/vmware-tanzu/vm-operator/pkg/context 0%
github.com/vmware-tanzu/vm-operator/pkg/context/fake 100%
github.com/vmware-tanzu/vm-operator/pkg/lib 78%
github.com/vmware-tanzu/vm-operator/pkg/manager 81%
github.com/vmware-tanzu/vm-operator/pkg/metrics 89%
github.com/vmware-tanzu/vm-operator/pkg/patch 78%
github.com/vmware-tanzu/vm-operator/pkg/prober 92%
github.com/vmware-tanzu/vm-operator/pkg/prober/context 100%
github.com/vmware-tanzu/vm-operator/pkg/prober/fake 85%
github.com/vmware-tanzu/vm-operator/pkg/prober/fake/probe 83%
github.com/vmware-tanzu/vm-operator/pkg/prober/fake/worker 88%
github.com/vmware-tanzu/vm-operator/pkg/prober/probe 83%
github.com/vmware-tanzu/vm-operator/pkg/prober/worker 86%
github.com/vmware-tanzu/vm-operator/pkg/record 89%
github.com/vmware-tanzu/vm-operator/pkg/topology 85%
github.com/vmware-tanzu/vm-operator/pkg/util 77%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/fake 76%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere 73%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/client 74%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/clustermodules 85%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/config 83%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/contentlibrary 70%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/credentials 100%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/instancestorage 100%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/internal 0%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/network 85%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/placement 83%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/resources 41%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/session 84%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/storage 77%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/test 98%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/vcenter 80%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/virtualmachine 84%
github.com/vmware-tanzu/vm-operator/pkg/webconsolevalidation 53%
github.com/vmware-tanzu/vm-operator/webhooks 0%
github.com/vmware-tanzu/vm-operator/webhooks/common 100%
github.com/vmware-tanzu/vm-operator/webhooks/persistentvolumeclaim 0%
github.com/vmware-tanzu/vm-operator/webhooks/persistentvolumeclaim/validation 95%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachine 0%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachine/mutation 83%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachine/validation 94%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineclass 0%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineclass/mutation 62%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineclass/validation 89%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinepublishrequest 0%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinepublishrequest/validation 93%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineservice 0%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineservice/mutation 62%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineservice/validation 91%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinesetresourcepolicy 0%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinesetresourcepolicy/mutation 62%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinesetresourcepolicy/validation 89%
github.com/vmware-tanzu/vm-operator/webhooks/webconsolerequest 0%
github.com/vmware-tanzu/vm-operator/webhooks/webconsolerequest/validation 92%
Summary 80% (5729 / 7199)

Minimum allowed line rate is 60%

@dilyar85
Copy link
Member Author

@akutz Thanks for the review. I have updated this change to address your comments above.
Also verified this workflow using my fork (see the testing done section in PR's description).

Copy link
Collaborator

@akutz akutz left a comment

Choose a reason for hiding this comment

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

Lgtm!

@dilyar85 dilyar85 merged commit a8274a6 into vmware-tanzu:main Jan 30, 2023
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.

None yet

2 participants