Skip to content

Commit 04f7b59

Browse files
authored
feat: go1.20 and golangci-lint v1.55.2 (#480)
* fix: remove invalid 'unused' config and fix wsl trailing whitespace key name Signed-off-by: mikeee <[email protected]> * fix: disable inamedparam linter Signed-off-by: mikeee <[email protected]> * fix: update package and tool to go1.21.5 Signed-off-by: mikeee <[email protected]> * fix: correct majority of the testifylinter issues relating to error assertions Signed-off-by: mikeee <[email protected]> * fix: reverse actual and expected values Signed-off-by: mikeee <[email protected]> * fix: correct test cases Signed-off-by: mikeee <[email protected]> * fix: correct misspell - upsert Signed-off-by: mikeee <[email protected]> * fix: add missing import Signed-off-by: mikeee <[email protected]> * update: bump validation workflow to 1.21 Signed-off-by: mikeee <[email protected]> * fix: refactor direct access references to proto fields Signed-off-by: mikeee <[email protected]> * fix: revert to go1.20 retaining version-1 support Signed-off-by: mikeee <[email protected]> * fix: update test-dapr-bot workflow golangci-lint ver to 1.55.2 Signed-off-by: mikeee <[email protected]> * fix: fix assertions for dapr-bot and check-lint-version Signed-off-by: mikeee <[email protected]> * fix: remove length function call Signed-off-by: mikeee <[email protected]> * fix: fix StateConsistency logic and add tests to satisfy codecov Signed-off-by: mikeee <[email protected]> * tests: add coverage of empty store names for delete bulk state item method Signed-off-by: mikeee <[email protected]> --------- Signed-off-by: mikeee <[email protected]>
1 parent 959de75 commit 04f7b59

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+625
-525
lines changed

.github/workflows/dapr-bot.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Setup Golang
2222
uses: actions/setup-go@v4
2323
with:
24-
go-version: ~1.21
24+
go-version: ~1.20
2525
cache-dependency-path: |
2626
./.github/workflows/dapr-bot/
2727

.github/workflows/dapr-bot/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
GO_COMPAT_VERSION=1.21
1+
GO_COMPAT_VERSION=1.20
22

33
.PHONY: cover
44
cover:

.github/workflows/dapr-bot/bot_test.go

+14-13
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ import (
88
"github.com/google/go-github/v55/github"
99
"github.com/jinzhu/copier"
1010
"github.com/stretchr/testify/assert"
11+
"github.com/stretchr/testify/require"
1112
)
1213

13-
var testBot *Bot = &Bot{
14+
var testBot = &Bot{
1415
ctx: context.Background(),
1516
issueClient: &testClient{},
1617
}
@@ -50,7 +51,7 @@ func TestHandleEvent(t *testing.T) {
5051
}
5152
testEventCopy.IssueCommentEvent.Comment.Body = github.String("/assign")
5253
res, err := testBot.HandleEvent(ctx, testEventCopy)
53-
assert.NoError(t, err)
54+
require.NoError(t, err)
5455
assert.NotEmpty(t, res)
5556
})
5657

@@ -67,7 +68,7 @@ func TestHandleEvent(t *testing.T) {
6768
}
6869
testEventCopy.IssueCommentEvent.Comment.Body = github.String("/assign \r \ntest body")
6970
res, err := testBot.HandleEvent(ctx, testEventCopy)
70-
assert.NoError(t, err)
71+
require.NoError(t, err)
7172
assert.NotEmpty(t, res)
7273
})
7374

@@ -84,7 +85,7 @@ func TestHandleEvent(t *testing.T) {
8485
}
8586
testEventCopy.IssueCommentEvent.Comment.Body = github.String("/assign")
8687
res, err := testBot.HandleEvent(ctx, testEventCopy)
87-
assert.Error(t, err)
88+
require.Error(t, err)
8889
assert.NotEmpty(t, res)
8990
})
9091

@@ -99,7 +100,7 @@ func TestHandleEvent(t *testing.T) {
99100
}
100101
testEventCopy.IssueCommentEvent.Comment.Body = github.String("assign")
101102
res, err := testBot.HandleEvent(ctx, testEventCopy)
102-
assert.NoError(t, err)
103+
require.NoError(t, err)
103104
assert.Equal(t, "no command found", res)
104105
})
105106
}
@@ -111,7 +112,7 @@ func TestCreateIssueComment(t *testing.T) {
111112
}
112113
testBot.issueClient = &tc
113114
err := testBot.CreateIssueComment("test", testEvent)
114-
assert.Error(t, err)
115+
require.Error(t, err)
115116
})
116117

117118
t.Run("create issue comment", func(t *testing.T) {
@@ -120,7 +121,7 @@ func TestCreateIssueComment(t *testing.T) {
120121
}
121122
testBot.issueClient = &tc
122123
err := testBot.CreateIssueComment("test", testEvent)
123-
assert.NoError(t, err)
124+
require.NoError(t, err)
124125
})
125126

