diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 5512f22..21a46ca 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,86 +1,20 @@ name: CI on: - workflow_call: pull_request: push: branches: - main concurrency: - group: ${{ github.workflow }}-${{ github.ref }} + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} cancel-in-progress: true permissions: {} jobs: - test: - name: Test - runs-on: ${{ matrix.os }} + ci: + name: CI permissions: contents: read - strategy: - matrix: - os: - - ubuntu-latest - - macos-latest - - windows-latest - - steps: - - name: Checkout Code - uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version-file: go.mod - - - name: Run Tests - run: go test -race ./... - - cov: - name: CodeCov - runs-on: ubuntu-latest - permissions: - contents: read - - steps: - - name: Checkout Code - uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version-file: go.mod - - - name: Run Tests - run: go test -race -cover -covermode=atomic -coverprofile=./coverage.out ./... - - - name: Coverage - uses: codecov/codecov-action@v5 - with: - files: ./coverage.out - token: ${{ secrets.CODECOV_TOKEN }} - - lint: - name: Lint - runs-on: ubuntu-latest - permissions: - contents: read - - steps: - - name: Checkout Code - uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version-file: go.mod - - - name: Clean Mod Cache # See https://github.com/golangci/golangci-lint-action/issues/135 - run: go clean -modcache - - - name: Run Linting - uses: golangci/golangci-lint-action@v6 - with: - version: latest + uses: FollowTheProcess/ci/.github/workflows/Go.yml@v1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5724f56..5f57653 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,13 +8,6 @@ on: permissions: {} jobs: - ci: - name: CI - uses: FollowTheProcess/debug/.github/workflows/CI.yml@main - secrets: inherit - permissions: - contents: read - release: name: Release runs-on: ubuntu-latest @@ -22,9 +15,6 @@ jobs: contents: write pull-requests: read - needs: - - ci - steps: - name: Checkout Code uses: actions/checkout@v4 diff --git a/.golangci.yml b/.golangci.yml index 5218106..4ede9b0 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,42 +1,54 @@ linters: - disable-all: true - enable: - - bodyclose - - containedctx - - durationcheck - - errcheck - - errchkjson - - errname - - exhaustive - - goconst - - gocritic - - gocyclo - - godot - - gofumpt - - goimports - - gosimple - - govet - - ineffassign - - misspell - - mnd - - nilerr - - nilnil - - nolintlint - - nakedret - - predeclared - - reassign - - revive - - staticcheck - - tagliatelle - - tenv - - testpackage - - thelper - - unconvert - - unparam - - unused - - whitespace + enable-all: true + disable: + - decorder # Don't care about this + - dupl # Basically every table driven test ever triggers this + - dupword # Messes with test cases more often than not + - err113 # Out of date + - exhaustruct # No + - forbidigo # Nothing to forbid + - funlen # Bad metric for complexity + - gci # gofmt/goimports is fine + - ginkgolinter # I don't use whatever this is + - gochecknoglobals # Globals are fine sometimes, use common sense + - gocyclo # cyclop does this instead + - godox # "todo" and "fixme" comments are allowed + - goheader # No need + - gosmopolitan # No need + - grouper # Imports take care of themselves, rest is common sense + - ireturn # This is just not necessary or practical in a real codebase + - lll # Auto formatters do this and what they can't do I don't care about + - maintidx # This is just the inverse of complexity... which is cyclop + - nestif # cyclop does this + - nlreturn # Similar to wsl, I think best left to judgement + - nonamedreturns # Named returns are often helpful, it's naked returns that are the issue + - paralleltest # No need + - tenv # Replaced by usetesting + - thelper # Lots of false positives due to the way I do table tests in here + - varnamelen # Lots of false positives of things that are fine + - wrapcheck # Not every error must be wrapped + - wsl # Very aggressive, some of this I like but tend to do anyway + +issues: + exclude-rules: + - path: _test\.go + linters: + - prealloc # These kinds of optimisations will make no difference to test code linters-settings: + cyclop: + max-complexity: 20 + + depguard: + rules: + main: + deny: + - pkg: io/ioutil + desc: io/ioutil is deprecated, use io instead + + - pkg: "math/rand$" + desc: use math/rand/v2 instead + errcheck: check-type-assertions: true check-blank: true @@ -47,80 +59,83 @@ linters-settings: - map default-signifies-exhaustive: true - gocyclo: - min-complexity: 20 - staticcheck: - checks: ["all"] + checks: + - all gosimple: - checks: ["all"] + checks: + - all govet: enable-all: true - revive: - max-open-files: 256 - ignore-generated-header: true - rules: - - name: argument-limit - disabled: false - arguments: [5] - - - name: atomic - disabled: false - - - name: blank-imports - disabled: false + gofumpt: + extra-rules: true - - name: call-to-gc - disabled: false + nakedret: + max-func-lines: 0 # Disallow any naked returns - - name: constant-logical-expr - disabled: false + nolintlint: + allow-unused: false + require-explanation: true + require-specific: true - - name: context-as-argument - disabled: false + usetesting: + context-background: true + context-todo: true + os-chdir: true + os-mkdir-temp: true + os-setenv: true + os-create-temp: true + os-temp-dir: true - - name: datarace - disabled: false + revive: + max-open-files: 256 + ignore-generated-header: true + enable-all-rules: true + rules: + - name: add-constant + disabled: true # goconst does this - - name: deep-exit - disabled: false + - name: argument-limit + arguments: + - 5 - - name: defer - disabled: false + - name: cognitive-complexity + disabled: true # gocognit does this - - name: dot-imports - disabled: false + - name: comment-spacings + arguments: + - "nolint:" - - name: early-return - disabled: false + - name: cyclomatic + disabled: true # cyclop does this - name: exported arguments: - checkPrivateReceivers + - checkPublicInterface - - name: modifies-value-receiver - disabled: false - - - name: package-comments - disabled: false - - - name: range - disabled: false + - name: function-length + disabled: true # Bad proxy for complexity - - name: range-val-in-closure - disabled: false + - name: function-result-limit + arguments: + - 3 - - name: range-val-address - disabled: false + - name: import-shadowing + disabled: true # predeclared does this - - name: time-equal - disabled: false + - name: line-length-limit + disabled: true # gofmt/golines handles this well enough - - name: use-any - disabled: false + - name: redefines-builtin-id + disabled: true # predeclared does this - - name: waitgroup-by-value - disabled: false + - name: unhandled-error + arguments: + - fmt\.(Fp|P)rint(ln|f)? + - strings.Builder.Write(String|Byte)? + - bytes.Buffer.Write(String|Byte)? + - go/printer\.(Fp|P)rint(ln|f)? diff --git a/.typos.toml b/.typos.toml new file mode 100644 index 0000000..ba94b04 --- /dev/null +++ b/.typos.toml @@ -0,0 +1,4 @@ +[default.extend-words] +byt = "byt" # Useful name as byte is a keyword in go +decorder = "decorder" # Name of a Go linter +importas = "importas" # Same diff --git a/go.mod b/go.mod index 6744eb6..ad38ed8 100644 --- a/go.mod +++ b/go.mod @@ -1,13 +1,11 @@ module github.com/FollowTheProcess/debug -go 1.23 - -toolchain go1.23.3 +go 1.24 require github.com/FollowTheProcess/test v0.20.2 require ( - github.com/FollowTheProcess/hue v0.3.1 // indirect - golang.org/x/sys v0.29.0 // indirect - golang.org/x/term v0.28.0 // indirect + github.com/FollowTheProcess/hue v0.4.0 // indirect + golang.org/x/sys v0.30.0 // indirect + golang.org/x/term v0.29.0 // indirect ) diff --git a/go.sum b/go.sum index 6a91a83..2717277 100644 --- a/go.sum +++ b/go.sum @@ -1,12 +1,18 @@ github.com/FollowTheProcess/hue v0.3.1 h1:3axoXNxWFzyj3fvL6N/20fosmPbX+Dr6i07aDz8gv7g= github.com/FollowTheProcess/hue v0.3.1/go.mod h1:PDpb1DXuZmN3VT7pwru+V3E4WCPQ0TghQIYaqkpOLxo= +github.com/FollowTheProcess/hue v0.4.0 h1:r7vuiFGZTgs4ekJb0CpIs2oqoh36Vohum0OKL1yAKf4= +github.com/FollowTheProcess/hue v0.4.0/go.mod h1:PDpb1DXuZmN3VT7pwru+V3E4WCPQ0TghQIYaqkpOLxo= github.com/FollowTheProcess/snapshot v0.4.1 h1:WIwvs+yZrK9886frLbNB98QWkAXTjIGnuvEjURHOrtE= github.com/FollowTheProcess/snapshot v0.4.1/go.mod h1:hb3V3azvp8FVrl4pvyhvq/ZYOnFSgyKHfXt96Jgg4e0= github.com/FollowTheProcess/test v0.20.2 h1:8/Yw7ny7IVMHIp/dmkGOdDYSUbAy77c+jDq86nfAhOw= github.com/FollowTheProcess/test v0.20.2/go.mod h1:4XBQyPoORSO1ZQcXpuopbv1INCAQNB1TY4SF6lGfBwU= golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= +golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg= golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek= +golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU= +golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s= golang.org/x/tools v0.29.0 h1:Xx0h3TtM9rzQpQuR4dKLrdglAmCEN5Oi+P74JdhdzXE= golang.org/x/tools v0.29.0/go.mod h1:KMQVMRsVxU6nHCFXrBPhDB8XncLNLM0lIy/F14RP588=