Skip to content
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

update actions, golangci-lint, and test against go1.22.x #58

Merged
merged 8 commits into from
Jul 18, 2024
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
42 changes: 21 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ jobs:
timeout-minutes: 5

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
path: src/github.com/containerd/fifo
path: src/github.com/containerd/fifo # project-checks depends on GOPATH mode
fetch-depth: 25
- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: 1.20.x
go-version: 1.22.x
- uses: containerd/[email protected]
with:
working-directory: src/github.com/containerd/fifo
working-directory: src/github.com/containerd/fifo # project-checks depends on GOPATH mode

linters:
name: Linters
Expand All @@ -32,38 +32,38 @@ jobs:

strategy:
matrix:
go-version: [1.20.x]
os: [ubuntu-22.04, macos-12, windows-2022]
go-version: [1.22.x]
os: [ubuntu-22.04, macos-14, windows-2022]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
path: src/github.com/containerd/fifo
go-version: ${{ matrix.go-version }}

- name: Set env
shell: bash
run: |
echo "GOPATH=${{ github.workspace }}" >> $GITHUB_ENV
echo "${{ github.workspace }}/bin" >> $GITHUB_PATH

- uses: golangci/golangci-lint-action@v3
- uses: golangci/golangci-lint-action@v6
with:
version: v1.51.1
working-directory: src/github.com/containerd/fifo
version: v1.59.1

tests:
name: Tests
runs-on: ubuntu-22.04
runs-on: ${{ matrix.os }}
timeout-minutes: 5

steps:
- uses: actions/checkout@v3
with:
path: src/github.com/containerd/fifo
strategy:
matrix:
go-version: [1.20.x, 1.22.x]
os: [ubuntu-22.04]

- uses: actions/setup-go@v3
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.20.x
go-version: ${{ matrix.go-version }}

- run: make test
working-directory: src/github.com/containerd/fifo
2 changes: 0 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,3 @@ linters-settings:

