Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

sync: update CI config files #272

Merged
merged 5 commits into from
Oct 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/[email protected]
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/[email protected]
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/[email protected]
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,4 +1,4 @@
go 1.17
go 1.18

module github.com/ipfs/go-ipfs-api

Expand Down
17 changes: 10 additions & 7 deletions mfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"context"
"fmt"
"io/ioutil"
"io"
"os"
"testing"

Expand Down Expand Up @@ -144,7 +144,7 @@ func TestFilesRead(t *testing.T) {
reader, err := s.FilesRead(context.Background(), "/testdata/readme", FilesRead.Offset(0), FilesRead.Count(5))
is.Nil(err)

resBytes, err := ioutil.ReadAll(reader)
resBytes, err := io.ReadAll(reader)
is.Nil(err)
is.Equal(string(resBytes), "Hello")
}
Expand All @@ -153,7 +153,7 @@ func TestFilesRm(t *testing.T) {
is := is.New(t)
s := NewShell(shellUrl)

file, _ := ioutil.ReadFile("./testdata/ping")
file, _ := os.ReadFile("./testdata/ping")
err := s.FilesWrite(context.Background(), "/testdata/dir1/ping", bytes.NewBuffer(file), FilesWrite.Parents(true), FilesWrite.Create(true))
is.Nil(err)

Expand Down Expand Up @@ -185,7 +185,7 @@ func TestFilesWrite(t *testing.T) {
is := is.New(t)
s := NewShell(shellUrl)

file, err := ioutil.ReadFile("./testdata/ping")
file, err := os.ReadFile("./testdata/ping")
is.Nil(err)

err = s.FilesWrite(context.Background(), "/testdata/ping", bytes.NewBuffer(file), FilesWrite.Create(true), FilesWrite.RawLeaves(true), FilesWrite.CidVersion(1), FilesWrite.Hash("sha3-256"))
Expand All @@ -194,11 +194,11 @@ func TestFilesWrite(t *testing.T) {
reader, err := s.FilesRead(context.Background(), "/testdata/ping")
is.Nil(err)

resBytes, err := ioutil.ReadAll(reader)
resBytes, err := io.ReadAll(reader)
is.Nil(err)
is.Equal(string(resBytes), "ipfs")

file, err = ioutil.ReadFile("./testdata/ping")
file, err = os.ReadFile("./testdata/ping")
is.Nil(err)

err = s.FilesWrite(context.Background(), "/testdata/ping", bytes.NewBuffer(file), FilesWrite.Offset(0), FilesWrite.Count(2), FilesWrite.Truncate(true))
Expand All @@ -207,7 +207,10 @@ func TestFilesWrite(t *testing.T) {
reader, err = s.FilesRead(context.Background(), "/testdata/ping")
is.Nil(err)

resBytes, err = ioutil.ReadAll(reader)
resBytes, err = io.ReadAll(reader)
is.Nil(err)
is.Equal(string(resBytes), "ip")

err = s.FilesRm(context.Background(), "/testdata/ping", true)
is.Nil(err)
}
9 changes: 4 additions & 5 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"os"
Expand Down Expand Up @@ -70,7 +69,7 @@ type Response struct {
func (r *Response) Close() error {
if r.Output != nil {
// always drain output (response body)
_, err1 := io.Copy(ioutil.Discard, r.Output)
_, err1 := io.Copy(io.Discard, r.Output)
err2 := r.Output.Close()
if err1 != nil {
return err1
Expand Down Expand Up @@ -147,7 +146,7 @@ func (r *Request) Send(c *http.Client) (*Response, error) {
case resp.StatusCode == http.StatusNotFound:
e.Message = "command not found"
case contentType == "text/plain":
out, err := ioutil.ReadAll(resp.Body)
out, err := io.ReadAll(resp.Body)
if err != nil {
fmt.Fprintf(os.Stderr, "ipfs-shell: warning! response (%d) read error: %s\n", resp.StatusCode, err)
}
Expand All @@ -158,7 +157,7 @@ func (r *Request) Send(c *http.Client) (*Response, error) {
}
default:
fmt.Fprintf(os.Stderr, "ipfs-shell: warning! unhandled response (%d) encoding: %s", resp.StatusCode, contentType)
out, err := ioutil.ReadAll(resp.Body)
out, err := io.ReadAll(resp.Body)
if err != nil {
fmt.Fprintf(os.Stderr, "ipfs-shell: response (%d) read error: %s\n", resp.StatusCode, err)
}
Expand All @@ -168,7 +167,7 @@ func (r *Request) Send(c *http.Client) (*Response, error) {
nresp.Output = nil

// drain body and close
io.Copy(ioutil.Discard, resp.Body)
io.Copy(io.Discard, resp.Body)
resp.Body.Close()
}

Expand Down
8 changes: 4 additions & 4 deletions shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net"
gohttp "net/http"
"os"
Expand Down Expand Up @@ -55,7 +54,7 @@ func NewLocalShell() *Shell {
return nil
}

api, err := ioutil.ReadFile(apiFile)
api, err := os.ReadFile(apiFile)
if err != nil {
return nil
}
Expand Down Expand Up @@ -145,7 +144,8 @@ type IdOutput struct {
// ID gets information about a given peer. Arguments:
//
// peer: peer.ID of the node to look up. If no peer is specified,
// return information about the local peer.
//
// return information about the local peer.
func (s *Shell) ID(peer ...string) (*IdOutput, error) {
if len(peer) > 1 {
return nil, fmt.Errorf("too many peer arguments")
Expand Down Expand Up @@ -460,7 +460,7 @@ func (s *Shell) BlockGet(path string) ([]byte, error) {
return nil, resp.Error
}

return ioutil.ReadAll(resp.Output)
return io.ReadAll(resp.Output)
}

func (s *Shell) BlockPut(block []byte, format, mhtype string, mhlen int) (string, error) {
Expand Down
3 changes: 1 addition & 2 deletions shell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"crypto/md5"
"fmt"
"io"
"io/ioutil"
"math/rand"
"net"
"net/http"
Expand Down Expand Up @@ -465,7 +464,7 @@ func TestNewShellWithUnixSocket(t *testing.T) {
is := is.New(t)

// setup uds temporary dir
path, err := ioutil.TempDir("", "uds-test")
path, err := os.MkdirTemp("", "uds-test")
is.Nil(err)

defer os.RemoveAll(path)
Expand Down
2 changes: 1 addition & 1 deletion tests/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"math/rand"
"time"

"github.com/ipfs/go-ipfs-api"
shell "github.com/ipfs/go-ipfs-api"

u "github.com/ipfs/go-ipfs-util"
)
Expand Down