This commit is contained in:
parent
58dba906f4
commit
cc0e94690e
67
.drone.yml
Normal file
67
.drone.yml
Normal file
@ -0,0 +1,67 @@
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: testing
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
steps:
|
||||
- name: environment
|
||||
image: golang:1.18
|
||||
commands:
|
||||
- go version
|
||||
- go env
|
||||
volumes:
|
||||
- name: gopath
|
||||
path: /go
|
||||
|
||||
- name: tools
|
||||
image: golang:1.18
|
||||
commands:
|
||||
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.47.3
|
||||
- go install github.com/tebeka/go2xunit@latest
|
||||
- go install github.com/t-yuki/gocover-cobertura@latest
|
||||
volumes:
|
||||
- name: gopath
|
||||
path: /go
|
||||
|
||||
- name: lint
|
||||
image: golang:1.18
|
||||
commands:
|
||||
- echo 'Running linting'
|
||||
- golangci-lint run
|
||||
volumes:
|
||||
- name: gopath
|
||||
path: /go
|
||||
|
||||
- name: test
|
||||
image: golang:1.18
|
||||
commands:
|
||||
- go test -cover -v ./...
|
||||
volumes:
|
||||
- name: gopath
|
||||
path: /go
|
||||
|
||||
- name: send telegram notification
|
||||
image: appleboy/drone-telegram
|
||||
settings:
|
||||
token:
|
||||
from_secret: telegram_token
|
||||
to:
|
||||
from_secret: telegram_chat_id
|
||||
message: >
|
||||
{{#success build.status}}
|
||||
build {{build.number}} succeeded. Good job.
|
||||
{{else}}
|
||||
build {{build.number}} failed. Fix me please.
|
||||
{{/success}}
|
||||
when:
|
||||
status:
|
||||
- failure
|
||||
- success
|
||||
|
||||
volumes:
|
||||
- name: gopath
|
||||
temp: {}
|
211
.golangci.yml
Normal file
211
.golangci.yml
Normal file
@ -0,0 +1,211 @@
|
||||
---
|
||||
# options for analysis running
|
||||
run:
|
||||
# timeout for analysis, e.g. 30s, 5m, default is 1m
|
||||
timeout: 2m
|
||||
|
||||
issues:
|
||||
exclude:
|
||||
- abcdef
|
||||
# Excluding configuration per-path, per-linter, per-text and per-source
|
||||
exclude-rules:
|
||||
# Exclude some linters from running on tests files.
|
||||
- path: _test\.go
|
||||
linters:
|
||||
- gocyclo
|
||||
- errcheck
|
||||
- dupl
|
||||
- gosec
|
||||
# Exclude known linters from partially hard-vendored code,
|
||||
# which is impossible to exclude via `nolint` comments.
|
||||
- path: internal/hmac/
|
||||
text: "weak cryptographic primitive"
|
||||
linters:
|
||||
- gosec
|
||||
# Exclude `lll` issues for long lines with `go:generate`.
|
||||
- linters:
|
||||
- lll
|
||||
source: "^//go:generate "
|
||||
|
||||
exclude-use-default: false
|
||||
|
||||
# Maximum count of issues with the same text.
|
||||
# Set to 0 to disable.
|
||||
# Default: 3
|
||||
max-same-issues: 3
|
||||
# Maximum issues count per one linter.
|
||||
# Set to 0 to disable.
|
||||
# Default: 50
|
||||
max-issues-per-linter: 50
|
||||
|
||||
fix: false
|
||||
|
||||
output:
|
||||
sort-results: true
|
||||
|
||||
# Uncomment and add a path if needed to exclude
|
||||
# skip-dirs:
|
||||
# - some/path
|
||||
# skip-files:
|
||||
# - ".*\\.my\\.go$"
|
||||
# - lib/bad.go
|
||||
|
||||
# Find the whole list here https://golangci-lint.run/usage/linters/
|
||||
linters:
|
||||
disable-all: true
|
||||
enable:
|
||||
- asciicheck # simple linter to check that your code does not contain non-ASCII identifiers
|
||||
- bidichk
|
||||
- bodyclose # checks whether HTTP response body is closed successfully
|
||||
- containedctx
|
||||
- deadcode # finds unused code
|
||||
- decorder
|
||||
- depguard
|
||||
- dupl # tool for code clone detection
|
||||
- durationcheck # check for two durations multiplied together
|
||||
- errcheck # checking for unchecked errors in go programs
|
||||
- errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13.
|
||||
- execinquery
|
||||
- exhaustive
|
||||
- exportloopref # checks for pointers to enclosing loop variables
|
||||
- goconst # finds repeated strings that could be replaced by a constant
|
||||
- godot
|
||||
- godox # tool for detection of FIXME, TODO and other comment keywords
|
||||
- gofumpt
|
||||
- goimports # Goimports does everything that gofmt does. Additionally it checks unused imports
|
||||
- gomoddirectives # manage the use of 'replace', 'retract', and 'excludes' directives in go.mod.
|
||||
- gomodguard # check for blocked dependencies
|
||||
- gosec # inspects source code for security problems
|
||||
- gosimple # linter for Go source code that specializes in simplifying a code
|
||||
- govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
|
||||
- ifshort
|
||||
- importas # enforces consistent import aliases
|
||||
- ineffassign # detects when assignments to existing variables are not used
|
||||
- makezero
|
||||
- misspell # finds commonly misspelled English words in comments
|
||||
- nakedret # finds naked returns in functions greater than a specified function length
|
||||
- nilerr # finds the code that returns nil even if it checks that the error is not nil.
|
||||
- nilnil
|
||||
- noctx # noctx finds sending http request without context.Context
|
||||
- nolintlint # reports ill-formed or insufficient nolint directives
|
||||
- nonamedreturns
|
||||
- prealloc # finds slice declarations that could potentially be preallocated
|
||||
- sqlclosecheck
|
||||
- staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks
|
||||
- structcheck # finds unused struct fields
|
||||
- stylecheck # a replacement for golint
|
||||
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code
|
||||
- unconvert # Remove unnecessary type conversions
|
||||
- unparam # reports unused function parameters
|
||||
- unused # checks Go code for unused constants, variables, functions and types
|
||||
- varcheck # Finds unused global variables and constants
|
||||
- wastedassign # wastedassign finds wasted assignment statements.
|
||||
- whitespace
|
||||
- revive
|
||||
|
||||
# all available settings of specific linters
|
||||
linters-settings:
|
||||
errcheck:
|
||||
# report about not checking of errors in type assertions: `a := b.(MyStruct)`;
|
||||
# default is false: such cases aren't reported by default.
|
||||
check-type-assertions: true
|
||||
|
||||
errorlint:
|
||||
# Check whether fmt.Errorf uses the %w verb for formatting errors. See the readme for caveats
|
||||
errorf: true
|
||||
# Check for plain type assertions and type switches
|
||||
asserts: true
|
||||
# Check for plain error comparisons
|
||||
comparison: true
|
||||
|
||||
goconst:
|
||||
# minimal length of string constant, 3 by default
|
||||
min-len: 3
|
||||
# minimal occurrences count to trigger, 3 by default
|
||||
min-occurrences: 5
|
||||
|
||||
dupl:
|
||||
# tokens count to trigger issue, 150 by default
|
||||
threshold: 100
|
||||
|
||||
gomoddirectives:
|
||||
# Allow local `replace` directives. Default is false.
|
||||
replace-local: false
|
||||
|
||||
goimports:
|
||||
local-prefixes: github.com/elastic
|
||||
|
||||
gomodguard:
|
||||
blocked:
|
||||
# List of blocked modules.
|
||||
modules:
|
||||
# Blocked module.
|
||||
- github.com/pkg/errors:
|
||||
# Recommended modules that should be used instead. (Optional)
|
||||
recommendations:
|
||||
- errors
|
||||
- fmt
|
||||
reason: "This package is deprecated, use `fmt.Errorf` with `%w` instead"
|
||||
depguard:
|
||||
list-type:: denylist
|
||||
# Check the list against standard lib.
|
||||
include-go-root: true
|
||||
packages-with-error-message:
|
||||
- io/ioutil: "The package is deprecated, use `io` or `so` instead."
|
||||
|
||||
gosimple:
|
||||
# Select the Go version to target. The default is '1.13'.
|
||||
go: "1.18.5"
|
||||
|
||||
misspell:
|
||||
# Correct spellings using locale preferences for US or UK.
|
||||
# Default is to use a neutral variety of English.
|
||||
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
|
||||
# locale: US
|
||||
# ignore-words:
|
||||
# - IdP
|
||||
|
||||
nakedret:
|
||||
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
|
||||
max-func-lines: 0
|
||||
|
||||
prealloc:
|
||||
# Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
|
||||
# True by default.
|
||||
simple: true
|
||||
range-loops: true # Report preallocation suggestions on range loops, true by default
|
||||
for-loops: false # Report preallocation suggestions on for loops, false by default
|
||||
|
||||
nolintlint:
|
||||
# Enable to ensure that nolint directives are all used. Default is true.
|
||||
allow-unused: false
|
||||
# Disable to ensure that nolint directives don't have a leading space. Default is true.
|
||||
allow-leading-space: false
|
||||
# Exclude following linters from requiring an explanation. Default is [].
|
||||
allow-no-explanation: []
|
||||
# Enable to require an explanation of nonzero length after each nolint directive. Default is false.
|
||||
require-explanation: true
|
||||
# Enable to require nolint directives to mention the specific linter being suppressed. Default is false.
|
||||
require-specific: true
|
||||
|
||||
staticcheck:
|
||||
# Select the Go version to target. The default is '1.13'.
|
||||
go: "1.18.5"
|
||||
# https://staticcheck.io/docs/options#checks
|
||||
checks: ["all"]
|
||||
|
||||
stylecheck:
|
||||
# Select the Go version to target. The default is '1.13'.
|
||||
go: "1.18.5"
|
||||
checks: ["all"]
|
||||
|
||||
unparam:
|
||||
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
|
||||
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
|
||||
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations
|
||||
# with golangci-lint call it on a directory with the changed file.
|
||||
check-exported: false
|
||||
|
||||
unused:
|
||||
# Select the Go version to target. The default is '1.13'.
|
||||
go: "1.18.5"
|
41
Jenkinsfile
vendored
41
Jenkinsfile
vendored
@ -1,41 +0,0 @@
|
||||
pipeline {
|
||||
agent any
|
||||
tools {
|
||||
go 'go1.18.5'
|
||||
}
|
||||
stages {
|
||||
stage('Pre Test') {
|
||||
steps {
|
||||
echo 'Installing dependencies'
|
||||
sh 'go version'
|
||||
sh 'go install golang.org/x/lint/golint@latest'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build') {
|
||||
steps {
|
||||
echo 'Compiling and building'
|
||||
sh 'go build'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Lint') {
|
||||
steps {
|
||||
echo 'Running vetting'
|
||||
sh 'go vet ./...'
|
||||
echo 'Running linting'
|
||||
sh 'golint ./...'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Unit-Test') {
|
||||
steps {
|
||||
echo 'Run All unit test'
|
||||
sh 'go test -cover ./...'
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
post {
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user