Linting and attempt to make Drone execute tests and linting in parallel.
This commit is contained in:
parent
e81ce2c830
commit
e8a98c4ef5
10
.drone.yml
10
.drone.yml
@ -19,6 +19,8 @@ steps:
|
|||||||
CGO_ENABLED: 0
|
CGO_ENABLED: 0
|
||||||
commands:
|
commands:
|
||||||
- golangci-lint run
|
- golangci-lint run
|
||||||
|
depends_on:
|
||||||
|
- notify-start
|
||||||
|
|
||||||
- name: test-1.13
|
- name: test-1.13
|
||||||
image: golang:1.13.5-alpine
|
image: golang:1.13.5-alpine
|
||||||
@ -26,6 +28,8 @@ steps:
|
|||||||
CGO_ENABLED: 0
|
CGO_ENABLED: 0
|
||||||
commands:
|
commands:
|
||||||
- go test -cover -test.v .
|
- go test -cover -test.v .
|
||||||
|
depends_on:
|
||||||
|
- notify-start
|
||||||
|
|
||||||
- name: test-1.12
|
- name: test-1.12
|
||||||
image: golang:1.12.14-alpine
|
image: golang:1.12.14-alpine
|
||||||
@ -34,6 +38,8 @@ steps:
|
|||||||
GO111MODULE: on
|
GO111MODULE: on
|
||||||
commands:
|
commands:
|
||||||
- go test -cover -test.v .
|
- go test -cover -test.v .
|
||||||
|
depends_on:
|
||||||
|
- notify-start
|
||||||
|
|
||||||
- name: notify-end
|
- name: notify-end
|
||||||
when:
|
when:
|
||||||
@ -52,3 +58,7 @@ steps:
|
|||||||
{{ else }}
|
{{ else }}
|
||||||
**{{repo.name}}#{{build.number}}@{{commit.sha}}** failed. See {{build.link}}.
|
**{{repo.name}}#{{build.number}}@{{commit.sha}}** failed. See {{build.link}}.
|
||||||
{{/success}}"
|
{{/success}}"
|
||||||
|
depends_on:
|
||||||
|
- lint
|
||||||
|
- test-1.12
|
||||||
|
- test-1.13
|
||||||
|
18
.golangci.yml
Normal file
18
.golangci.yml
Normal 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
|
||||||
|
|
@ -15,5 +15,6 @@ func main() {
|
|||||||
Type: "bool",
|
Type: "bool",
|
||||||
DefaultValue: false,
|
DefaultValue: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
f.Parse()
|
f.Parse()
|
||||||
}
|
}
|
||||||
|
@ -39,12 +39,15 @@ var (
|
|||||||
// print logs to stdout.
|
// print logs to stdout.
|
||||||
func New(appName string, l LoggerInterface) *Flagger {
|
func New(appName string, l LoggerInterface) *Flagger {
|
||||||
applicationName = appName
|
applicationName = appName
|
||||||
|
|
||||||
if l == nil {
|
if l == nil {
|
||||||
lg := log.New(os.Stdout, "Flagger: ", log.LstdFlags)
|
lg := log.New(os.Stdout, "Flagger: ", log.LstdFlags)
|
||||||
logger = LoggerInterface(lg)
|
logger = LoggerInterface(lg)
|
||||||
} else {
|
} else {
|
||||||
logger = l
|
logger = l
|
||||||
}
|
}
|
||||||
|
|
||||||
f := Flagger{}
|
f := Flagger{}
|
||||||
|
|
||||||
return &f
|
return &f
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,7 @@ func (f *Flagger) AddFlag(flag *Flag) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
f.flags[flag.Name] = flag
|
f.flags[flag.Name] = flag
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,6 +68,7 @@ func (f *Flagger) GetBoolValue(name string) (bool, error) {
|
|||||||
if !present {
|
if !present {
|
||||||
return false, errors.New("No such flag: " + name)
|
return false, errors.New("No such flag: " + name)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (*fl), nil
|
return (*fl), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,6 +79,7 @@ func (f *Flagger) GetIntValue(name string) (int, error) {
|
|||||||
if !present {
|
if !present {
|
||||||
return 0, errors.New("No such flag: " + name)
|
return 0, errors.New("No such flag: " + name)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (*fl), nil
|
return (*fl), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,6 +90,7 @@ func (f *Flagger) GetStringValue(name string) (string, error) {
|
|||||||
if !present {
|
if !present {
|
||||||
return "", errors.New("No such flag: " + name)
|
return "", errors.New("No such flag: " + name)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (*fl), nil
|
return (*fl), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,6 +133,7 @@ func (f *Flagger) Parse() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logger.Print("Parsing CLI parameters:", os.Args)
|
logger.Print("Parsing CLI parameters:", os.Args)
|
||||||
|
|
||||||
err := f.flagSet.Parse(os.Args[1:])
|
err := f.flagSet.Parse(os.Args[1:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
Loading…
Reference in New Issue
Block a user