From 993750832f04a1ce20cbfc1ba331f55e6a1b5bb1 Mon Sep 17 00:00:00 2001 From: Paulo Gomes Date: Fri, 27 Jun 2025 08:17:41 +0100 Subject: [PATCH 1/2] build: Remove master branch from workflow Signed-off-by: Paulo Gomes --- .github/workflows/codeql.yml | 2 +- .github/workflows/test_wasip1.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index b11eb9f..7c88ca1 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -2,7 +2,7 @@ name: CodeQL on: push: - branches: [ "master", "main" ] + branches: [ "main" ] pull_request: schedule: - cron: '00 5 * * 1' diff --git a/.github/workflows/test_wasip1.yml b/.github/workflows/test_wasip1.yml index 53c90d4..afe48b6 100644 --- a/.github/workflows/test_wasip1.yml +++ b/.github/workflows/test_wasip1.yml @@ -2,7 +2,7 @@ name: Test wasip1 on: push: - branches: [ "master", "main" ] + branches: [ "main" ] pull_request: permissions: {} From b0cb6a2cadfa7b4a61150cf2fa6dd1410894ad49 Mon Sep 17 00:00:00 2001 From: Paulo Gomes Date: Fri, 27 Jun 2025 08:55:23 +0100 Subject: [PATCH 2/2] build: Bump golangci to v2.1.6 Signed-off-by: Paulo Gomes --- .golangci.yaml | 28 +++++++++++++++++++++++----- Makefile | 2 +- osfs/os_posix.go | 4 ++-- test/basic_test.go | 11 +++++------ 4 files changed, 31 insertions(+), 14 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index f21ef5b..f233aa2 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,5 +1,6 @@ +version: "2" linters: - disable-all: true + default: none enable: - asasalint - asciicheck @@ -22,10 +23,8 @@ linters: - gochecknoinits - gochecksumtype - goheader - - goimports - gomodguard - goprintffuncname - - gosimple - gosmopolitan - govet - grouper @@ -44,14 +43,33 @@ linters: - sloglint - spancheck - sqlclosecheck + - staticcheck - tagalign - tagliatelle - - tenv - testableexamples - - typecheck - unconvert - unused - usestdlibvars - wastedassign - whitespace - zerologlint + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + paths: + - third_party$ + - builtin$ + - examples$ +formatters: + enable: + - goimports + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ diff --git a/Makefile b/Makefile index 8793e4b..f0b04ae 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ GOCMD = go GOTEST = $(GOCMD) test WASIRUN_WRAPPER := $(CURDIR)/scripts/wasirun-wrapper -GOLANGCI_VERSION ?= v1.64.5 +GOLANGCI_VERSION ?= v2.1.6 TOOLS_BIN := $(shell mkdir -p build/tools && realpath build/tools) GOLANGCI = $(TOOLS_BIN)/golangci-lint-$(GOLANGCI_VERSION) diff --git a/osfs/os_posix.go b/osfs/os_posix.go index de511ed..7dd2062 100644 --- a/osfs/os_posix.go +++ b/osfs/os_posix.go @@ -14,14 +14,14 @@ func (f *file) Lock() error { f.m.Lock() defer f.m.Unlock() - return unix.Flock(int(f.File.Fd()), unix.LOCK_EX) + return unix.Flock(int(f.Fd()), unix.LOCK_EX) } func (f *file) Unlock() error { f.m.Lock() defer f.m.Unlock() - return unix.Flock(int(f.File.Fd()), unix.LOCK_UN) + return unix.Flock(int(f.Fd()), unix.LOCK_UN) } func rename(from, to string) error { diff --git a/test/basic_test.go b/test/basic_test.go index 5b72b7a..867ec42 100644 --- a/test/basic_test.go +++ b/test/basic_test.go @@ -12,7 +12,6 @@ import ( "strings" "testing" - "github.com/go-git/go-billy/v6" . "github.com/go-git/go-billy/v6" //nolint "github.com/go-git/go-billy/v6/osfs" "github.com/go-git/go-billy/v6/util" @@ -71,7 +70,7 @@ func TestCreateOverwrite(t *testing.T) { f, err := fs.Create("foo") require.NoError(t, err) - l, err := f.Write([]byte(fmt.Sprintf("foo%d", i))) + l, err := fmt.Fprintf(f, "foo%d", i) require.NoError(t, err) assert.Equal(t, 4, l) @@ -477,7 +476,7 @@ func TestStatNonExistent(t *testing.T) { func TestRename(t *testing.T) { tests := []struct { name string - before func(*testing.T, billy.Filesystem) + before func(*testing.T, Filesystem) from string to string wantErr *error @@ -491,7 +490,7 @@ func TestRename(t *testing.T) { }, { name: "file rename", - before: func(t *testing.T, fs billy.Filesystem) { + before: func(t *testing.T, fs Filesystem) { root := fsRoot(fs) f, err := fs.Create(fs.Join(root, "foo")) require.NoError(t, err) @@ -503,7 +502,7 @@ func TestRename(t *testing.T) { }, { name: "dir rename", - before: func(t *testing.T, fs billy.Filesystem) { + before: func(t *testing.T, fs Filesystem) { root := fsRoot(fs) f, err := fs.Create(fs.Join(root, "foo", "bar1")) require.NoError(t, err) @@ -568,7 +567,7 @@ func TestRename(t *testing.T) { }) } -func fsRoot(fs billy.Filesystem) string { +func fsRoot(fs Filesystem) string { if reflect.TypeOf(fs) == reflect.TypeOf(&osfs.BoundOS{}) { return fs.Root() }