126127
t.Run("create issue comment with empty body", func(t *testing.T) {
@@ -129,7 +130,7 @@ func TestCreateIssueComment(t *testing.T) {
129130
}
130131
testBot.issueClient = &tc
131132
err := testBot.CreateIssueComment("", testEvent)
132-
assert.Error(t, err)
133+
require.Error(t, err)
133134
})
134135
}
135136

@@ -140,7 +141,7 @@ func TestAssignIssueToCommenter(t *testing.T) {
140141
}
141142
testBot.issueClient = &tc
142143
assignee, err := testBot.AssignIssueToCommenter(testEvent)
143-
assert.Error(t, err)
144+
require.Error(t, err)
144145
assert.Empty(t, assignee)
145146
})
146147

@@ -156,7 +157,7 @@ func TestAssignIssueToCommenter(t *testing.T) {
156157
}
157158
testEventCopy.IssueCommentEvent.Issue.Assignees = []*github.User{}
158159
assignee, err := testBot.AssignIssueToCommenter(testEventCopy)
159-
assert.NoError(t, err)
160+
require.NoError(t, err)
160161
assert.Equal(t, "testCommentLogin", assignee)
161162
})
162163

@@ -170,7 +171,7 @@ func TestAssignIssueToCommenter(t *testing.T) {
170171
}
171172
testEventCopy.IssueCommentEvent.Issue.State = github.String("closed")
172173
assignee, err := testBot.AssignIssueToCommenter(testEventCopy)
173-
assert.Error(t, err)
174+
require.Error(t, err)
174175
assert.Empty(t, assignee)
175176
})
176177

@@ -184,7 +185,7 @@ func TestAssignIssueToCommenter(t *testing.T) {
184185
}
185186
testEventCopy.IssueCommentEvent.Issue.Assignees = []*github.User{{Login: github.String("testCommentLogin")}}
186187
assignee, err := testBot.AssignIssueToCommenter(testEventCopy)
187-
assert.Error(t, err)
188+
require.Error(t, err)
188189
assert.Empty(t, assignee)
189190
})
190191

@@ -200,7 +201,7 @@ func TestAssignIssueToCommenter(t *testing.T) {
200201
}
201202
testEventCopy.IssueCommentEvent.Issue.Assignees = []*github.User{{Login: github.String("testCommentLogin2")}}
202203
assignee, err := testBot.AssignIssueToCommenter(testEventCopy)
203-
assert.Error(t, err)
204+
require.Error(t, err)
204205
assert.Empty(t, assignee)
205206
})
206207
}

.github/workflows/dapr-bot/event_test.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ import (
88

99
"github.com/google/go-github/v55/github"
1010
"github.com/stretchr/testify/assert"
11+
"github.com/stretchr/testify/require"
1112
)
1213

