diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..8298624 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,72 @@ +--- +kind: pipeline +type: docker +name: default + +trigger: + event: + - push + - pull_request + - tag + +steps: + - name: Lint + image: docker.io/golangci/golangci-lint:latest + environment: + GO111MODULE: "on" + CGO_ENABLED: "0" + GOMEMLIMIT: "1150MiB" + volumes: + - name: go-cache + path: /go + commands: + - golangci-lint run -v + + - name: Test + image: docker.io/golang:1.20-bullseye + network_mode: host + environment: + GO111MODULE: "on" + CGO_ENABLED: "1" + DOCKER_HOST: tcp://localhost:2375 + volumes: + - name: go-cache + path: /go + commands: + - go install gotest.tools/gotestsum@latest + - gotestsum --junitfile out/results.xml --format pkgname-and-test-fails -- -race -shuffle=on ./... + + - name: junit-reports + image: ghcr.io/rohit-gohri/drone-junit:v0 + settings: + paths: out/results.xml + +volumes: + - name: go-cache + temp: { } + + --- +kind: pipeline +type: docker +name: housekeeping + +trigger: + event: + - cron + cron: + - housekeeping + +steps: + - name: Renovate + image: code.icb4dc0.de/prskr/ci-images/renovate:latest + commands: + - renovate "${DRONE_REPO}" + environment: + RENOVATE_TOKEN: + from_secret: gitea_token + GITHUB_COM_TOKEN: + from_secret: github_token + RENOVATE_PLATFORM: gitea + RENOVATE_AUTODISCOVER: "false" + RENOVATE_ENDPOINT: https://code.icb4dc0.de/api/v1 + LOG_LEVEL: info diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..4c441b8 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,27 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +tab_width = 4 +indent_style = space +insert_final_newline = false +max_line_length = 120 +trim_trailing_whitespace = true + +[*.go] +indent_style = tab +ij_smart_tabs = true +ij_go_GROUP_CURRENT_PROJECT_IMPORTS = true +ij_go_group_stdlib_imports = true +ij_go_import_sorting = goimports +ij_go_local_group_mode = project +ij_go_move_all_imports_in_one_declaration = true +ij_go_move_all_stdlib_imports_in_one_group = true +ij_go_remove_redundant_import_aliases = true + +[*.{yaml,yml}] +indent_size = 2 +tab_width = 2 +insert_final_newline = true diff --git a/.gitignore b/.gitignore index adf8f72..22952ec 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ # Go workspace file go.work +.idea/ \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..e7622dd --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,131 @@ +linters-settings: + dupl: + threshold: 100 + funlen: + lines: 100 + statements: 50 + gci: + local-prefixes: code.icb4dc0.de/prskr/nurse + goconst: + min-len: 2 + min-occurrences: 2 + gocritic: + enabled-tags: + - diagnostic + - opinionated + - performance + disabled-checks: + - ifElseChain + - octalLiteral + - wrapperFunc + # see https://github.com/golangci/golangci-lint/issues/2649 + - hugeParam + - rangeValCopy + # settings: + # hugeParam: + # sizeThreshold: 200 + + gocyclo: + min-complexity: 15 + goimports: + local-prefixes: code.1533b4dc0.de/prskr/nurse + golint: + min-confidence: 0 + gomnd: + settings: + mnd: + # don't include the "operation" and "assign" + checks: + - argument + - case + - condition + - return + gomoddirectives: + replace-allow-list: + - github.com/docker/docker + govet: + check-shadowing: true + enable-all: true + disable: + - fieldalignment + # see https://github.com/golangci/golangci-lint/issues/2649 + - nilness + - unusedwrite + importas: + no-unaliased: true + lll: + line-length: 140 + misspell: + locale: US + +linters: + disable-all: true + enable: + - contextcheck + - dogsled + - dupl + - errcheck + - errchkjson + - errname + - errorlint + - exhaustive + - exportloopref + - funlen + - gocognit + - goconst + # - gocritic + - gocyclo + - godox + - gofumpt + - goimports + - gomoddirectives + - gomnd + - gosec + - gosimple + - govet + - importas + - ineffassign + # - ireturn - enable later + - lll + - misspell + - nakedret + - nestif + - nilnil + - noctx + - nolintlint + - paralleltest + - prealloc + - predeclared + - promlinter + - staticcheck + - stylecheck + - testpackage + - thelper + # - typecheck + - unconvert + - unparam + - whitespace + - unused + - wastedassign + +issues: + # Excluding configuration per-path, per-linter, per-text and per-source + exclude-rules: + - path: _test\.go + linters: + - dupl + - funlen + - gocognit + - gomnd + - govet + - path: magefiles/.*\.go + linters: + - typecheck + - unused + - govet + +run: + skip-files: + - ".*.mock.\\.go$" + modules-download-mode: readonly + timeout: 5m diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..ec3597f --- /dev/null +++ b/go.mod @@ -0,0 +1,13 @@ +module code.icb4dc0.de/prskr/nitter + +go 1.20 + +require ( + code.gitea.io/sdk/gitea v0.15.1 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect + github.com/golangci/golangci-lint v1.51.2 // indirect + github.com/hashicorp/go-version v1.6.0 // indirect + github.com/russross/blackfriday/v2 v2.1.0 // indirect + github.com/urfave/cli/v2 v2.25.0 // indirect + github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..c927a45 --- /dev/null +++ b/go.sum @@ -0,0 +1,39 @@ +code.gitea.io/gitea-vet v0.2.1/go.mod h1:zcNbT/aJEmivCAhfmkHOlT645KNOf9W2KnkLgFjGGfE= +code.gitea.io/sdk/gitea v0.15.1 h1:WJreC7YYuxbn0UDaPuWIe/mtiNKTvLN8MLkaw71yx/M= +code.gitea.io/sdk/gitea v0.15.1/go.mod h1:klY2LVI3s3NChzIk/MzMn7G1FHrfU7qd63iSMVoHRBA= +github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= +github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/golangci/golangci-lint v1.51.2 h1:yIcsT1X9ZYHdSpeWXRT1ORC/FPGSqDHbHsu9uk4FK7M= +github.com/golangci/golangci-lint v1.51.2/go.mod h1:KH9Q7/3glwpYSknxUgUyLlAv46A8fsSKo1hH2wDvkr8= +github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= +github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/urfave/cli/v2 v2.25.0 h1:ykdZKuQey2zq0yin/l7JOm9Mh+pg72ngYMeB0ABn6q8= +github.com/urfave/cli/v2 v2.25.0/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= +github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200325010219-a49f79bcc224/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/main.go b/main.go new file mode 100644 index 0000000..395fa86 --- /dev/null +++ b/main.go @@ -0,0 +1,16 @@ +package main + +import ( + "log" + "os" + + "github.com/urfave/cli/v2" +) + +func main() { + app := &cli.App{} + + if err := app.Run(os.Args); err != nil { + log.Fatal(err) + } +} diff --git a/nitters/gitea/pr_nitter.go b/nitters/gitea/pr_nitter.go new file mode 100644 index 0000000..1a841a4 --- /dev/null +++ b/nitters/gitea/pr_nitter.go @@ -0,0 +1,11 @@ +package gitea + +import "code.gitea.io/sdk/gitea" + +type PRNitter struct { + client *gitea.Client + + Namespace string + Repo string + PRIndex int64 +} diff --git a/nitters/nitter.go b/nitters/nitter.go new file mode 100644 index 0000000..6776063 --- /dev/null +++ b/nitters/nitter.go @@ -0,0 +1,9 @@ +package nitters + +import ( + "github.com/golangci/golangci-lint/pkg/printers" +) + +type Nitter interface { + Report(result printers.JSONResult) error +} diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..ee8c906 --- /dev/null +++ b/renovate.json @@ -0,0 +1,5 @@ +{ + "extends": [ + "config:base" + ] +}