Skip to content

Commit

Permalink
Merge pull request #9 from michurin/ci
Browse files Browse the repository at this point in the history
CI: update actions, linter, minor cosmetics
  • Loading branch information
michurin committed Jul 6, 2024
2 parents 3d138bb + fbfa834 commit 0e9d6b9
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 31 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ jobs:
- "1.19"
- "1.20"
- "1.21"
- "1.22"
name: "Go ${{ matrix.go }} build"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: "${{ matrix.go }}"
- run: "go version"
Expand All @@ -29,14 +30,15 @@ jobs:
name: "Test and lint"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21"
- uses: golangci/golangci-lint-action@v3
go-version: "1.22"
- uses: golangci/golangci-lint-action@v6
with:
version: "v1.55"
version: "v1.59"
- run: "go test -v -race -coverprofile=coverage.txt -covermode=atomic ./netpunchlib/..."
- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }} # required
files: ./coverage.txt
verbose: true
47 changes: 28 additions & 19 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
linters:
enable-all: true
disable:
- wrapcheck
- paralleltest
- gomnd
# nice to be turned on
- wsl
- 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
- err113
- mnd
- wrapcheck
# deprecated
- interfacer
- maligned
- scopelint
- golint
- exhaustivestruct # since v1.46.0
- varcheck # since v1.49.0
- nosnakecase # since v1.48.1
- deadcode # since v1.49.0
- structcheck # since v1.49.0
- ifshort # since v1.48.0
- gomnd
- execinquery
# disabled because the Go version
- copyloopvar
- intrange

linters-settings:
paralleltest:
ignore-missing: true
cyclop:
max-complexity: 20
funlen:
Expand All @@ -42,6 +34,23 @@ linters-settings:
- standard
- default
- prefix(github.com/michurin/netpunch/netpunchlib)
depguard:
rules:
regular:
files:
- !$test
allow:
- $gostd
- github.com/michurin/netpunch/netpunchlib
tests:
files:
- $test
allow:
- $gostd
- github.com/michurin/netpunch/netpunchlib
- github.com/stretchr/testify/assert
- github.com/stretchr/testify/require
- github.com/golang/mock/gomock

issues:
exclude-rules:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/golang/mock v1.6.0
github.com/stretchr/testify v1.8.4
github.com/stretchr/testify v1.9.0
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
Expand Down
4 changes: 2 additions & 2 deletions netpunchlib/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package netpunchlib
import "net"

type ConnectionReader interface {
ReadFromUDP([]byte) (int, *net.UDPAddr, error)
ReadFromUDP(data []byte) (int, *net.UDPAddr, error)
}

type ConnectionWriter interface {
WriteToUDP([]byte, *net.UDPAddr) (int, error)
WriteToUDP(data []byte, addr *net.UDPAddr) (int, error)
}

type ConnectionCloser interface {
Expand Down
2 changes: 1 addition & 1 deletion netpunchlib/mw_sign_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,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") //nolint:testifylint
assert.Errorf(t, err, "TestErr")
}

func TestReadFromUDP_ok(t *testing.T) {
Expand Down

0 comments on commit 0e9d6b9

Please sign in to comment.