Repository: jenkins-x/lighthouse
Pull request #1216 (2021-01-20 17:46:53)

fix: keeper status case insensitive labels
Signed-off-by: Patrick Lee Scott <pat@patscott.io>

jenkins-x-bot: Hi @patrickleet. Thanks for your PR.

I'm waiting for a [jenkins-x](https://github.com/orgs/jenkins-x/people) 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](https://github.com/orgs/jenkins-x/people) 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](https://go.k8s.io/bot-commands?repo=jenkins-x%2Flighthouse).

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [jenkins-x/lighthouse](https://github.com/jenkins-x/lighthouse/issues/new?title=Command%20issue:) repository.
</details>

jenkins-x-bot: [APPROVALNOTIFIER] This PR is **NOT APPROVED**

This pull-request has been approved by:
To complete the [pull request process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process), please assign **daveconde**
You can assign the PR to them by writing `/assign @daveconde` in a comment when ready.

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=jenkins-x%2Flighthouse).

<details open>
Needs approval from an approver in each of these files:

- **[OWNERS](https://github.com/jenkins-x/lighthouse/blob/master/OWNERS)**

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":["daveconde"]} -->
patrickleet: /cc @abayer 

Thanks for merging the last two - still didn't work though so had to dig deeper.

Added a new test case that failed before the change as well.
abayer: /ok-to-test
/lgtm

d'oh, I shoulda thought of that too! =)
jenkins-x-bot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *[abayer](https://github.com/jenkins-x/lighthouse/pull/1216#issuecomment-763821291 "LGTM")*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=jenkins-x%2Flighthouse).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com#issuecomment-763821291/jenkins-x/lighthouse/blob/master/OWNERS)~~ [abayer]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->

Patch:
diff --git a/pkg/keeper/status.go b/pkg/keeper/status.go
index 770aaa86..d0b6c143 100644
--- a/pkg/keeper/status.go
+++ b/pkg/keeper/status.go
@@ -163,7 +163,7 @@ func requirementDiff(pr *PullRequest, q *keeper.Query, cc contextChecker) (strin
 	for _, l1 := range q.Labels {
 		var found bool
 		for _, l2 := range pr.Labels.Nodes {
-			if string(l2.Name) == l1 {
+			if strings.ToLower(string(l2.Name)) == strings.ToLower(string(l1)) {
 				found = true
 				break
 			}


Test patch:
diff --git a/pkg/keeper/status_test.go b/pkg/keeper/status_test.go
index 355a81c5..03cd73a8 100644
--- a/pkg/keeper/status_test.go
+++ b/pkg/keeper/status_test.go
@@ -33,6 +33,7 @@ import (
 
 func TestExpectedStatus(t *testing.T) {
 	neededLabels := []string{"need-1", "need-2", "need-a-very-super-duper-extra-not-short-at-all-label-name"}
+	titleCasedNeededLabels := []string{"Need-1", "Need-2", "Need-a-very-super-duper-extra-not-short-at-all-label-name"}
 	forbiddenLabels := []string{"forbidden-1", "forbidden-2"}
 	testcases := []struct {
 		name string
@@ -67,6 +68,15 @@ func TestExpectedStatus(t *testing.T) {
 			state: scmprovider.StatusPending,
 			desc:  fmt.Sprintf(statusNotInPool, " Needs need-1, need-2 labels."),
 		},
+		{
+			name:      "check label requirements are case insensitive because Github treats them that way",
+			labels:    append([]string{}, titleCasedNeededLabels[:2]...),
+			milestone: "v1.0",
+			inPool:    false,
+
+			state: scmprovider.StatusPending,
+			desc:  fmt.Sprintf(statusNotInPool, " Needs need-a-very-super-duper-extra-not-short-at-all-label-name label."),
+		},
 		{
 			name:      "check truncation of label list is not excessive",
 			labels:    append([]string{}, neededLabels[:2]...),