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

feat: go1.20 and golangci-lint v1.55.2 #480

Merged
merged 16 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/dapr-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Setup Golang
uses: actions/setup-go@v4
with:
go-version: ~1.21
go-version: ~1.20
cache-dependency-path: |
./.github/workflows/dapr-bot/

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dapr-bot/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GO_COMPAT_VERSION=1.21
GO_COMPAT_VERSION=1.20

.PHONY: cover
cover:
Expand Down
27 changes: 14 additions & 13 deletions .github/workflows/dapr-bot/bot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import (
"github.com/google/go-github/v55/github"
"github.com/jinzhu/copier"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

var testBot *Bot = &Bot{
var testBot = &Bot{
ctx: context.Background(),
issueClient: &testClient{},
}
Expand Down Expand Up @@ -50,7 +51,7 @@ func TestHandleEvent(t *testing.T) {
}
testEventCopy.IssueCommentEvent.Comment.Body = github.String("/assign")
res, err := testBot.HandleEvent(ctx, testEventCopy)
assert.NoError(t, err)
require.NoError(t, err)
assert.NotEmpty(t, res)
})

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

Expand All @@ -84,7 +85,7 @@ func TestHandleEvent(t *testing.T) {
}
testEventCopy.IssueCommentEvent.Comment.Body = github.String("/assign")
res, err := testBot.HandleEvent(ctx, testEventCopy)
assert.Error(t, err)
require.Error(t, err)
assert.NotEmpty(t, res)
})

Expand All @@ -99,7 +100,7 @@ func TestHandleEvent(t *testing.T) {
}
testEventCopy.IssueCommentEvent.Comment.Body = github.String("assign")
res, err := testBot.HandleEvent(ctx, testEventCopy)
assert.NoError(t, err)
require.NoError(t, err)
assert.Equal(t, "no command found", res)
})
}
Expand All @@ -111,7 +112,7 @@ func TestCreateIssueComment(t *testing.T) {
}
testBot.issueClient = &tc
err := testBot.CreateIssueComment("test", testEvent)
assert.Error(t, err)
require.Error(t, err)
})

t.Run("create issue comment", func(t *testing.T) {
Expand All @@ -120,7 +121,7 @@ func TestCreateIssueComment(t *testing.T) {
}
testBot.issueClient = &tc
err := testBot.CreateIssueComment("test", testEvent)
assert.NoError(t, err)
require.NoError(t, err)
})

t.Run("create issue comment with empty body", func(t *testing.T) {
Expand All @@ -129,7 +130,7 @@ func TestCreateIssueComment(t *testing.T) {
}
testBot.issueClient = &tc
err := testBot.CreateIssueComment("", testEvent)
assert.Error(t, err)
require.Error(t, err)
})
}

Expand All @@ -140,7 +141,7 @@ func TestAssignIssueToCommenter(t *testing.T) {
}
testBot.issueClient = &tc
assignee, err := testBot.AssignIssueToCommenter(testEvent)
assert.Error(t, err)
require.Error(t, err)
assert.Empty(t, assignee)
})

Expand All @@ -156,7 +157,7 @@ func TestAssignIssueToCommenter(t *testing.T) {
}
testEventCopy.IssueCommentEvent.Issue.Assignees = []*github.User{}
assignee, err := testBot.AssignIssueToCommenter(testEventCopy)
assert.NoError(t, err)
require.NoError(t, err)
assert.Equal(t, "testCommentLogin", assignee)
})

Expand All @@ -170,7 +171,7 @@ func TestAssignIssueToCommenter(t *testing.T) {
}
testEventCopy.IssueCommentEvent.Issue.State = github.String("closed")
assignee, err := testBot.AssignIssueToCommenter(testEventCopy)
assert.Error(t, err)
require.Error(t, err)
assert.Empty(t, assignee)
})

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