13-
var testEvent Event = Event{
14+
var testEvent = Event{
1415
Type: "issue_comment",
1516
Path: "test/test",
1617
IssueCommentEvent: &github.IssueCommentEvent{
@@ -36,14 +37,14 @@ func TestProcessEvent(t *testing.T) {
3637
}
3738
t.Run("process event", func(t *testing.T) {
3839
event, err := ProcessEvent(testEvent.Type, testEvent.Path, testEventData)
39-
assert.NoError(t, err)
40+
require.NoError(t, err)
4041
assert.NotNil(t, event)
4142
assert.Equal(t, "test/test", event.Path)
4243
})
4344

4445
t.Run("process event with empty path", func(t *testing.T) {
4546
event, err := ProcessEvent(testEvent.Type, "", testEventData)
46-
assert.Error(t, err)
47+
require.Error(t, err)
4748
assert.Empty(t, event)
4849
})
4950

@@ -53,22 +54,22 @@ func TestProcessEvent(t *testing.T) {
5354

5455
t.Run("process issue_comment event", func(t *testing.T) {
5556
event, err := ProcessEvent(testEvent.Type, testEvent.Path, testEventData)
56-
assert.NoError(t, err)
57+
require.NoError(t, err)
5758
assert.NotNil(t, event)
5859
assert.Equal(t, "issue_comment", event.Type)
5960
})
6061

6162
t.Run("process invalid event", func(t *testing.T) {
6263
event, err := ProcessEvent(testEvent.Type, testEvent.Path, randomData.Bytes())
63-
assert.Error(t, err)
64+
require.Error(t, err)
6465
assert.Empty(t, event)
6566
})
6667
}
6768

6869
func TestGetIssueAssignees(t *testing.T) {
6970
t.Run("get assignees", func(t *testing.T) {
7071
assignees := testEvent.GetIssueAssignees()
71-
assert.Equal(t, 1, len(assignees))
72+
assert.Len(t, assignees, 1)
7273
assert.Equal(t, "testAssignee", assignees[0])
7374
})
7475
}

.github/workflows/dapr-bot/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/dapr/go-sdk/.github/workflows/dapr-bot
22

3-
go 1.21
3+
go 1.20
44

55
require (
66
github.com/google/go-github/v55 v55.0.0

.github/workflows/dapr-bot/go.sum

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
88
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
99
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
1010
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
11-
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
1211
github.com/google/go-github/v55 v55.0.0 h1:4pp/1tNMB9X/LuAhs5i0KQAE40NmiR/y6prLNb9x9cg=
1312
github.com/google/go-github/v55 v55.0.0/go.mod h1:JLahOTA1DnXzhxEymmFF5PP2tSS9JVNj68mSZNDwskA=
1413
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=

.github/workflows/release-on-tag.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Setup
1616
uses: actions/setup-go@v3
1717
with:
18-
go-version: ^1.19
18+
go-version: ^1.20
1919

2020
- name: Checkout
2121
uses: actions/checkout@v3

.github/workflows/test-dapr-bot.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ jobs:
2020
fail-fast: false
2121
matrix:
2222
gover:
23-
- "1.21"
23+
- "1.20"
2424
env:
2525
GOVER: ${{ matrix.gover }}
26-
GOLANGCILINT_VER: v1.54.2
26+
GOLANGCILINT_VER: v1.55.2
2727

2828
steps:
2929
- name: Setup

.github/workflows/test-on-push.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ jobs:
1414
fail-fast: false
1515
matrix:
1616
gover:
17-
- "1.19"
1817
- "1.20"
1918
- "1.21"
2019
env:
2120
GOVER: ${{ matrix.gover }}
22-
GOLANGCILINT_VER: v1.54.2
21+
GOLANGCILINT_VER: v1.55.2
2322

2423
steps:
2524
- name: Setup

.github/workflows/test-tooling.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ jobs:
2020
fail-fast: false
2121
matrix:
2222
gover:
23-
- "1.21"
23+
- "1.20"
2424
os:
2525
- "ubuntu-latest"
2626
- "windows-latest"
2727
- "macos-latest"
2828
runs-on: ${{ matrix.os }}
2929
env:
3030
GOVER: ${{ matrix.gover }}
31-
GOLANGCILINT_VER: v1.54.2 # Make sure to bump /tools/check-lint-version/main_test.go
31+
GOLANGCILINT_VER: v1.55.2 # Make sure to bump /tools/check-lint-version/main_test.go
3232

3333
steps:
3434
- name: Setup

.golangci.yml

+2-7
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,6 @@ linters-settings:
164164
line-length: 120
165165
# tab width in spaces. Default to 1.
166166
tab-width: 1
167-
unused:
168-
# treat code as a program (not a library) and report unused exported identifiers; default is false.
169-
# XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
170-
# if it's called for subdir of a project it can't find funcs usages. All text editor integrations
171-
# with golangci-lint call it on a directory with the changed file.
172-
check-exported: false
173167
unparam:
174168
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
175169
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
@@ -242,7 +236,7 @@ linters-settings:
242236
# Allow multiline assignments to be cuddled. Default is true.
243237
allow-multiline-assign: true
244238
# Allow case blocks to end with a whitespace.
245-
allow-case-traling-whitespace: true
239+
force-case-trailing-whitespace: 0
246240
# Allow declarations (var) to be cuddled.
247241
allow-cuddle-declarations: false
248242

@@ -310,6 +304,7 @@ linters:
310304
- varcheck
311305
- deadcode
312306
- golint
307+
- inamedparam
313308
issues:
314309
exclude-rules:
315310
- path: .*_test.go

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
RELEASE_VERSION =v1.0.0-rc-3
22
GDOC_PORT =8888
3-
GO_COMPAT_VERSION=1.19
3+
GO_COMPAT_VERSION=1.20
44

55
.PHONY: all
66
all: help

actor/manager/container_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func TestContainerInvoke(t *testing.T) {
7272
mockCodec.EXPECT().Unmarshal([]byte(param), gomock.Any()).SetArg(1, "param").Return(nil)
7373

7474
rsp, err := container.Invoke("Invoke", []byte(param))
75-
require.Equal(t, 2, len(rsp))
75+
require.Len(t, rsp, 2)
7676
require.Equal(t, actorErr.Success, err)
7777
assert.Equal(t, param, rsp[0].Interface().(string))
7878
}

client/actor.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func (c *GRPCClient) InvokeActor(ctx context.Context, in *InvokeActorRequest) (o
7474
out = &InvokeActorResponse{}
7575

7676
if resp != nil {
77-
out.Data = resp.Data
77+
out.Data = resp.GetData()
7878
}
7979

8080
return out, nil
@@ -421,7 +421,7 @@ func (c *GRPCClient) GetActorState(ctx context.Context, in *GetActorStateRequest
421421
if err != nil {
422422
return nil, fmt.Errorf("error invoking actor get state %s/%s: %w", in.ActorType, in.ActorID, err)
423423
}
424-
return &GetActorStateResponse{Data: rsp.Data}, nil
424+
return &GetActorStateResponse{Data: rsp.GetData()}, nil
425425
}
426426

427427
type ActorStateOperation struct {

0 commit comments

Comments
 (0)