sync: update CI config files (#2073)
* bump go.mod to Go 1.19 and run go fix * stop using the deprecated io/ioutil package * bump go.mod to Go 1.19 and run go fix * bump go.mod to Go 1.19 and run go fix * bump go.mod to Go 1.19 and run go fix * stop using the deprecated io/ioutil package * bump go.mod to Go 1.19 and run go fix * stop using the deprecated io/ioutil package * update .github/workflows/go-test.yml * update .github/workflows/go-check.yml * update .github/workflows/release-check.yml * various fixes * stop using deprecated math/rand.Read --------- Co-authored-by: web3-bot <web3-bot@users.noreply.github.com> Co-authored-by: Marten Seemann <martenseemann@gmail.com>
This commit is contained in:
parent
985683722c
commit
3a66ff89a1
|
@ -8,26 +8,20 @@ jobs:
|
|||
unit:
|
||||
runs-on: ubuntu-latest
|
||||
name: All
|
||||
env:
|
||||
RUNGOGENERATE: false
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
- id: config
|
||||
uses: protocol/.github/.github/actions/read-config@master
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: "1.19.x"
|
||||
go-version: 1.20.x
|
||||
- name: Run repo-specific setup
|
||||
uses: ./.github/actions/go-check-setup
|
||||
if: hashFiles('./.github/actions/go-check-setup') != ''
|
||||
- name: Read config
|
||||
if: hashFiles('./.github/workflows/go-check-config.json') != ''
|
||||
run: |
|
||||
if jq -re .gogenerate ./.github/workflows/go-check-config.json; then
|
||||
echo "RUNGOGENERATE=true" >> $GITHUB_ENV
|
||||
fi
|
||||
- name: Install staticcheck
|
||||
run: go install honnef.co/go/tools/cmd/staticcheck@376210a89477dedbe6fdc4484b233998650d7b3c # 2022.1.3 (v0.3.3)
|
||||
run: go install honnef.co/go/tools/cmd/staticcheck@4970552d932f48b71485287748246cf3237cebdf # 2023.1 (v0.4.0)
|
||||
- name: Check that go.mod is tidy
|
||||
uses: protocol/multiple-go-modules@v1.2
|
||||
with:
|
||||
|
@ -39,7 +33,7 @@ jobs:
|
|||
fi
|
||||
git diff --exit-code -- go.sum go.mod
|
||||
- name: gofmt
|
||||
if: ${{ success() || failure() }} # run this step even if the previous one failed
|
||||
if: success() || failure() # run this step even if the previous one failed
|
||||
run: |
|
||||
out=$(gofmt -s -l .)
|
||||
if [[ -n "$out" ]]; then
|
||||
|
@ -47,12 +41,12 @@ jobs:
|
|||
exit 1
|
||||
fi
|
||||
- name: go vet
|
||||
if: ${{ success() || failure() }} # run this step even if the previous one failed
|
||||
if: success() || failure() # run this step even if the previous one failed
|
||||
uses: protocol/multiple-go-modules@v1.2
|
||||
with:
|
||||
run: go vet ./...
|
||||
- name: staticcheck
|
||||
if: ${{ success() || failure() }} # run this step even if the previous one failed
|
||||
if: success() || failure() # run this step even if the previous one failed
|
||||
uses: protocol/multiple-go-modules@v1.2
|
||||
with:
|
||||
run: |
|
||||
|
@ -60,11 +54,11 @@ jobs:
|
|||
staticcheck ./... | sed -e 's@\(.*\)\.go@./\1.go@g'
|
||||
- name: go generate
|
||||
uses: protocol/multiple-go-modules@v1.2
|
||||
if: (success() || failure()) && env.RUNGOGENERATE == 'true'
|
||||
if: (success() || failure()) && fromJSON(steps.config.outputs.json).gogenerate == true
|
||||
with:
|
||||
run: |
|
||||
git clean -fd # make sure there aren't untracked files / directories
|
||||
go generate ./...
|
||||
go generate -x ./...
|
||||
# check if go generate modified or added any files
|
||||
if ! $(git add . && git diff-index HEAD --exit-code --quiet); then
|
||||
echo "go generated caused changes to the repository:"
|
||||
|
|
|
@ -10,15 +10,17 @@ jobs:
|
|||
fail-fast: false
|
||||
matrix:
|
||||
os: [ "ubuntu", "windows", "macos" ]
|
||||
go: [ "1.18.x", "1.19.x" ]
|
||||
go: ["1.19.x","1.20.x"]
|
||||
env:
|
||||
COVERAGES: ""
|
||||
runs-on: ${{ format('{0}-latest', matrix.os) }}
|
||||
runs-on: ${{ fromJSON(vars[format('UCI_GO_TEST_RUNNER_{0}', matrix.os)] || format('"{0}-latest"', matrix.os)) }}
|
||||
name: ${{ matrix.os }} (go ${{ matrix.go }})
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
- id: config
|
||||
uses: protocol/.github/.github/actions/read-config@master
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: ${{ matrix.go }}
|
||||
|
@ -27,7 +29,7 @@ jobs:
|
|||
go version
|
||||
go env
|
||||
- name: Use msys2 on windows
|
||||
if: ${{ matrix.os == 'windows' }}
|
||||
if: matrix.os == 'windows'
|
||||
shell: bash
|
||||
# The executable for msys2 is also called bash.cmd
|
||||
# https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md#shells
|
||||
|
@ -38,6 +40,7 @@ jobs:
|
|||
uses: ./.github/actions/go-test-setup
|
||||
if: hashFiles('./.github/actions/go-test-setup') != ''
|
||||
- name: Run tests
|
||||
if: contains(fromJSON(steps.config.outputs.json).skipOSes, matrix.os) == false
|
||||
uses: protocol/multiple-go-modules@v1.2
|
||||
with:
|
||||
# Use -coverpkg=./..., so that we include cross-package coverage.
|
||||
|
@ -45,16 +48,21 @@ jobs:
|
|||
# this means ./B's coverage will be significantly higher than 0%.
|
||||
run: go test -v -shuffle=on -coverprofile=module-coverage.txt -coverpkg=./... ./...
|
||||
- name: Run tests (32 bit)
|
||||
if: ${{ matrix.os != 'macos' }} # can't run 32 bit tests on OSX.
|
||||
# can't run 32 bit tests on OSX.
|
||||
if: matrix.os != 'macos' &&
|
||||
fromJSON(steps.config.outputs.json).skip32bit != true &&
|
||||
contains(fromJSON(steps.config.outputs.json).skipOSes, matrix.os) == false
|
||||
uses: protocol/multiple-go-modules@v1.2
|
||||
env:
|
||||
GOARCH: 386
|
||||
with:
|
||||
run: |
|
||||
export "PATH=${{ env.PATH_386 }}:$PATH"
|
||||
export "PATH=$PATH_386:$PATH"
|
||||
go test -v -shuffle=on ./...
|
||||
- name: Run tests with race detector
|
||||
if: ${{ matrix.os == 'ubuntu' }} # speed things up. Windows and OSX VMs are slow
|
||||
# speed things up. Windows and OSX VMs are slow
|
||||
if: matrix.os == 'ubuntu' &&
|
||||
contains(fromJSON(steps.config.outputs.json).skipOSes, matrix.os) == false
|
||||
uses: protocol/multiple-go-modules@v1.2
|
||||
with:
|
||||
run: go test -v -race ./...
|
||||
|
@ -62,7 +70,7 @@ jobs:
|
|||
shell: bash
|
||||
run: echo "COVERAGES=$(find . -type f -name 'module-coverage.txt' | tr -s '\n' ',' | sed 's/,$//')" >> $GITHUB_ENV
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
|
||||
uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1
|
||||
with:
|
||||
files: '${{ env.COVERAGES }}'
|
||||
env_vars: OS=${{ matrix.os }}, GO=${{ matrix.go }}
|
||||
|
|
|
@ -3,9 +3,11 @@
|
|||
|
||||
name: Release Checker
|
||||
on:
|
||||
pull_request:
|
||||
pull_request_target:
|
||||
paths: [ 'version.json' ]
|
||||
|
||||
jobs:
|
||||
release-check:
|
||||
uses: protocol/.github/.github/workflows/release-check.yml@master
|
||||
with:
|
||||
go-version: 1.20.x
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package test
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"crypto/rand"
|
||||
"testing"
|
||||
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module github.com/libp2p/go-libp2p/examples
|
||||
|
||||
go 1.18
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/gogo/protobuf v1.3.2
|
||||
|
|
|
@ -5,8 +5,9 @@ package main
|
|||
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
math "math"
|
||||
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
|
|
|
@ -5,8 +5,9 @@ package main
|
|||
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
math "math"
|
||||
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module github.com/libp2p/go-libp2p/examples/ipfs-camp-2019
|
||||
|
||||
go 1.18
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/gogo/protobuf v1.3.2
|
||||
|
|
|
@ -13,9 +13,9 @@ import (
|
|||
)
|
||||
|
||||
func main() {
|
||||
rnd := rand.New(rand.NewSource(666))
|
||||
// Choose random ports between 10000-10100
|
||||
rand.Seed(666)
|
||||
port1 := rand.Intn(100) + 10000
|
||||
port1 := rnd.Intn(100) + 10000
|
||||
port2 := port1 + 1
|
||||
|
||||
done := make(chan bool, 1)
|
||||
|
|
|
@ -3,9 +3,13 @@
|
|||
|
||||
package protocols_p2p
|
||||
|
||||
import proto "github.com/gogo/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
import (
|
||||
fmt "fmt"
|
||||
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
|
||||
math "math"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module github.com/libp2p/go-libp2p/examples/pubsub/chat
|
||||
|
||||
go 1.18
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/libp2p/go-libp2p v0.25.1
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module github.com/libp2p/go-libp2p/examples/pubsub/chat
|
||||
|
||||
go 1.18
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/gdamore/tcell/v2 v2.5.2
|
||||
|
|
2
go.mod
2
go.mod
|
@ -1,6 +1,6 @@
|
|||
module github.com/libp2p/go-libp2p
|
||||
|
||||
go 1.18
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/benbjohnson/clock v1.3.0
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
//go:build linux || darwin
|
||||
// +build linux darwin
|
||||
|
||||
package rcmgr
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package pnet
|
|||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"math/rand"
|
||||
"crypto/rand"
|
||||
"net"
|
||||
"testing"
|
||||
)
|
||||
|
@ -62,8 +62,7 @@ func TestPSKFragmentation(t *testing.T) {
|
|||
psk1, psk2 := setupPSKConns(ctx, t)
|
||||
|
||||
in := make([]byte, 1000)
|
||||
_, err := rand.Read(in)
|
||||
if err != nil {
|
||||
if _, err := rand.Read(in); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -85,8 +84,7 @@ func TestPSKFragmentation(t *testing.T) {
|
|||
in = in[100:]
|
||||
}
|
||||
|
||||
err = <-wch
|
||||
if err != nil {
|
||||
if err := <-wch; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,9 +3,9 @@ package relay_test
|
|||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
"io"
|
||||
"math/rand"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
@ -325,8 +325,7 @@ func TestRelayLimitData(t *testing.T) {
|
|||
|
||||
buf := make([]byte, 1024)
|
||||
for i := 0; i < 3; i++ {
|
||||
_, err = rand.Read(buf)
|
||||
if err != nil {
|
||||
if _, err := rand.Read(buf); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -345,8 +344,7 @@ func TestRelayLimitData(t *testing.T) {
|
|||
}
|
||||
|
||||
buf = make([]byte, 4096)
|
||||
_, err = rand.Read(buf)
|
||||
if err != nil {
|
||||
if _, err := rand.Read(buf); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
|
@ -271,12 +271,6 @@ func TestPeerIDOutboundNoCheck(t *testing.T) {
|
|||
require.NoError(t, initErr)
|
||||
}
|
||||
|
||||
func makeLargePlaintext(size int) []byte {
|
||||
buf := make([]byte, size)
|
||||
rand.Read(buf)
|
||||
return buf
|
||||
}
|
||||
|
||||
func TestLargePayloads(t *testing.T) {
|
||||
initTransport := newTestTransport(t, crypto.Ed25519, 2048)
|
||||
respTransport := newTestTransport(t, crypto.Ed25519, 2048)
|
||||
|
@ -287,11 +281,12 @@ func TestLargePayloads(t *testing.T) {
|
|||
|
||||
// enough to require a couple Noise messages, with a size that
|
||||
// isn't a neat multiple of Noise message size, just in case
|
||||
size := 100000
|
||||
rnd := rand.New(rand.NewSource(1234))
|
||||
const size = 100000
|
||||
before := make([]byte, size)
|
||||
rnd.Read(before)
|
||||
|
||||
before := makeLargePlaintext(size)
|
||||
_, err := initConn.Write(before)
|
||||
if err != nil {
|
||||
if _, err := initConn.Write(before); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ func runRound(t *testing.T, hosts []host.Host) {
|
|||
numStreams = 5
|
||||
maxDataLen = 64 << 10
|
||||
)
|
||||
rnd := rand.New(rand.NewSource(12345))
|
||||
// exchange some data
|
||||
for _, h1 := range hosts {
|
||||
for _, h2 := range hosts {
|
||||
|
@ -80,10 +81,10 @@ func runRound(t *testing.T, hosts []host.Host) {
|
|||
var wg sync.WaitGroup
|
||||
wg.Add(numStreams)
|
||||
for i := 0; i < numStreams; i++ {
|
||||
data := make([]byte, rand.Intn(maxDataLen)+1)
|
||||
rnd.Read(data)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
data := make([]byte, rand.Intn(maxDataLen)+1)
|
||||
rand.Read(data)
|
||||
str, err := h1.NewStream(context.Background(), h2.ID(), protocol.TestingID)
|
||||
require.NoError(t, err)
|
||||
defer str.Close()
|
||||
|
|
|
@ -45,6 +45,7 @@ type transport struct {
|
|||
|
||||
holePunchingMx sync.Mutex
|
||||
holePunching map[holePunchKey]*activeHolePunch
|
||||
rnd rand.Rand
|
||||
|
||||
connMx sync.Mutex
|
||||
conns map[quic.Connection]*conn
|
||||
|
@ -94,6 +95,7 @@ func NewTransport(key ic.PrivKey, connManager *quicreuse.ConnManager, psk pnet.P
|
|||
rcmgr: rcmgr,
|
||||
conns: make(map[quic.Connection]*conn),
|
||||
holePunching: make(map[holePunchKey]*activeHolePunch),
|
||||
rnd: *rand.New(rand.NewSource(time.Now().UnixNano())),
|
||||
|
||||
listeners: make(map[string][]*virtualListener),
|
||||
}, nil
|
||||
|
@ -217,7 +219,7 @@ func (t *transport) holePunch(ctx context.Context, raddr ma.Multiaddr, p peer.ID
|
|||
var punchErr error
|
||||
loop:
|
||||
for i := 0; ; i++ {
|
||||
if _, err := rand.Read(payload); err != nil {
|
||||
if _, err := t.rnd.Read(payload); err != nil {
|
||||
punchErr = err
|
||||
break
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue