Skip to content

Commit

Permalink
sync: update CI config files (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
web3-bot authored Aug 29, 2022
1 parent 42d193d commit a39b231
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 40 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/go-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ jobs:
env:
RUNGOGENERATE: false
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: actions/setup-go@v2
- uses: actions/setup-go@v3
with:
go-version: "1.18.x"
go-version: "1.19.x"
- name: Run repo-specific setup
uses: ./.github/actions/go-check-setup
if: hashFiles('./.github/actions/go-check-setup') != ''
Expand All @@ -27,7 +27,7 @@ jobs:
echo "RUNGOGENERATE=true" >> $GITHUB_ENV
fi
- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@d7e217c1ff411395475b2971c0824e1e7cc1af98 # 2022.1 (v0.3.0)
run: go install honnef.co/go/tools/cmd/staticcheck@376210a89477dedbe6fdc4484b233998650d7b3c # 2022.1.3 (v0.3.3)
- name: Check that go.mod is tidy
uses: protocol/multiple-go-modules@v1.2
with:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/go-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ jobs:
fail-fast: false
matrix:
os: [ "ubuntu", "windows", "macos" ]
go: [ "1.17.x", "1.18.x" ]
go: [ "1.18.x", "1.19.x" ]
env:
COVERAGES: ""
runs-on: ${{ format('{0}-latest', matrix.os) }}
name: ${{ matrix.os }} (go ${{ matrix.go }})
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: actions/setup-go@v2
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
- name: Go information
Expand All @@ -43,7 +43,7 @@ jobs:
# Use -coverpkg=./..., so that we include cross-package coverage.
# If package ./A imports ./B, and ./A's tests also cover ./B,
# this means ./B's coverage will be significantly higher than 0%.
run: go test -v -coverprofile=module-coverage.txt -coverpkg=./... ./...
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.
uses: protocol/multiple-go-modules@v1.2
Expand All @@ -52,7 +52,7 @@ jobs:
with:
run: |
export "PATH=${{ env.PATH_386 }}:$PATH"
go test -v ./...
go test -v -shuffle=on ./...
- name: Run tests with race detector
if: ${{ matrix.os == 'ubuntu' }} # speed things up. Windows and OSX VMs are slow
uses: protocol/multiple-go-modules@v1.2
Expand All @@ -62,7 +62,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@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
with:
files: '${{ env.COVERAGES }}'
env_vars: OS=${{ matrix.os }}, GO=${{ matrix.go }}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/libp2p/go-yamux/v3

go 1.17
go 1.18

require (
github.com/libp2p/go-buffer-pool v0.0.2
Expand Down
3 changes: 1 addition & 2 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"log"
"math"
"net"
Expand Down Expand Up @@ -692,7 +691,7 @@ func (s *Session) handleStreamMessage(hdr header) error {
// Drain any data on the wire
if hdr.MsgType() == typeData && hdr.Length() > 0 {
s.logger.Printf("[WARN] yamux: Discarding data for stream: %d", id)
if _, err := io.CopyN(ioutil.Discard, s.reader, int64(hdr.Length())); err != nil {
if _, err := io.CopyN(io.Discard, s.reader, int64(hdr.Length())); err != nil {
s.logger.Printf("[ERR] yamux: Failed to discard data: %v", err)
return nil
}
Expand Down
4 changes: 1 addition & 3 deletions session_norace_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
//go:build !race
// +build !race

package yamux

import (
"bytes"
"context"
"io"
"io/ioutil"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -81,7 +79,7 @@ func TestSendData_VeryLarge(t *testing.T) {
return
}

recv, err := io.Copy(ioutil.Discard, stream)
recv, err := io.Copy(io.Discard, stream)
if err != nil {
t.Errorf("err: %v", err)
return
Expand Down
15 changes: 7 additions & 8 deletions session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"math/rand"
"net"
"reflect"
Expand Down Expand Up @@ -629,7 +628,7 @@ func TestSendData_Large(t *testing.T) {
func TestGoAway(t *testing.T) {
// This test is noisy.
conf := testConf()
conf.LogOutput = ioutil.Discard
conf.LogOutput = io.Discard

client, server := testClientServerConfig(conf)
defer client.Close()
Expand Down Expand Up @@ -1352,7 +1351,7 @@ func TestWindowOverflow(t *testing.T) {
msg := make([]byte, client.config.MaxStreamWindowSize*2)
hdr2 := encode(typeData, 0, i, uint32(len(msg)))
_ = client.sendMsg(hdr2, msg, nil)
_, err = ioutil.ReadAll(s)
_, err = io.ReadAll(s)
if err == nil {
t.Fatal("expected to read no data")
}
Expand Down Expand Up @@ -1483,7 +1482,7 @@ func TestStreamHalfClose2(t *testing.T) {
stream.CloseWrite()
wait <- struct{}{}

buf, err := ioutil.ReadAll(stream)
buf, err := io.ReadAll(stream)
if err != nil {
t.Error(err)
}
Expand All @@ -1507,7 +1506,7 @@ func TestStreamResetRead(t *testing.T) {
t.Error(err)
}

_, err = ioutil.ReadAll(stream)
_, err = io.ReadAll(stream)
if err == nil {
t.Errorf("expected reset")
}
Expand All @@ -1521,7 +1520,7 @@ func TestStreamResetRead(t *testing.T) {
go func() {
defer wc.Done()

_, err := ioutil.ReadAll(stream)
_, err := io.ReadAll(stream)
if err == nil {
t.Errorf("expected reset")
}
Expand Down Expand Up @@ -1572,7 +1571,7 @@ func TestLotsOfWritesWithStreamDeadline(t *testing.T) {
t.Error(err)
return
}
if b, err := ioutil.ReadAll(stream2); len(b) != 0 || err != ErrTimeout {
if b, err := io.ReadAll(stream2); len(b) != 0 || err != ErrTimeout {
t.Errorf("writes from the client should've expired; got: %v, bytes: %v", err, b)
return
}
Expand Down Expand Up @@ -1723,7 +1722,7 @@ func TestInitialStreamWindow(t *testing.T) {
if err != nil {
t.Fatal(err)
}
data, err := ioutil.ReadAll(str)
data, err := io.ReadAll(str)
if err != nil {
t.Fatal(err)
}
Expand Down
26 changes: 12 additions & 14 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,30 +40,28 @@ func min(values ...uint32) uint32 {

// The segmented buffer looks like:
//
// | data | empty space |
// < window (10) >
// < len (5) > < cap (5) >
// | data | empty space |
// < window (10) >
// < len (5) > < cap (5) >
//
// As data is read, the buffer gets updated like so:
//
// | data | empty space |
// < window (8) >
// < len (3) > < cap (5) >
// | data | empty space |
// < window (8) >
// < len (3) > < cap (5) >
//
// It can then grow as follows (given a "max" of 10):
//
//
// | data | empty space |
// < window (10) >
// < len (3) > < cap (7) >
// | data | empty space |
// < window (10) >
// < len (3) > < cap (7) >
//
// Data can then be written into the empty space, expanding len,
// and shrinking cap:
//
// | data | empty space |
// < window (10) >
// < len (5) > < cap (5) >
//
// | data | empty space |
// < window (10) >
// < len (5) > < cap (5) >
type segmentedBuffer struct {
cap uint32
len uint32
Expand Down
3 changes: 1 addition & 2 deletions util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package yamux
import (
"bytes"
"io"
"io/ioutil"
"testing"
)

Expand Down Expand Up @@ -93,7 +92,7 @@ func TestSegmentedBuffer(t *testing.T) {
if grew, amount := buf.GrowTo(100, false); grew || amount != 0 {
t.Fatal("should not grow when data hasn't been read")
}
read, err := io.CopyN(ioutil.Discard, &buf, 50)
read, err := io.CopyN(io.Discard, &buf, 50)
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit a39b231

Please sign in to comment.