Expand All @@ -200,7 +201,7 @@ func TestAssignIssueToCommenter(t *testing.T) {
}
testEventCopy.IssueCommentEvent.Issue.Assignees = []*github.User{{Login: github.String("testCommentLogin2")}}
assignee, err := testBot.AssignIssueToCommenter(testEventCopy)
assert.Error(t, err)
require.Error(t, err)
assert.Empty(t, assignee)
})
}
13 changes: 7 additions & 6 deletions .github/workflows/dapr-bot/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import (

"github.com/google/go-github/v55/github"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

var testEvent Event = Event{
var testEvent = Event{
Type: "issue_comment",
Path: "test/test",
IssueCommentEvent: &github.IssueCommentEvent{
Expand All @@ -36,14 +37,14 @@ func TestProcessEvent(t *testing.T) {
}
t.Run("process event", func(t *testing.T) {
event, err := ProcessEvent(testEvent.Type, testEvent.Path, testEventData)
assert.NoError(t, err)
require.NoError(t, err)
assert.NotNil(t, event)
assert.Equal(t, "test/test", event.Path)
})

t.Run("process event with empty path", func(t *testing.T) {
event, err := ProcessEvent(testEvent.Type, "", testEventData)
assert.Error(t, err)
require.Error(t, err)
assert.Empty(t, event)
})

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

t.Run("process issue_comment event", func(t *testing.T) {
event, err := ProcessEvent(testEvent.Type, testEvent.Path, testEventData)
assert.NoError(t, err)
require.NoError(t, err)
assert.NotNil(t, event)
assert.Equal(t, "issue_comment", event.Type)
})

t.Run("process invalid event", func(t *testing.T) {
event, err := ProcessEvent(testEvent.Type, testEvent.Path, randomData.Bytes())
assert.Error(t, err)
require.Error(t, err)
assert.Empty(t, event)
})
}

func TestGetIssueAssignees(t *testing.T) {
t.Run("get assignees", func(t *testing.T) {
assignees := testEvent.GetIssueAssignees()
assert.Equal(t, 1, len(assignees))
assert.Len(t, assignees, 1)
assert.Equal(t, "testAssignee", assignees[0])
})
}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dapr-bot/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/dapr/go-sdk/.github/workflows/dapr-bot

go 1.21
go 1.20

require (
github.com/google/go-github/v55 v55.0.0
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/dapr-bot/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-github/v55 v55.0.0 h1:4pp/1tNMB9X/LuAhs5i0KQAE40NmiR/y6prLNb9x9cg=
github.com/google/go-github/v55 v55.0.0/go.mod h1:JLahOTA1DnXzhxEymmFF5PP2tSS9JVNj68mSZNDwskA=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-on-tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Setup
uses: actions/setup-go@v3
with:
go-version: ^1.19
go-version: ^1.20

- name: Checkout
uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-dapr-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
fail-fast: false
matrix:
gover:
- "1.21"
- "1.20"
env:
GOVER: ${{ matrix.gover }}
GOLANGCILINT_VER: v1.54.2
GOLANGCILINT_VER: v1.55.2

steps:
- name: Setup
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/test-on-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ jobs:
fail-fast: false
matrix:
gover:
- "1.19"
- "1.20"
- "1.21"
env:
GOVER: ${{ matrix.gover }}
GOLANGCILINT_VER: v1.54.2
GOLANGCILINT_VER: v1.55.2

steps:
- name: Setup
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-tooling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ jobs:
fail-fast: false
matrix:
gover:
- "1.21"
- "1.20"
os:
- "ubuntu-latest"
- "windows-latest"
- "macos-latest"
runs-on: ${{ matrix.os }}
env:
GOVER: ${{ matrix.gover }}
GOLANGCILINT_VER: v1.54.2 # Make sure to bump /tools/check-lint-version/main_test.go
GOLANGCILINT_VER: v1.55.2 # Make sure to bump /tools/check-lint-version/main_test.go

steps:
- name: Setup
Expand Down
9 changes: 2 additions & 7 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,6 @@ linters-settings:
line-length: 120
# tab width in spaces. Default to 1.
tab-width: 1
unused:
# treat code as a program (not a library) and report unused exported identifiers; default is false.
# XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
# if it's called for subdir of a project it can't find funcs usages. All text editor integrations
# with golangci-lint call it on a directory with the changed file.
check-exported: false
unparam:
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
Expand Down Expand Up @@ -242,7 +236,7 @@ linters-settings:
# Allow multiline assignments to be cuddled. Default is true.
allow-multiline-assign: true
# Allow case blocks to end with a whitespace.
allow-case-traling-whitespace: true
force-case-trailing-whitespace: 0
# Allow declarations (var) to be cuddled.
allow-cuddle-declarations: false

Expand Down Expand Up @@ -310,6 +304,7 @@ linters:
- varcheck
- deadcode
- golint
- inamedparam
issues:
exclude-rules:
- path: .*_test.go
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
RELEASE_VERSION =v1.0.0-rc-3
GDOC_PORT =8888
GO_COMPAT_VERSION=1.19
GO_COMPAT_VERSION=1.20

.PHONY: all
all: help
Expand Down
2 changes: 1 addition & 1 deletion actor/manager/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func TestContainerInvoke(t *testing.T) {
mockCodec.EXPECT().Unmarshal([]byte(param), gomock.Any()).SetArg(1, "param").Return(nil)

rsp, err := container.Invoke("Invoke", []byte(param))
require.Equal(t, 2, len(rsp))
require.Len(t, rsp, 2)
require.Equal(t, actorErr.Success, err)
assert.Equal(t, param, rsp[0].Interface().(string))
}
4 changes: 2 additions & 2 deletions client/actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
out = &InvokeActorResponse{}

if resp != nil {
out.Data = resp.Data
out.Data = resp.GetData()
}

return out, nil
Expand Down Expand Up @@ -421,7 +421,7 @@
if err != nil {
return nil, fmt.Errorf("error invoking actor get state %s/%s: %w", in.ActorType, in.ActorID, err)
}
return &GetActorStateResponse{Data: rsp.Data}, nil
return &GetActorStateResponse{Data: rsp.GetData()}, nil

Check warning on line 424 in client/actor.go

View check run for this annotation

Codecov / codecov/patch

client/actor.go#L424

Added line #L424 was not covered by tests
}

type ActorStateOperation struct {
Expand Down
Loading
Loading