Linting and attempt to make Drone execute tests and linting in parallel.

This commit is contained in:
Stanislav Nikitin 2019-12-22 01:31:33 +05:00
parent e81ce2c830
commit e8a98c4ef5
No known key found for this signature in database
GPG Key ID: 106900B32F8192EE
5 changed files with 37 additions and 0 deletions

View File

@ -19,6 +19,8 @@ steps:
CGO_ENABLED: 0
commands:
- golangci-lint run
depends_on:
- notify-start
- name: test-1.13
image: golang:1.13.5-alpine
@ -26,6 +28,8 @@ steps:
CGO_ENABLED: 0
commands:
- go test -cover -test.v .
depends_on:
- notify-start
- name: test-1.12
image: golang:1.12.14-alpine
@ -34,6 +38,8 @@ steps:
GO111MODULE: on
commands:
- go test -cover -test.v .
depends_on:
- notify-start
- name: notify-end
when:
@ -52,3 +58,7 @@ steps:
{{ else }}
**{{repo.name}}#{{build.number}}@{{commit.sha}}** failed. See {{build.link}}.
{{/success}}"
depends_on:
- lint
- test-1.12
- test-1.13

18
.golangci.yml Normal file
View File

@ -0,0 +1,18 @@
run:
deadline: 5m
linters:
enable-all: true
disable:
# Because globals might exist, but according to our codestyle they
# should be lowercased and considered as unexported.
- gochecknoglobals
# While it might be useful it'll create more problems that will solve.
- gocritic
# Complains about main() lengths, which isn't an issue.
- funlen
linters-settings:
lll:
line-length: 420
gocyclo:
min-complexity: 40

View File

@ -15,5 +15,6 @@ func main() {
Type: "bool",
DefaultValue: false,
})
f.Parse()
}

View File

@ -39,12 +39,15 @@ var (
// print logs to stdout.
func New(appName string, l LoggerInterface) *Flagger {
applicationName = appName
if l == nil {
lg := log.New(os.Stdout, "Flagger: ", log.LstdFlags)
logger = LoggerInterface(lg)
} else {
logger = l
}
f := Flagger{}
return &f
}

View File

@ -56,6 +56,7 @@ func (f *Flagger) AddFlag(flag *Flag) error {
}
f.flags[flag.Name] = flag
return nil
}
@ -67,6 +68,7 @@ func (f *Flagger) GetBoolValue(name string) (bool, error) {
if !present {
return false, errors.New("No such flag: " + name)
}
return (*fl), nil
}
@ -77,6 +79,7 @@ func (f *Flagger) GetIntValue(name string) (int, error) {
if !present {
return 0, errors.New("No such flag: " + name)
}
return (*fl), nil
}
@ -87,6 +90,7 @@ func (f *Flagger) GetStringValue(name string) (string, error) {
if !present {
return "", errors.New("No such flag: " + name)
}
return (*fl), nil
}
@ -129,6 +133,7 @@ func (f *Flagger) Parse() {
}
logger.Print("Parsing CLI parameters:", os.Args)
err := f.flagSet.Parse(os.Args[1:])
if err != nil {
os.Exit(0)