From 35670d5a583737215bf165a445a4b5f4f1fb4cc3 Mon Sep 17 00:00:00 2001 From: Artem Yadelskyi Date: Mon, 16 Feb 2026 13:45:36 +0200 Subject: [PATCH 1/8] feat(linters): Added golangci-lint config & CI job --- .github/workflows/build.yml | 4 +- .github/workflows/docker-build.yml | 2 +- .github/workflows/pr.yml | 40 +++++++-- .github/workflows/release.yml | 6 +- .golangci.yaml | 133 +++++++++++++++++++++++++++++ 5 files changed, 172 insertions(+), 13 deletions(-) create mode 100644 .golangci.yaml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0f075b0bb..499613625 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,10 +9,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Setup Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v6 with: go-version-file: go.mod diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 2d1aa9ffc..dadbed212 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -25,7 +25,7 @@ jobs: steps: # ── Checkout ────────────────────────────── - name: 📥 Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: ref: ${{ inputs.tag }} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index fac7597ea..4d7ac74ba 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -4,14 +4,40 @@ on: pull_request: jobs: + lint: + name: Linter + runs-on: ubuntu-latest + # TODO: Remove continue-on-error once linter issues are fixed + continue-on-error: true + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Setup Go + uses: actions/setup-go@v6 + with: + go-version-file: go.mod + + - name: Gofmt check + run: diff -u <(echo -n) <(gofmt -d .) + + - name: Run go generate + run: go generate ./... + + - name: Golangci Lint + uses: golangci/golangci-lint-action@v9 + with: + version: latest + + # TODO: Remove once linter job is required fmt-check: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Setup Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v6 with: go-version-file: go.mod @@ -20,15 +46,16 @@ jobs: make fmt git diff --exit-code || (echo "::error::Code is not formatted. Run 'make fmt' and commit the changes." && exit 1) + # TODO: Remove once linter job is required vet: runs-on: ubuntu-latest needs: fmt-check steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Setup Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v6 with: go-version-file: go.mod @@ -43,10 +70,10 @@ jobs: needs: fmt-check steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Setup Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v6 with: go-version-file: go.mod @@ -55,4 +82,3 @@ jobs: - name: Run go test run: go test ./... - diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f9987b35f..06ee55a7d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,7 +26,7 @@ jobs: contents: write steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: fetch-depth: 0 @@ -47,13 +47,13 @@ jobs: packages: write steps: - name: Checkout tag - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: fetch-depth: 0 ref: ${{ inputs.tag }} - name: Setup Go from go.mod - uses: actions/setup-go@v5 + uses: actions/setup-go@v6 with: go-version-file: go.mod diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 000000000..4d8435fff --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,133 @@ +version: "2" + +linters: + default: all + disable: + # TODO: Tweak for current project needs + - containedctx + - cyclop + - depguard + - dupl + - dupword + - err113 + - exhaustruct + - funcorder + - gochecknoglobals + - godot + - intrange + - ireturn + - nlreturn + - noctx + - noinlineerr + - nonamedreturns + - tagliatelle + - testpackage + - varnamelen + - wrapcheck + - wsl + - wsl_v5 + settings: + errcheck: + check-type-assertions: true + check-blank: true + exhaustive: + default-signifies-exhaustive: true + funlen: + lines: 120 + statements: 40 + gocognit: + min-complexity: 25 + gocyclo: + min-complexity: 20 + govet: + enable-all: true + disable: + - fieldalignment + lll: + line-length: 120 + tab-width: 4 + misspell: + locale: US + mnd: + checks: + - argument + - assign + - case + - condition + - operation + - return + nakedret: + max-func-lines: 3 + revive: + enable-all-rules: true + rules: + - name: add-constant + disabled: true + - name: argument-limit + arguments: + - 7 + severity: warning + - name: banned-characters + disabled: true + - name: cognitive-complexity + disabled: true + - name: comment-spacings + arguments: + - nolint + severity: warning + - name: cyclomatic + disabled: true + - name: file-header + disabled: true + - name: function-result-limit + arguments: + - 3 + severity: warning + - name: function-length + disabled: true + - name: line-length-limit + disabled: true + - name: max-public-structs + disabled: true + - name: modifies-value-receiver + disabled: true + - name: package-comments + disabled: true + - name: unused-receiver + disabled: true + exclusions: + generated: lax + rules: + - linters: + - lll + source: '^//go:generate ' + - linters: + - funlen + - maintidx + - gocognit + - gocyclo + path: _test\.go$ + +issues: + max-issues-per-linter: 0 + max-same-issues: 0 + +formatters: + enable: + - gci + - gofmt + - gofumpt + - goimports + settings: + gci: + sections: + - standard + - default + - localmodule + custom-order: true + gofmt: + rewrite-rules: + - pattern: "interface{}" + replacement: "any" + - pattern: "a[b:len(a)]" + replacement: "a[b:]" From d69ef653df4f23dd42cff04724c3b54c7add1b6e Mon Sep 17 00:00:00 2001 From: Artem Yadelskyi Date: Mon, 16 Feb 2026 13:51:10 +0200 Subject: [PATCH 2/8] feat(linters): Added job names --- .github/workflows/pr.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 4d7ac74ba..e1a2397d1 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -1,7 +1,7 @@ -name: pr-check +name: PR on: - pull_request: + pull_request: { } jobs: lint: @@ -31,6 +31,7 @@ jobs: # TODO: Remove once linter job is required fmt-check: + name: Formatting runs-on: ubuntu-latest steps: - name: Checkout @@ -48,6 +49,7 @@ jobs: # TODO: Remove once linter job is required vet: + name: Vet runs-on: ubuntu-latest needs: fmt-check steps: @@ -66,6 +68,7 @@ jobs: run: go vet ./... test: + name: Tests runs-on: ubuntu-latest needs: fmt-check steps: From d9b5f64777416502a67e1d556de10d241d77d38b Mon Sep 17 00:00:00 2001 From: Artem Yadelskyi Date: Mon, 16 Feb 2026 17:13:35 +0200 Subject: [PATCH 3/8] feat(linters): Temporarily disable most linters --- .github/workflows/pr.yml | 6 ++--- .golangci.yaml | 57 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 56 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index e1a2397d1..1394aa053 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -7,8 +7,6 @@ jobs: lint: name: Linter runs-on: ubuntu-latest - # TODO: Remove continue-on-error once linter issues are fixed - continue-on-error: true steps: - name: Checkout uses: actions/checkout@v6 @@ -29,7 +27,7 @@ jobs: with: version: latest - # TODO: Remove once linter job is required + # TODO: Remove once linter is properly configured fmt-check: name: Formatting runs-on: ubuntu-latest @@ -47,7 +45,7 @@ jobs: make fmt git diff --exit-code || (echo "::error::Code is not formatted. Run 'make fmt' and commit the changes." && exit 1) - # TODO: Remove once linter job is required + # TODO: Remove once linter is properly configured vet: name: Vet runs-on: ubuntu-latest diff --git a/.golangci.yaml b/.golangci.yaml index 4d8435fff..80e54ac1c 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -26,6 +26,52 @@ linters: - wrapcheck - wsl - wsl_v5 + + # TODO: Disabled, because they are failing at the moment, we should fix them and enable (step by step) + - bodyclose + - contextcheck + - dogsled + - embeddedstructfieldcheck + - errcheck + - errchkjson + - errorlint + - exhaustive + - forbidigo + - forcetypeassert + - funlen + - gochecknoinits + - gocognit + - goconst + - gocritic + - gocyclo + - godox + - goprintffuncname + - gosec + - govet + - ineffassign + - lll + - maintidx + - misspell + - mnd + - modernize + - nakedret + - nestif + - nilnil + - paralleltest + - perfsprint + - prealloc + - predeclared + - revive + - staticcheck + - tagalign + - testifylint + - thelper + - unparam + - unused + - usestdlibvars + - usetesting + - wastedassign + - whitespace settings: errcheck: check-type-assertions: true @@ -114,10 +160,12 @@ issues: formatters: enable: - - gci - - gofmt - - gofumpt - goimports + # TODO: Disabled, because they are failing at the moment, we should fix them and enable (step by step) + # - gci + # - gofmt + # - gofumpt + # - golines settings: gci: sections: @@ -126,8 +174,11 @@ formatters: - localmodule custom-order: true gofmt: + simplify: true rewrite-rules: - pattern: "interface{}" replacement: "any" - pattern: "a[b:len(a)]" replacement: "a[b:]" + golines: + max-len: 120 From 67d07109a99411ba4a791a287bb3d143fb6f1a0d Mon Sep 17 00:00:00 2001 From: Artem Yadelskyi Date: Mon, 16 Feb 2026 17:15:02 +0200 Subject: [PATCH 4/8] feat(linters): Removed fmt check (present in linters) --- .github/workflows/pr.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 1394aa053..df267aae8 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -16,9 +16,6 @@ jobs: with: go-version-file: go.mod - - name: Gofmt check - run: diff -u <(echo -n) <(gofmt -d .) - - name: Run go generate run: go generate ./... From d6f052f6b153a14a05fa4449756216cc069f3b87 Mon Sep 17 00:00:00 2001 From: Artem Yadelskyi Date: Wed, 18 Feb 2026 16:23:31 +0200 Subject: [PATCH 5/8] feat(linters): Fixed golangci-lint version --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index df267aae8..dfefba19c 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -22,7 +22,7 @@ jobs: - name: Golangci Lint uses: golangci/golangci-lint-action@v9 with: - version: latest + version: 2.10.1 # TODO: Remove once linter is properly configured fmt-check: From 272cabc627302b36fc385a35bd5603b7a088b4e1 Mon Sep 17 00:00:00 2001 From: Artem Yadelskyi Date: Wed, 18 Feb 2026 16:24:30 +0200 Subject: [PATCH 6/8] feat(linters): Fix version --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index dfefba19c..55bf77e00 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -22,7 +22,7 @@ jobs: - name: Golangci Lint uses: golangci/golangci-lint-action@v9 with: - version: 2.10.1 + version: v2.10.1 # TODO: Remove once linter is properly configured fmt-check: From b88f4c9ab567c4c523f39cd53ae72cc8fb9b5faf Mon Sep 17 00:00:00 2001 From: Artem Yadelskyi Date: Wed, 18 Feb 2026 16:24:55 +0200 Subject: [PATCH 7/8] feat(linters): Fix linter --- pkg/tools/shell.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/tools/shell.go b/pkg/tools/shell.go index bd612d9ae..d9430672f 100644 --- a/pkg/tools/shell.go +++ b/pkg/tools/shell.go @@ -4,7 +4,6 @@ import ( "bytes" "context" "fmt" - "github.com/sipeed/picoclaw/pkg/config" "os" "os/exec" "path/filepath" @@ -12,6 +11,8 @@ import ( "runtime" "strings" "time" + + "github.com/sipeed/picoclaw/pkg/config" ) type ExecTool struct { From df52d4ad0129a821050d02b9e514396a5d2d0e82 Mon Sep 17 00:00:00 2001 From: Artem Yadelskyi Date: Wed, 18 Feb 2026 16:26:35 +0200 Subject: [PATCH 8/8] feat(linters): Fix linter --- pkg/providers/claude_provider.go | 1 + pkg/providers/http_provider.go | 1 + 2 files changed, 2 insertions(+) diff --git a/pkg/providers/claude_provider.go b/pkg/providers/claude_provider.go index c72f5b0ef..3ca54d5a3 100644 --- a/pkg/providers/claude_provider.go +++ b/pkg/providers/claude_provider.go @@ -3,6 +3,7 @@ package providers import ( "context" "fmt" + anthropicprovider "github.com/sipeed/picoclaw/pkg/providers/anthropic" ) diff --git a/pkg/providers/http_provider.go b/pkg/providers/http_provider.go index e39a19e90..967d089d5 100644 --- a/pkg/providers/http_provider.go +++ b/pkg/providers/http_provider.go @@ -8,6 +8,7 @@ package providers import ( "context" + "github.com/sipeed/picoclaw/pkg/providers/openai_compat" )