Skip to content

Commit 8a3103c

Browse files
ab-ghoshzakisk
authored andcommitted
chore(linter): enforce British spelling 'cancelled' over 'canceled'
Add misspell linter configuration to enforce consistent use of 'cancelled' (British spelling) across the codebase. Update all internal code, comments, and test assertions to use 'cancelled'. Exclude GitLab provider code and test files from this rule, as GitLab's API requires 'canceled' (American spelling) for compatibility. Changes: - Configure misspell linter in .golangci.yml - Fix spelling in pkg/cmd/tknpac and pkg/reconciler - Update test files to use 'cancelled' - Add exclusions for GitLab API-related code Signed-off-by: ab-ghosh <abghosh@redhat.com>
1 parent 8c707c3 commit 8a3103c

File tree

10 files changed

+30
-23
lines changed

10 files changed

+30
-23
lines changed

.golangci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ linters:
5757
- whitespace
5858
- zerologlint
5959
settings:
60+
misspell:
61+
ignore-words:
62+
- cancelled
63+
extra-words:
64+
- typo: "canceled"
65+
correction: "cancelled"
6066
errcheck:
6167
exclude-functions:
6268
- (*github.com/tektoncd/pipeline/vendor/go.uber.org/zap.SugaredLogger).Sync

pkg/cmd/tknpac/resolve/basic_auth_secret.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ func makeGitAuthSecret(ctx context.Context, cs *params.Run, filenames []string,
7777
provideSecret := false
7878
msg := "We have detected a git_auth_secret in your PipelineRun. Would you like to provide a API token for the git_clone task?"
7979
if err := prompt.SurveyAskOne(&survey.Confirm{Message: msg, Default: true}, &provideSecret); err != nil {
80-
return "", "", fmt.Errorf("canceled")
80+
return "", "", fmt.Errorf("cancelled")
8181
}
8282
if provideSecret {
8383
msg := `Enter a token to be used for the git_auth_secret`
8484
if err := prompt.SurveyAskOne(&survey.Password{Message: msg}, &token); err != nil {
85-
return "", "", fmt.Errorf("canceled")
85+
return "", "", fmt.Errorf("cancelled")
8686
}
8787
}
8888
}

pkg/provider/gitlab/gitlab.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ func (v *Provider) SetClient(_ context.Context, run *params.Run, runevent *info.
249249
return nil
250250
}
251251

252+
//nolint:misspell
252253
func (v *Provider) CreateStatus(_ context.Context, event *info.Event, statusOpts provider.StatusOpts,
253254
) error {
254255
var detailsURL string

pkg/reconciler/reconciler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, pr *tektonv1.PipelineRun
106106
}
107107

108108
// queue pipelines which are in queued state and pending status
109-
// if status is not pending, it could be canceled so let it be reported, even if state is queued
109+
// if status is not pending, it could be cancelled so let it be reported, even if state is queued
110110
if state == kubeinteraction.StateQueued && pr.Spec.Status == tektonv1.PipelineRunSpecStatusPending {
111111
return r.queuePipelineRun(ctx, logger, pr)
112112
}

test/bitbucket_cloud_pullrequest_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,14 @@ func TestBitbucketCloudPullRequestCancelInProgressMerged(t *testing.T) {
9898
_, err = bprovider.Client().Repositories.PullRequests.Decline(po)
9999
assert.NilError(t, err)
100100

101-
runcnx.Clients.Log.Info("Waiting 10 seconds to check things has been canceled")
101+
runcnx.Clients.Log.Info("Waiting 10 seconds to check things has been cancelled")
102102
time.Sleep(10 * time.Second) // “Evil does not sleep. It waits.” - Galadriel
103103

104104
prs, err := runcnx.Clients.Tekton.TektonV1().PipelineRuns(targetNS).List(context.Background(), metav1.ListOptions{})
105105
assert.NilError(t, err)
106106
assert.Equal(t, len(prs.Items), 1, "should have only one pipelinerun, but we have: %d", len(prs.Items))
107107

108-
assert.Equal(t, prs.Items[0].GetStatusCondition().GetCondition(apis.ConditionSucceeded).GetReason(), "Cancelled", "should have been canceled")
108+
assert.Equal(t, prs.Items[0].GetStatusCondition().GetCondition(apis.ConditionSucceeded).GetReason(), "Cancelled", "should have been cancelled")
109109
}
110110

111111
// Local Variables:

test/gitea_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ func TestGiteaConfigCancelInProgress(t *testing.T) {
540540
cancelledPr++
541541
}
542542
}
543-
assert.Equal(t, cancelledPr, 1, "only one pr should have been canceled")
543+
assert.Equal(t, cancelledPr, 1, "only one pr should have been cancelled")
544544

