Skip to content

Commit 04c7b6f

Browse files
authored
sync: update CI config files (#195)
* bump go.mod to Go 1.18 and run go fix * stop using the deprecated io/ioutil package * bump go.mod to Go 1.18 and run go fix * stop using the deprecated io/ioutil package * update .github/workflows/go-test.yml * update .github/workflows/go-check.yml Co-authored-by: web3-bot <[email protected]>
1 parent 1de4708 commit 04c7b6f

File tree

17 files changed

+140
-133
lines changed

17 files changed

+140
-133
lines changed

.github/workflows/go-check.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ jobs:
1111
env:
1212
RUNGOGENERATE: false
1313
steps:
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v3
1515
with:
1616
submodules: recursive
17-
- uses: actions/setup-go@v2
17+
- uses: actions/setup-go@v3
1818
with:
19-
go-version: "1.18.x"
19+
go-version: "1.19.x"
2020
- name: Run repo-specific setup
2121
uses: ./.github/actions/go-check-setup
2222
if: hashFiles('./.github/actions/go-check-setup') != ''
@@ -27,7 +27,7 @@ jobs:
2727
echo "RUNGOGENERATE=true" >> $GITHUB_ENV
2828
fi
2929
- name: Install staticcheck
30-
run: go install honnef.co/go/tools/cmd/staticcheck@d7e217c1ff411395475b2971c0824e1e7cc1af98 # 2022.1 (v0.3.0)
30+
run: go install honnef.co/go/tools/cmd/staticcheck@376210a89477dedbe6fdc4484b233998650d7b3c # 2022.1.3 (v0.3.3)
3131
- name: Check that go.mod is tidy
3232
uses: protocol/[email protected]
3333
with:

.github/workflows/go-test.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
os: [ "ubuntu", "windows", "macos" ]
13-
go: [ "1.17.x", "1.18.x" ]
13+
go: [ "1.18.x", "1.19.x" ]
1414
env:
1515
COVERAGES: ""
1616
runs-on: ${{ format('{0}-latest', matrix.os) }}
1717
name: ${{ matrix.os }} (go ${{ matrix.go }})
1818
steps:
19-
- uses: actions/checkout@v2
19+
- uses: actions/checkout@v3
2020
with:
2121
submodules: recursive
22-
- uses: actions/setup-go@v2
22+
- uses: actions/setup-go@v3
2323
with:
2424
go-version: ${{ matrix.go }}
2525
- name: Go information
@@ -43,7 +43,7 @@ jobs:
4343
# Use -coverpkg=./..., so that we include cross-package coverage.
4444
# If package ./A imports ./B, and ./A's tests also cover ./B,
4545
# this means ./B's coverage will be significantly higher than 0%.
46-
run: go test -v -coverprofile=module-coverage.txt -coverpkg=./... ./...
46+
run: go test -v -shuffle=on -coverprofile=module-coverage.txt -coverpkg=./... ./...
4747
- name: Run tests (32 bit)
4848
if: ${{ matrix.os != 'macos' }} # can't run 32 bit tests on OSX.
4949
uses: protocol/[email protected]
@@ -52,7 +52,7 @@ jobs:
5252
with:
5353
run: |
5454
export "PATH=${{ env.PATH_386 }}:$PATH"
55-
go test -v ./...
55+
go test -v -shuffle=on ./...
5656
- name: Run tests with race detector
5757
if: ${{ matrix.os == 'ubuntu' }} # speed things up. Windows and OSX VMs are slow
5858
uses: protocol/[email protected]
@@ -62,7 +62,7 @@ jobs:
6262
shell: bash
6363
run: echo "COVERAGES=$(find . -type f -name 'module-coverage.txt' | tr -s '\n' ',' | sed 's/,$//')" >> $GITHUB_ENV
6464
- name: Upload coverage to Codecov
65-
uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
65+
uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
6666
with:
6767
files: '${{ env.COVERAGES }}'
6868
env_vars: OS=${{ matrix.os }}, GO=${{ matrix.go }}

basic_ds_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package datastore_test
22

33
import (
4-
"io/ioutil"
4+
"io"
55
"log"
66
"testing"
77

@@ -16,7 +16,7 @@ func TestMapDatastore(t *testing.T) {
1616

1717
func TestLogDatastore(t *testing.T) {
1818
defer log.SetOutput(log.Writer())
19-
log.SetOutput(ioutil.Discard)
19+
log.SetOutput(io.Discard)
2020
ds := datastore.NewLogDatastore(datastore.NewMapDatastore(), "")
2121
dstest.SubtestAll(t, ds)
2222
}

datastore.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,9 @@ var ErrNotFound error = &dsError{error: errors.New("datastore: key not found"),
201201
// GetBackedHas provides a default Datastore.Has implementation.
202202
// It exists so Datastore.Has implementations can use it, like so:
203203
//
204-
// func (*d SomeDatastore) Has(key Key) (exists bool, err error) {
205-
// return GetBackedHas(d, key)
206-
// }
204+
// func (*d SomeDatastore) Has(key Key) (exists bool, err error) {
205+
// return GetBackedHas(d, key)
206+
// }
207207
func GetBackedHas(ctx context.Context, ds Read, key Key) (bool, error) {
208208
_, err := ds.Get(ctx, key)
209209
switch err {
@@ -219,9 +219,9 @@ func GetBackedHas(ctx context.Context, ds Read, key Key) (bool, error) {
219219
// GetBackedSize provides a default Datastore.GetSize implementation.
220220
// It exists so Datastore.GetSize implementations can use it, like so:
221221
//
222-
// func (*d SomeDatastore) GetSize(key Key) (size int, err error) {
223-
// return GetBackedSize(d, key)
224-
// }
222+
// func (*d SomeDatastore) GetSize(key Key) (size int, err error) {
223+
// return GetBackedSize(d, key)
224+
// }
225225
func GetBackedSize(ctx context.Context, ds Read, key Key) (int, error) {
226226
value, err := ds.Get(ctx, key)
227227
if err == nil {

examples/fs.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
// This means key some segments will not work. For example, the
66
// following keys will result in unwanted behavior:
77
//
8-
// - "/foo/./bar"
9-
// - "/foo/../bar"
10-
// - "/foo\x00bar"
8+
// - "/foo/./bar"
9+
// - "/foo/../bar"
10+
// - "/foo\x00bar"
1111
//
1212
// Keys that only differ in case may be confused with each other on
1313
// case insensitive file systems, for example in OS X.
@@ -20,7 +20,6 @@ package examples
2020
import (
2121
"context"
2222
"fmt"
23-
"io/ioutil"
2423
"log"
2524
"os"
2625
"path/filepath"
@@ -65,7 +64,7 @@ func (d *Datastore) Put(ctx context.Context, key ds.Key, value []byte) (err erro
6564
return err
6665
}
6766

68-
return ioutil.WriteFile(fn, value, 0666)
67+
return os.WriteFile(fn, value, 0666)
6968
}
7069

7170
// Sync would ensure that any previous Puts under the prefix are written to disk.
@@ -81,7 +80,7 @@ func (d *Datastore) Get(ctx context.Context, key ds.Key) (value []byte, err erro
8180
return nil, ds.ErrNotFound
8281
}
8382

84-
return ioutil.ReadFile(fn)
83+
return os.ReadFile(fn)
8584
}
8685

8786
// Has returns whether the datastore has a value for a given key

failstore/failstore.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func (d *Failstore) DiskUsage(ctx context.Context) (uint64, error) {
110110
return ds.DiskUsage(ctx, d.child)
111111
}
112112

113-
// Close implements the Datastore interface
113+
// Close implements the Datastore interface
114114
func (d *Failstore) Close() error {
115115
return d.child.Close()
116116
}

fuzz/cmd/compare/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package main
22

33
import (
44
"fmt"
5-
"io/ioutil"
5+
"io"
66
"os"
77

88
ds "github.com/ipfs/go-datastore"
@@ -28,9 +28,9 @@ func main() {
2828
var dat []byte
2929
var err error
3030
if *input == "" {
31-
dat, err = ioutil.ReadAll(os.Stdin)
31+
dat, err = io.ReadAll(os.Stdin)
3232
} else {
33-
dat, err = ioutil.ReadFile(*input)
33+
dat, err = os.ReadFile(*input)
3434
}
3535
if err != nil {
3636
fmt.Fprintf(os.Stderr, "Could not read %s: %v\n", *input, err)

fuzz/cmd/isprefix/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package main
44

55
import (
66
"fmt"
7-
"io/ioutil"
7+
"io"
88
"os"
99

1010
ds "github.com/ipfs/go-datastore"
@@ -47,9 +47,9 @@ func main() {
4747
var dat []byte
4848
var err error
4949
if *input == "" {
50-
dat, err = ioutil.ReadAll(os.Stdin)
50+
dat, err = io.ReadAll(os.Stdin)
5151
} else {
52-
dat, err = ioutil.ReadFile(*input)
52+
dat, err = os.ReadFile(*input)
5353
}
5454
if err != nil {
5555
fmt.Fprintf(os.Stderr, "could not read %s: %v\n", *input, err)

fuzz/cmd/run/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package main
33
import (
44
"bufio"
55
"fmt"
6-
"io/ioutil"
76
"os"
87

98
fuzzer "github.com/ipfs/go-datastore/fuzz"
@@ -22,7 +21,7 @@ func main() {
2221
fuzzer.Threads = *threads
2322

2423
if *input != "" {
25-
dat, err := ioutil.ReadFile(*input)
24+
dat, err := os.ReadFile(*input)
2625
if err != nil {
2726
fmt.Fprintf(os.Stderr, "could not read %s: %v\n", *input, err)
2827
os.Exit(1)

fuzz/fuzzer.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"fmt"
66
"io"
7-
"io/ioutil"
87
"os"
98
"sync"
109
"sync/atomic"
@@ -134,7 +133,7 @@ func Fuzz(data []byte) int {
134133
impls = append(impls, impl)
135134
}
136135

137-
defaultLoc, _ := ioutil.TempDir("", "fuzz-*")
136+
defaultLoc, _ := os.MkdirTemp("", "fuzz-*")
138137

139138
if len(impls) == 0 {
140139
fmt.Fprintf(os.Stderr, "No datastores to fuzz.\n")

fuzz/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/ipfs/go-datastore/fuzz
22

3-
go 1.17
3+
go 1.18
44

55
require (
66
github.com/ipfs/go-datastore v0.4.4

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ require (
1616
go.uber.org/atomic v1.6.0 // indirect
1717
)
1818

19-
go 1.17
19+
go 1.18

0 commit comments

Comments
 (0)