From 6f4ee04e55355ae8b1d83a81f102882e10ab81b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sun, 21 Sep 2025 14:45:42 +0800 Subject: [PATCH] feat: add ci --- .github/workflows/go-vet.yml | 43 +++++++++++++++++++++++ .golangci.yml | 68 ++++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 .github/workflows/go-vet.yml create mode 100644 .golangci.yml diff --git a/.github/workflows/go-vet.yml b/.github/workflows/go-vet.yml new file mode 100644 index 0000000..ed30d12 --- /dev/null +++ b/.github/workflows/go-vet.yml @@ -0,0 +1,43 @@ +name: golang-ci + +on: [push, pull_request] + +jobs: + + build: + name: CI + runs-on: ubuntu-latest + steps: + - name: Set up Go 1.x + uses: actions/setup-go@master + with: + go-version: "1.20" + + - name: Check out code into the Go module directory + uses: actions/checkout@master + + - name: Get dependencies + run: go mod tidy + + - name: Build + run: go build -v ./... + + - name: Test + run: go test $(go list ./...) + + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - name: Set up Go 1.x + uses: actions/setup-go@master + with: + go-version: "1.20" + + - name: Check out code into the Go module directory + uses: actions/checkout@master + + - name: golangci-lint + uses: golangci/golangci-lint-action@master + with: + version: latest diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..6fca97b --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,68 @@ +linters-settings: + errcheck: + ignore: fmt:.*,io/ioutil:^Read.* + ignoretests: true + + goimports: + local-prefixes: github.com/fumiama/go-onebot-agent + +linters: + # please, do not use `enable-all`: it's deprecated and will be removed soon. + # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint + disable-all: true + fast: false + enable: + - bodyclose + #- depguard + - dogsled + - errcheck + #- exportloopref + - exhaustive + #- funlen + #- goconst + - gocritic + #- gocyclo + - gofmt + - goimports + - goprintffuncname + #- gosec + - gosimple + - govet + - ineffassign + #- misspell + - nolintlint + - rowserrcheck + - staticcheck + - stylecheck + - typecheck + - unconvert + - unparam + - unused + - whitespace + - prealloc + - predeclared + - asciicheck + - revive + - forbidigo + - makezero + + +run: + # default concurrency is a available CPU number. + # concurrency: 4 # explicitly omit this value to fully utilize available resources. + deadline: 5m + issues-exit-code: 1 + tests: false + go: '1.20' + +# output configuration options +output: + formats: + - format: "colored-line-number" + print-issued-lines: true + print-linter-name: true + uniq-by-line: true + +issues: + # Fix found issues (if it's supported by the linter) + fix: true