545545
// Test that cancelling works with /retest - use specific PipelineRun name to bypass success check
546546
tgitea.PostCommentOnPullRequest(t, topts, "/retest pr-cancel-in-progress")
@@ -554,7 +554,7 @@ func TestGiteaConfigCancelInProgress(t *testing.T) {
554554
cancelledPr++
555555
}
556556
}
557-
assert.Equal(t, cancelledPr, 2, "tweo pr should have been canceled")
557+
assert.Equal(t, cancelledPr, 2, "two pr should have been cancelled")
558558
}
559559

560560
func TestGiteaConfigCancelInProgressAfterPRClosed(t *testing.T) {
@@ -586,14 +586,14 @@ func TestGiteaConfigCancelInProgressAfterPRClosed(t *testing.T) {
586586
})
587587
assert.NilError(t, err)
588588

589-
topts.ParamsRun.Clients.Log.Info("Waiting 10 seconds to check things has been canceled")
589+
topts.ParamsRun.Clients.Log.Info("Waiting 10 seconds to check things has been cancelled")
590590
time.Sleep(10 * time.Second) // “Evil does not sleep. It waits.” - Galadriel
591591

592592
prs, err := topts.ParamsRun.Clients.Tekton.TektonV1().PipelineRuns(topts.TargetNS).List(context.Background(), metav1.ListOptions{})
593593
assert.NilError(t, err)
594594
assert.Equal(t, len(prs.Items), 1, "should have only one pipelinerun, but we have: %d", len(prs.Items))
595595

596-
assert.Equal(t, prs.Items[0].GetStatusCondition().GetCondition(apis.ConditionSucceeded).GetReason(), "Cancelled", "should have been canceled")
596+
assert.Equal(t, prs.Items[0].GetStatusCondition().GetCondition(apis.ConditionSucceeded).GetReason(), "Cancelled", "should have been cancelled")
597597
}
598598

