Skip to content

Commit

Permalink
CI: enable manual running, update linter. Tests: minor cosmetics
Browse files Browse the repository at this point in the history
  • Loading branch information
michurin committed Jan 21, 2024
1 parent 02418d8 commit bc9900b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: build # this string appears on badge
on:
- push
- pull_request
- workflow_dispatch
jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -15,7 +16,7 @@ jobs:
- "1.21"
name: "Go ${{ matrix.go }} build"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "${{ matrix.go }}"
Expand All @@ -27,13 +28,13 @@ jobs:
runs-on: ubuntu-latest
name: "Test and lint"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "1.21"
- uses: golangci/golangci-lint-action@v3
with:
version: "v1.54"
version: "v1.55"
- run: "go test -v -race -coverprofile=coverage.txt -covermode=atomic ./netpunchlib/..."
- uses: codecov/codecov-action@v3
with:
Expand Down
1 change: 1 addition & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ linters:
- nlreturn
- depguard
- goerr113 # TODO: has to be turned on
- inamedparam
# disabled in golangci-lint v1.45.2 due to 1.18
- contextcheck
- staticcheck # TODO: has to be turned on
Expand Down
2 changes: 1 addition & 1 deletion netpunchlib/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ LOOP:
for role, res := range results {
assert.Len(t, res.role, 1)
assert.Equal(t, res.role, role)
assert.NoError(t, res.err)
assert.NoError(t, res.err) //nolint:testifylint
slotA := int([]byte(role)[0] - 'a')
slotB := slotA ^ 1
assert.Equal(t, peerBasePort+slotA, res.a.Port)
Expand Down
9 changes: 5 additions & 4 deletions netpunchlib/mw_sign_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/michurin/netpunch/netpunchlib"
"github.com/michurin/netpunch/netpunchlib/internal/mock"
Expand All @@ -22,7 +23,7 @@ func TestClose(t *testing.T) {
conn := netpunchlib.SigningMiddleware([]byte("MORN"))(m)
err := conn.Close()

assert.NoError(t, err)
require.NoError(t, err)
}

func TestWriteToUDP_ok(t *testing.T) {
Expand All @@ -35,8 +36,8 @@ func TestWriteToUDP_ok(t *testing.T) {
conn := netpunchlib.SigningMiddleware([]byte("MORN"))(m)
n, err := conn.WriteToUDP([]byte("data"), nil)

require.NoError(t, err)
assert.Equal(t, 4, n)
assert.NoError(t, err)
}

func TestWriteToUDP_error(t *testing.T) {
Expand All @@ -50,7 +51,7 @@ func TestWriteToUDP_error(t *testing.T) {
n, err := conn.WriteToUDP([]byte("data"), nil)

assert.Equal(t, 0, n)
assert.Errorf(t, err, "TestErr")
assert.Errorf(t, err, "TestErr") //nolint:testifylint
}

func TestReadFromUDP_ok(t *testing.T) {
Expand All @@ -68,8 +69,8 @@ func TestReadFromUDP_ok(t *testing.T) {
buff := make([]byte, 1024)
n, addr, err := conn.ReadFromUDP(buff)

require.NoError(t, err)
assert.Equal(t, 4, n)
assert.Equal(t, []byte("data"), buff[:n])
assert.Nil(t, addr)
assert.NoError(t, err)
}

0 comments on commit bc9900b

Please sign in to comment.