Skip to content

sync: update CI config files #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 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 }}
3 changes: 1 addition & 2 deletions convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package flatfs_test
import (
"bytes"
"encoding/base32"
"io/ioutil"
"math/rand"
"os"
"path/filepath"
Expand All @@ -22,7 +21,7 @@ func TestMove(t *testing.T) {
v1dir := filepath.Join(tempdir, "v1")
createDatastore(t, v1dir, flatfs.Prefix(3))

err := ioutil.WriteFile(filepath.Join(v1dir, "README_ALSO"), []byte("something"), 0666)
err := os.WriteFile(filepath.Join(v1dir, "README_ALSO"), []byte("something"), 0666)
if err != nil {
t.Fatalf("WriteFile fail: %v\n", err)
}
Expand Down
4 changes: 2 additions & 2 deletions flatfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ type opResult struct {
// Begins starts the processing of an op:
// - if no other op for the same key exist, register it and return immediately
// - if another op exist for the same key, wait until it's done:
// - if that previous op succeeded, consider that ours shouldn't execute and return nil
// - if that previous op failed, start ours
// - if that previous op succeeded, consider that ours shouldn't execute and return nil
// - if that previous op failed, start ours
func (m *opMap) Begin(name string) *opResult {
for {
myOp := &opResult{opMap: m, name: name}
Expand Down
2 changes: 1 addition & 1 deletion flatfs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"os"
"strconv"

"github.com/ipfs/go-ds-flatfs"
flatfs "github.com/ipfs/go-ds-flatfs"
)

// To convert from the old format to a new format with a different
Expand Down
13 changes: 6 additions & 7 deletions flatfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/base32"
"encoding/json"
"fmt"
"io/ioutil"
"math"
"math/rand"
"os"
Expand Down Expand Up @@ -47,7 +46,7 @@ func checkTemp(t *testing.T, dir string) {
}

func tempdir(t testing.TB) (path string, cleanup func()) {
path, err := ioutil.TempDir("", "test-datastore-flatfs-")
path, err := os.MkdirTemp("", "test-datastore-flatfs-")
if err != nil {
t.Fatalf("cannot create temp directory: %v", err)
}
Expand Down Expand Up @@ -281,7 +280,7 @@ func testStorage(p *params, t *testing.T) {
case ".", "..", "SHARDING", flatfs.DiskUsageFile, ".temp":
// ignore
case "_README":
_, err := ioutil.ReadFile(absPath)
_, err := os.ReadFile(absPath)
if err != nil {
t.Error("could not read _README file")
}
Expand Down Expand Up @@ -587,7 +586,7 @@ func testDiskUsage(dirFunc mkShardFunc, t *testing.T) {
fs.Close()

// Check that disk usage file is correct
duB, err := ioutil.ReadFile(filepath.Join(temp, flatfs.DiskUsageFile))
duB, err := os.ReadFile(filepath.Join(temp, flatfs.DiskUsageFile))
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -1012,7 +1011,7 @@ func TestNonDatastoreDir(t *testing.T) {
tempdir, cleanup := tempdir(t)
defer cleanup()

err := ioutil.WriteFile(filepath.Join(tempdir, "afile"), []byte("Some Content"), 0644)
err := os.WriteFile(filepath.Join(tempdir, "afile"), []byte("Some Content"), 0644)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -1059,7 +1058,7 @@ func TestNoCluster(t *testing.T) {
}

fs.Close()
dirs, err := ioutil.ReadDir(tempdir)
dirs, err := os.ReadDir(tempdir)
if err != nil {
t.Fatalf("ReadDir fail: %v\n", err)
}
Expand All @@ -1072,7 +1071,7 @@ func TestNoCluster(t *testing.T) {
continue
}
count += 1
files, err := ioutil.ReadDir(filepath.Join(tempdir, dir.Name()))
files, err := os.ReadDir(filepath.Join(tempdir, dir.Name()))
if err != nil {
t.Fatalf("ReadDir fail: %v\n", err)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ require (
go.uber.org/zap v1.10.0 // indirect
)

go 1.17
go 1.18
1 change: 0 additions & 1 deletion rename.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build !plan9
// +build !plan9

package flatfs

Expand Down
5 changes: 2 additions & 3 deletions shard.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package flatfs

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strconv"
Expand Down Expand Up @@ -118,7 +117,7 @@ func ParseShardFunc(str string) (*ShardIdV1, error) {
}

func ReadShardFunc(dir string) (*ShardIdV1, error) {
buf, err := ioutil.ReadFile(filepath.Join(dir, SHARDING_FN))
buf, err := os.ReadFile(filepath.Join(dir, SHARDING_FN))
if os.IsNotExist(err) {
return nil, ErrShardingFileMissing
} else if err != nil {
Expand All @@ -143,7 +142,7 @@ func WriteShardFunc(dir string, id *ShardIdV1) error {

func WriteReadme(dir string, id *ShardIdV1) error {
if id.String() == IPFS_DEF_SHARD.String() {
err := ioutil.WriteFile(filepath.Join(dir, README_FN), []byte(README_IPFS_DEF_SHARD), 0444)
err := os.WriteFile(filepath.Join(dir, README_FN), []byte(README_IPFS_DEF_SHARD), 0444)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
// 16 should be able to sataurate most RAIDs
// in case of two used disks per write (RAID 1, 5) and queue depth of 2,
// 16 concurrent Sync calls should be able to saturate 16 HDDs RAID
//TODO: benchmark it out, maybe provide tweak parmeter
// TODO: benchmark it out, maybe provide tweak parmeter
const SyncThreadsMax = 16

var syncSemaphore chan struct{} = make(chan struct{}, SyncThreadsMax)
Expand Down
6 changes: 2 additions & 4 deletions util_unix.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
//go:build !windows
// +build !windows

package flatfs

import (
"io/ioutil"
"os"
)

func tempFileOnce(dir, pattern string) (*os.File, error) {
return ioutil.TempFile(dir, pattern)
return os.CreateTemp(dir, pattern)
}

func readFileOnce(filename string) ([]byte, error) {
return ioutil.ReadFile(filename)
return os.ReadFile(filename)
}
5 changes: 2 additions & 3 deletions util_windows.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build windows
// +build windows

// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
Expand All @@ -13,7 +12,7 @@ package flatfs

import (
"bytes"
"io/ioutil"
"io"
"os"
"path/filepath"
"strconv"
Expand Down Expand Up @@ -98,5 +97,5 @@ func readFileOnce(filename string) ([]byte, error) {
}
}

return ioutil.ReadAll(f)
return io.ReadAll(f)
}