run:
timeout: 3m
skip-dirs:
- vendor
4 changes: 2 additions & 2 deletions fifo_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestFifoCloseAfterRm(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()

f, err := OpenFifo(ctx, filepath.Join(tmpdir, "f0"), syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0600)
f, err := OpenFifo(ctx, filepath.Join(tmpdir, "f0"), syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0o600)
assert.NoError(t, err)

err = os.RemoveAll(filepath.Join(tmpdir, "f0"))
Expand Down Expand Up @@ -80,7 +80,7 @@ func TestFifoCloseAfterRm(t *testing.T) {

cerr = make(chan error)
go func() {
_, err = OpenFifo(ctx, filepath.Join(tmpdir, "f1"), syscall.O_WRONLY|syscall.O_CREAT, 0600)
_, err = OpenFifo(ctx, filepath.Join(tmpdir, "f1"), syscall.O_WRONLY|syscall.O_CREAT, 0o600)
cerr <- err
}()

Expand Down
4 changes: 2 additions & 2 deletions fifo_nolinux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestFifoCloseAfterRm(t *testing.T) {

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
f, err := OpenFifo(ctx, filepath.Join(tmpdir, "f0"), syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0600)
f, err := OpenFifo(ctx, filepath.Join(tmpdir, "f0"), syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0o600)
assert.NoError(t, err)

time.Sleep(time.Second) // non-linux doesn't allow removing before syscall has been called. will cause an error.
Expand Down Expand Up @@ -74,7 +74,7 @@ func TestFifoCloseAfterRm(t *testing.T) {
ctx, cancel = context.WithCancel(context.Background())
cerr = make(chan error)
go func() {
_, err = OpenFifo(ctx, filepath.Join(tmpdir, "f1"), syscall.O_WRONLY|syscall.O_CREAT, 0600)
_, err = OpenFifo(ctx, filepath.Join(tmpdir, "f1"), syscall.O_WRONLY|syscall.O_CREAT, 0o600)
cerr <- err
}()

Expand Down
33 changes: 15 additions & 18 deletions fifo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestOpenNonNamedPipe(t *testing.T) {
assert.NoError(t, err)
f.Close()

_, err = OpenFifo(context.TODO(), normalFile, syscall.O_RDONLY|syscall.O_NONBLOCK, 0600)
_, err = OpenFifo(context.TODO(), normalFile, syscall.O_RDONLY|syscall.O_NONBLOCK, 0o600)
assert.ErrorContains(t, err, fmt.Sprintf("file %v is not fifo", normalFile))
}

Expand All @@ -54,7 +54,7 @@ func TestFifoCancel(t *testing.T) {
leakCheckWg = nil
}()

f, err := OpenFifo(context.Background(), filepath.Join(tmpdir, "f0"), syscall.O_RDONLY|syscall.O_NONBLOCK, 0600)
f, err := OpenFifo(context.Background(), filepath.Join(tmpdir, "f0"), syscall.O_RDONLY|syscall.O_NONBLOCK, 0o600)
assert.Exactly(t, nil, f)
assert.NotNil(t, err)

Expand All @@ -63,7 +63,7 @@ func TestFifoCancel(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
defer cancel()

f, err = OpenFifo(ctx, filepath.Join(tmpdir, "f0"), syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0600)
f, err = OpenFifo(ctx, filepath.Join(tmpdir, "f0"), syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0o600)
assert.NoError(t, err)

b := make([]byte, 32)
Expand Down Expand Up @@ -92,7 +92,7 @@ func TestFifoReadWrite(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()

r, err := OpenFifo(ctx, filepath.Join(tmpdir, "f0"), syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0600)
r, err := OpenFifo(ctx, filepath.Join(tmpdir, "f0"), syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0o600)
assert.NoError(t, err)

w, err := OpenFifo(ctx, filepath.Join(tmpdir, "f0"), syscall.O_WRONLY|syscall.O_NONBLOCK, 0)
Expand All @@ -118,7 +118,7 @@ func TestFifoReadWrite(t *testing.T) {
ctx, cancel = context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()

w, err = OpenFifo(ctx, filepath.Join(tmpdir, "f1"), syscall.O_CREAT|syscall.O_WRONLY|syscall.O_NONBLOCK, 0600)
w, err = OpenFifo(ctx, filepath.Join(tmpdir, "f1"), syscall.O_CREAT|syscall.O_WRONLY|syscall.O_NONBLOCK, 0o600)
assert.NoError(t, err)

written := make(chan struct{})
Expand Down Expand Up @@ -170,7 +170,7 @@ func TestFifoCancelOneSide(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()

f, err := OpenFifo(ctx, filepath.Join(tmpdir, "f0"), syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0600)
f, err := OpenFifo(ctx, filepath.Join(tmpdir, "f0"), syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0o600)
assert.NoError(t, err)

read := make(chan struct{})
Expand Down Expand Up @@ -213,7 +213,7 @@ func TestFifoBlocking(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()

f, err := OpenFifo(ctx, filepath.Join(tmpdir, "f0"), syscall.O_RDONLY|syscall.O_CREAT, 0600)
f, err := OpenFifo(ctx, filepath.Join(tmpdir, "f0"), syscall.O_RDONLY|syscall.O_CREAT, 0o600)
assert.Exactly(t, nil, f)
assert.EqualError(t, err, "context deadline exceeded")

Expand All @@ -233,7 +233,7 @@ func TestFifoBlocking(t *testing.T) {
var r io.ReadCloser
readerOpen := make(chan struct{})
go func() {
r, rerr = OpenFifo(ctx, filepath.Join(tmpdir, "f1"), syscall.O_RDONLY|syscall.O_CREAT, 0600)
r, rerr = OpenFifo(ctx, filepath.Join(tmpdir, "f1"), syscall.O_RDONLY|syscall.O_CREAT, 0o600)
close(readerOpen)
}()

Expand Down Expand Up @@ -281,7 +281,7 @@ func TestFifoORDWR(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

f, err := OpenFifo(ctx, filepath.Join(tmpdir, "f0"), syscall.O_RDWR|syscall.O_CREAT, 0600)
f, err := OpenFifo(ctx, filepath.Join(tmpdir, "f0"), syscall.O_RDWR|syscall.O_CREAT, 0o600)
assert.NoError(t, err)

_, err = f.Write([]byte("foobar"))
Expand Down Expand Up @@ -352,15 +352,15 @@ func TestFifoCloseError(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()

w, err := OpenFifo(ctx, filepath.Join(tmpdir, t.Name()), syscall.O_WRONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0600)
w, err := OpenFifo(ctx, filepath.Join(tmpdir, t.Name()), syscall.O_WRONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0o600)
assert.NoError(t, err)
w.Close()

data := []byte("hello world!")
_, err = w.Write(data)
assert.Equal(t, ErrWriteClosed, err)

r, err := OpenFifo(ctx, filepath.Join(tmpdir, t.Name()), syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0600)
r, err := OpenFifo(ctx, filepath.Join(tmpdir, t.Name()), syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0o600)
assert.NoError(t, err)
r.Close()

Expand All @@ -377,7 +377,7 @@ func TestFifoCloseWhileReading(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()

r, err := OpenFifo(ctx, filepath.Join(tmpdir, t.Name()), syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0600)
r, err := OpenFifo(ctx, filepath.Join(tmpdir, t.Name()), syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0o600)
assert.NoError(t, err)

read := make(chan struct{})
Expand All @@ -386,14 +386,12 @@ func TestFifoCloseWhileReading(t *testing.T) {
go func() {
buf := make([]byte, 32)
_, err := r.Read(buf)

if err != nil {
readErr <- err
return
}

close(read)

}()

time.Sleep(500 * time.Millisecond)
Expand All @@ -417,7 +415,7 @@ func TestFifoCloseWhileReadingAndWriting(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()

r, err := OpenFifo(ctx, filepath.Join(tmpdir, t.Name()), syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0600)
r, err := OpenFifo(ctx, filepath.Join(tmpdir, t.Name()), syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0o600)
assert.NoError(t, err)

w, err := OpenFifo(ctx, filepath.Join(tmpdir, t.Name()), syscall.O_WRONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0)
Expand All @@ -430,7 +428,6 @@ func TestFifoCloseWhileReadingAndWriting(t *testing.T) {
go func() {
buf := make([]byte, 32)
_, err := r.Read(buf)

if err != nil {
readErr <- err
return
Expand Down Expand Up @@ -467,14 +464,14 @@ func TestFifoWrongRdWrError(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()

r, err := OpenFifo(ctx, filepath.Join(tmpdir, t.Name()), syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0600)
r, err := OpenFifo(ctx, filepath.Join(tmpdir, t.Name()), syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0o600)
assert.NoError(t, err)

data := []byte("hello world!")
_, err = r.Write(data)
assert.Equal(t, ErrWrToRDONLY, err)

w, err := OpenFifo(ctx, filepath.Join(tmpdir, t.Name()), syscall.O_WRONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0600)
w, err := OpenFifo(ctx, filepath.Join(tmpdir, t.Name()), syscall.O_WRONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0o600)
assert.NoError(t, err)

buf := make([]byte, len(data))
Expand Down
2 changes: 1 addition & 1 deletion handle_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
)

//nolint:revive
const O_PATH = 010000000
const O_PATH = 0o10000000

type handle struct {
f *os.File
Expand Down
22 changes: 11 additions & 11 deletions raw_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestRawReadWrite(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()

r, err := OpenFifo(ctx, filepath.Join(tmpdir, t.Name()), syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0600)
r, err := OpenFifo(ctx, filepath.Join(tmpdir, t.Name()), syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0o600)
assert.NoError(t, err)
defer r.Close()
rawR := makeRawConn(t, r, false)
Expand Down Expand Up @@ -68,12 +68,12 @@ func TestRawWriteUserRead(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()

w, err := OpenFifo(ctx, filepath.Join(tmpdir, t.Name()), syscall.O_WRONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0600)
w, err := OpenFifo(ctx, filepath.Join(tmpdir, t.Name()), syscall.O_WRONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0o600)
assert.NoError(t, err)
defer w.Close()
rawW := makeRawConn(t, w, false)

r, err := OpenFifo(ctx, filepath.Join(tmpdir, t.Name()), syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0600)
r, err := OpenFifo(ctx, filepath.Join(tmpdir, t.Name()), syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0o600)
assert.NoError(t, err)
defer r.Close()

Expand All @@ -95,11 +95,11 @@ func TestUserWriteRawRead(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()

w, err := OpenFifo(ctx, filepath.Join(tmpdir, t.Name()), syscall.O_WRONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0600)
w, err := OpenFifo(ctx, filepath.Join(tmpdir, t.Name()), syscall.O_WRONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0o600)
assert.NoError(t, err)
defer w.Close()

r, err := OpenFifo(ctx, filepath.Join(tmpdir, t.Name()), syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0600)
r, err := OpenFifo(ctx, filepath.Join(tmpdir, t.Name()), syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0o600)
assert.NoError(t, err)
defer r.Close()
rawR := makeRawConn(t, r, false)
Expand All @@ -124,7 +124,7 @@ func TestRawCloseError(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()

f, err := OpenFifo(ctx, filepath.Join(tmpdir, path.Base(t.Name())), syscall.O_RDWR|syscall.O_CREAT, 0600)
f, err := OpenFifo(ctx, filepath.Join(tmpdir, path.Base(t.Name())), syscall.O_RDWR|syscall.O_CREAT, 0o600)
assert.NoError(t, err)

f.Close()
Expand All @@ -135,7 +135,7 @@ func TestRawCloseError(t *testing.T) {
t.Run("RawOpsAfterClose", func(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
f, err := OpenFifo(ctx, filepath.Join(tmpdir, path.Base(t.Name())), syscall.O_RDWR|syscall.O_CREAT, 0600)
f, err := OpenFifo(ctx, filepath.Join(tmpdir, path.Base(t.Name())), syscall.O_RDWR|syscall.O_CREAT, 0o600)
assert.NoError(t, err)
defer f.Close()

Expand All @@ -153,7 +153,7 @@ func TestRawCloseError(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
dummy := func(uintptr) bool { return true }
r, err := OpenFifo(ctx, filepath.Join(tmpdir, path.Base(t.Name())), syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0600)
r, err := OpenFifo(ctx, filepath.Join(tmpdir, path.Base(t.Name())), syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0o600)
assert.NoError(t, err)
defer r.Close()
rawR := makeRawConn(t, r, false)
Expand All @@ -162,7 +162,7 @@ func TestRawCloseError(t *testing.T) {
assert.Equal(t, ErrCtrlClosed, rawR.Control(func(uintptr) {}))
assert.Equal(t, ErrReadClosed, rawR.Read(dummy))

w, err := OpenFifo(ctx, filepath.Join(tmpdir, path.Base(t.Name())), syscall.O_WRONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0600)
w, err := OpenFifo(ctx, filepath.Join(tmpdir, path.Base(t.Name())), syscall.O_WRONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0o600)
assert.NoError(t, err)
defer w.Close()
rawW := makeRawConn(t, w, false)
Expand All @@ -181,14 +181,14 @@ func TestRawWrongRdWrError(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
dummy := func(uintptr) bool { return true }
r, err := OpenFifo(ctx, filepath.Join(tmpdir, path.Base(t.Name())), syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0600)
r, err := OpenFifo(ctx, filepath.Join(tmpdir, path.Base(t.Name())), syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0o600)
assert.NoError(t, err)
defer r.Close()
rawR := makeRawConn(t, r, false)

assert.Equal(t, ErrWrToRDONLY, rawR.Write(dummy))

w, err := OpenFifo(ctx, filepath.Join(tmpdir, path.Base(t.Name())), syscall.O_WRONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0600)
w, err := OpenFifo(ctx, filepath.Join(tmpdir, path.Base(t.Name())), syscall.O_WRONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0o600)
assert.NoError(t, err)
defer w.Close()
rawW := makeRawConn(t, w, false)
Expand Down
Loading