From 27fb38bf200f3d82eda3a8b875b5d9be184e5f69 Mon Sep 17 00:00:00 2001 From: Adam Gordon <3723289+gordon-to@users.noreply.github.com> Date: Thu, 14 Nov 2024 13:40:53 +0700 Subject: [PATCH] chore: update dependencies and fix ci --- .github/workflows/checks.yml | 27 ----------------------- .github/workflows/pr-checks.yml | 28 ++++++++++++++++++++++++ .github/workflows/tests.yml | 27 ----------------------- golangci.yml => .golangci.yml | 34 +++++------------------------ go.mod | 16 +++++++------- go.sum | 38 +++++++++++++++++++++------------ sign_test.go | 3 +-- vrf_test.go | 3 +-- 8 files changed, 67 insertions(+), 109 deletions(-) delete mode 100644 .github/workflows/checks.yml create mode 100644 .github/workflows/pr-checks.yml delete mode 100644 .github/workflows/tests.yml rename golangci.yml => .golangci.yml (86%) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml deleted file mode 100644 index cd0e54e..0000000 --- a/.github/workflows/checks.yml +++ /dev/null @@ -1,27 +0,0 @@ -on: [pull_request] -name: checks -env: - GO111MODULE: on - -jobs: - linter-check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - - name: golangci-lint - uses: golangci/golangci-lint-action@v2 - with: - version: 'latest' - args: --config ./golangci.yml - - vet-check: - runs-on: ubuntu-latest - steps: - - uses: actions/setup-go@v1 - with: - go-version: '1.15.x' - - uses: actions/checkout@v2 - - - name: Run go vet - run: go vet ./... \ No newline at end of file diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml new file mode 100644 index 0000000..7581c8e --- /dev/null +++ b/.github/workflows/pr-checks.yml @@ -0,0 +1,28 @@ +on: [pull_request] +name: pr-checks + +jobs: + golangci: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version-file: ./go.mod + - name: golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + version: v1.60 + args: --timeout 5m + unit-tests: + strategy: + matrix: + platform: [macos-latest, ubuntu-latest] + runs-on: ${{ matrix.platform }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version-file: ./go.mod + - name: Run unit tests + run: go test ./... -v diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index 8fc655a..0000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,27 +0,0 @@ -on: [pull_request] -name: tests -env: - GO111MODULE: on - -jobs: - unit-tests: - strategy: - matrix: - go-version: [1.15.x] - platform: [macos-latest, ubuntu-latest] - runs-on: ${{ matrix.platform }} - steps: - - uses: actions/setup-go@v1 - with: - go-version: ${{ matrix.go-version }} - - uses: actions/checkout@v2 - - - name: Cache go modules - uses: actions/cache@v1 - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('go.sum') }} - restore-keys: ${{ runner.os }}-go- - - - name: Run unit tests - run: go test ./... -v \ No newline at end of file diff --git a/golangci.yml b/.golangci.yml similarity index 86% rename from golangci.yml rename to .golangci.yml index 3336c4a..2b53fe1 100644 --- a/golangci.yml +++ b/.golangci.yml @@ -7,9 +7,6 @@ run: # default concurrency is a available CPU number concurrency: 4 - # timeout for analysis, e.g. 30s, 5m, default is 1m - deadline: 5m - # exit code when at least one issue was found, default is 1 issues-exit-code: 1 @@ -45,8 +42,6 @@ run: # output configuration options output: - # colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number" - format: colored-line-number # print lines of code with issue, default is true print-issued-lines: true @@ -60,23 +55,17 @@ linters-settings: errcheck: # report about not checking of errors in type assetions: `a := b.(MyStruct)`; # default is false: such cases aren't reported by default. - check-type-assertions: false + check-type-assertions: true # report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`; # default is false: such cases aren't reported by default. check-blank: false - # [deprecated] comma-separated list of pairs of the form pkg:regex - # the regex is used to ignore names within pkg. (default "fmt:.*"). - # see https://github.com/kisielk/errcheck#the-deprecated-method for details - ignore: fmt:.*,io/ioutil:^Read.* - # path to a file containing a list of functions to exclude from checking # see https://github.com/kisielk/errcheck#excluding-functions for details #exclude: /path/to/file.txt govet: # report about shadowed variables - check-shadowing: true # settings per analyzer settings: @@ -86,9 +75,6 @@ linters-settings: - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf - golint: - # minimal confidence for issues, default is 0.8 - min-confidence: 0.8 gofmt: # simplify code: gofmt with `-s` option, true by default simplify: true @@ -99,9 +85,6 @@ linters-settings: gocyclo: # minimal code complexity to report, 30 by default (but we recommend 10-20) min-complexity: 10 - maligned: - # print struct with more effective memory layout or not, false by default - suggest-new: true dupl: # tokens count to trigger issue, 150 by default threshold: 100 @@ -121,12 +104,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: @@ -163,15 +140,17 @@ linters-settings: linters: enable: - - megacheck + - staticcheck + - unused + - gosimple - govet - gofmt - goimports - gosec - errcheck +# - testpackage enable-all: false disable: - - maligned - prealloc - unparam disable-all: false @@ -223,9 +202,6 @@ issues: # Default value for this option is true. exclude-use-default: false - # Maximum issues count per one linter. Set to 0 to disable. Default is 50. - max-per-linter: 0 - # Maximum count of issues with the same text. Set to 0 to disable. Default is 3. max-same-issues: 0 diff --git a/go.mod b/go.mod index bed05e4..1e0b382 100644 --- a/go.mod +++ b/go.mod @@ -3,17 +3,17 @@ module github.com/ChainSafe/go-schnorrkel go 1.21 require ( - github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d - github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f + github.com/cosmos/go-bip39 v1.0.0 + github.com/gtank/merlin v0.1.1 github.com/gtank/ristretto255 v0.1.2 - github.com/stretchr/testify v1.4.0 - golang.org/x/crypto v0.1.0 + github.com/stretchr/testify v1.9.0 + golang.org/x/crypto v0.29.0 ) require ( - github.com/davecgh/go-spew v1.1.0 // indirect - github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/mimoo/StrobeGo v0.0.0-20220103164710-9a04d6ca976b // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/sys v0.1.0 // indirect - gopkg.in/yaml.v2 v2.2.2 // indirect + golang.org/x/sys v0.27.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 0899605..f7ccb9c 100644 --- a/go.sum +++ b/go.sum @@ -1,23 +1,33 @@ -github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d h1:49RLWk1j44Xu4fjHb6JFYmeUnDORVwHNkDxaQ0ctCVU= -github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= +github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f h1:8N8XWLZelZNibkhM1FuF+3Ad3YIbgirjdMiVA0eUkaM= -github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= +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/gtank/merlin v0.1.1 h1:eQ90iG7K9pOhtereWsmyRJ6RAwcP4tHTDBHXNg+u5is= +github.com/gtank/merlin v0.1.1/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= github.com/gtank/ristretto255 v0.1.2 h1:JEqUCPA1NvLq5DwYtuzigd7ss8fwbYay9fi4/5uMzcc= github.com/gtank/ristretto255 v0.1.2/go.mod h1:Ph5OpO6c7xKUGROZfWVLiJf9icMDwUeIvY4OmlYW69o= -github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 h1:hLDRPB66XQT/8+wG9WsDpiCvZf1yKO7sz7scAjSlBa0= github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= +github.com/mimoo/StrobeGo v0.0.0-20220103164710-9a04d6ca976b h1:QrHweqAtyJ9EwCaGHBu1fghwxIPiopAHV06JlXrMHjk= +github.com/mimoo/StrobeGo v0.0.0-20220103164710-9a04d6ca976b/go.mod h1:xxLb2ip6sSUts3g1irPVHyk/DGslwQsNOo9I7smJfNU= 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/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU= -golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= -golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +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= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ= +golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= +golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sign_test.go b/sign_test.go index 1d646b7..ab29d2b 100644 --- a/sign_test.go +++ b/sign_test.go @@ -2,7 +2,6 @@ package schnorrkel import ( "encoding/hex" - "errors" "fmt" "testing" @@ -223,5 +222,5 @@ func TestVerify_PublicKeyAtInfinity(t *testing.T) { transcript2 := merlin.NewTranscript("hello") _, err = pub.Verify(sig, transcript2) - require.True(t, errors.Is(err, errPublicKeyAtInfinity)) + require.ErrorIs(t, err, errPublicKeyAtInfinity) } diff --git a/vrf_test.go b/vrf_test.go index 0951fa8..d8704a8 100644 --- a/vrf_test.go +++ b/vrf_test.go @@ -1,7 +1,6 @@ package schnorrkel import ( - "errors" "fmt" "testing" @@ -297,5 +296,5 @@ func TestVRFVerify_PublicKeyAtInfinity(t *testing.T) { require.NoError(t, err) _, err = pub.VrfVerify(verifyTranscript, inout.Output(), proof) - require.True(t, errors.Is(err, errPublicKeyAtInfinity)) + require.ErrorIs(t, err, errPublicKeyAtInfinity) }