599599
func TestGiteaPush(t *testing.T) {

test/github_pullrequest_retest_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,16 @@ func TestGithubSecondPullRequestGitopsCommentCancel(t *testing.T) {
122122
assert.NilError(t, err)
123123
assert.Equal(t, len(pruns.Items), 3)
124124

125-
// go over all pruns check that at least one is canceled and the other two are succeeded
126-
canceledCount := 0
125+
// go over all pruns check that at least one is cancelled and the other two are succeeded
126+
cancelledCount := 0
127127
succeededCount := 0
128128
unknownCount := 0
129129
for _, prun := range pruns.Items {
130130
for _, condition := range prun.Status.Conditions {
131131
if condition.Type == "Succeeded" {
132132
switch condition.Status {
133133
case corev1.ConditionFalse:
134-
canceledCount++
134+
cancelledCount++
135135
case corev1.ConditionTrue:
136136
succeededCount++
137137
case corev1.ConditionUnknown:
@@ -140,7 +140,7 @@ func TestGithubSecondPullRequestGitopsCommentCancel(t *testing.T) {
140140
}
141141
}
142142
}
143-
assert.Equal(t, canceledCount, 1, "should have one canceled PipelineRun")
143+
assert.Equal(t, cancelledCount, 1, "should have one cancelled PipelineRun")
144144
assert.Equal(t, succeededCount, 2, "should have two succeeded PipelineRuns")
145145
assert.Equal(t, unknownCount, 0, "should have zero unknown PipelineRuns: %+v", pruns.Items)
146146
}

test/github_pullrequest_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ func TestGithubSecondCancelInProgress(t *testing.T) {
339339
err = twait.UntilPipelineRunCreated(ctx, g.Cnx.Clients, waitOpts)
340340
assert.NilError(t, err)
341341

342-
g.Cnx.Clients.Log.Infof("Sleeping for 10 seconds to let the pipelinerun to be canceled")
342+
g.Cnx.Clients.Log.Infof("Sleeping for 10 seconds to let the pipelinerun to be cancelled")
343343

344344
i := 0
345345
foundCancelled := false
@@ -357,7 +357,7 @@ func TestGithubSecondCancelInProgress(t *testing.T) {
357357
continue
358358
}
359359
if pr.Status.Conditions[0].Reason == "Cancelled" {
360-
g.Cnx.Clients.Log.Infof("PipelineRun %s has been canceled", pr.Name)
360+
g.Cnx.Clients.Log.Infof("PipelineRun %s has been cancelled", pr.Name)
361361
foundCancelled = true
362362
break
363363
}
@@ -400,16 +400,16 @@ func TestGithubSecondCancelInProgressPRClosed(t *testing.T) {
400400
})
401401
assert.NilError(t, err)
402402

403-
g.Cnx.Clients.Log.Infof("Sleeping for 10 seconds to let the pipelinerun to be canceled")
403+
g.Cnx.Clients.Log.Infof("Sleeping for 10 seconds to let the pipelinerun to be cancelled")
404404
time.Sleep(10 * time.Second)
405405

406-
g.Cnx.Clients.Log.Infof("Checking that the pipelinerun has been canceled")
406+
g.Cnx.Clients.Log.Infof("Checking that the pipelinerun has been cancelled")
407407

408408
prs, err := g.Cnx.Clients.Tekton.TektonV1().PipelineRuns(g.TargetNamespace).List(context.Background(), metav1.ListOptions{})
409409
assert.NilError(t, err)
410410
assert.Equal(t, len(prs.Items), 1, "should have only one pipelinerun, but we have: %d", len(prs.Items))
411411

412-
assert.Equal(t, prs.Items[0].GetStatusCondition().GetCondition(apis.ConditionSucceeded).GetReason(), "Cancelled", "should have been canceled")
412+
assert.Equal(t, prs.Items[0].GetStatusCondition().GetCondition(apis.ConditionSucceeded).GetReason(), "Cancelled", "should have been cancelled")
413413

414414
res, resp, err := g.Provider.Client().Checks.ListCheckRunsForRef(ctx, g.Options.Organization, g.Options.Repo, g.SHA, &github.ListCheckRunsOptions{
415415
AppID: g.Provider.ApplicationID,

test/github_push_retest_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ func TestGithubPushRequestGitOpsCommentCancel(t *testing.T) {
172172
&github.RepositoryComment{Body: github.Ptr(comment)})
173173
assert.NilError(t, err)
174174

175-
g.Cnx.Clients.Log.Infof("Waiting for Repository to be updated still to %d since it has been canceled", numberOfStatus)
176-
repo, _ := twait.UntilRepositoryUpdated(ctx, g.Cnx.Clients, waitOpts) // don't check for error, because canceled is not success and this will fail
175+
g.Cnx.Clients.Log.Infof("Waiting for Repository to be updated still to %d since it has been cancelled", numberOfStatus)
176+
repo, _ := twait.UntilRepositoryUpdated(ctx, g.Cnx.Clients, waitOpts) // don't check for error, because cancelled is not success and this will fail
177177
cancelled := false
178178
for _, c := range repo.Status {
179179
if c.Conditions[0].Reason == tektonv1.TaskRunReasonCancelled.String() {

test/gitlab_merge_request_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ func TestGitlabCancelInProgressOnChange(t *testing.T) {
360360
err = twait.UntilPipelineRunCreated(ctx, runcnx.Clients, newPipelineWaitOpts)
361361
assert.NilError(t, err)
362362

363-
runcnx.Clients.Log.Infof("Waiting for old pipelinerun to be canceled")
363+
runcnx.Clients.Log.Infof("Waiting for old pipelinerun to be cancelled")
364364
cancelledErr := twait.UntilPipelineRunHasReason(ctx, runcnx.Clients, v1.PipelineRunReasonCancelled, originalPipelineWaitOpts)
365365
assert.NilError(t, cancelledErr)
366366
}
@@ -429,7 +429,7 @@ func TestGitlabCancelInProgressOnPRClose(t *testing.T) {
429429
prs, err := runcnx.Clients.Tekton.TektonV1().PipelineRuns(targetNS).List(context.Background(), metav1.ListOptions{})
430430
assert.NilError(t, err)
431431
assert.Equal(t, len(prs.Items), 1, "should have only one pipelinerun, but we have: %d", len(prs.Items))
432-
assert.Equal(t, prs.Items[0].GetStatusCondition().GetCondition(apis.ConditionSucceeded).GetReason(), "Cancelled", "should have been canceled")
432+
assert.Equal(t, prs.Items[0].GetStatusCondition().GetCondition(apis.ConditionSucceeded).GetReason(), "Cancelled", "should have been cancelled")
433433

434434
// failing on `true` condition because for cancelled PipelineRun we want `false` condition.
435435
waitOpts.FailOnRepoCondition = corev1.ConditionTrue
@@ -597,7 +597,7 @@ func TestGitlabDisableCommentsOnMRNotCreated(t *testing.T) {
597597
case "success":
598598
pipeline = p
599599
return true, nil // Success! Stop polling.
600-
case "failed", "canceled", "skipped":
600+
case "failed", "canceled", "skipped": //nolint:misspell
601601
// The pipeline has finished but not successfully.
602602
return false, fmt.Errorf("pipeline finished with non-success status: %s", p.Status)
603603
default:

0 commit comments

Comments
 (0)