From 539a3d918e79cad325c9578ea0af9eefbf3f50e4 Mon Sep 17 00:00:00 2001 From: Frederic BIDON Date: Mon, 23 Nov 2020 20:42:29 +0100 Subject: [PATCH] updated CI config * re-enacted linter in CI * bumped golang versions used by CI * updated golangci settings * fixed a few cosmetic linting issues (comments) * reduced the matrix of jobs run by CI Signed-off-by: Frederic BIDON --- .golangci.yml | 21 +++++++++++++++++++++ .travis.yml | 18 ++++++++++++++++-- schema_test.go | 22 +++++++++++----------- 3 files changed, 48 insertions(+), 13 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 6badaf1..f9381ae 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -18,3 +18,24 @@ linters: - maligned - lll - gochecknoglobals + - godox + - gocognit + - whitespace + - wsl + - funlen + - gochecknoglobals + - gochecknoinits + - scopelint + - wrapcheck + - exhaustivestruct + - exhaustive + - nlreturn + - testpackage + - gci + - gofumpt + - goerr113 + - gomnd + - tparallel + - nestif + - godot + - errorlint diff --git a/.travis.yml b/.travis.yml index 57631a0..e4a01bf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,25 @@ after_success: - bash <(curl -s https://codecov.io/bash) go: -- 1.13.x - 1.14.x +- 1.x arch: - amd64 - - ppc64le +jobs: + include: + # only run fast tests on ppc64le + - go: 1.x + arch: ppc64le + script: + - gotestsum -f short-verbose -- ./... + + # include linting job, but only for latest go version and amd64 arch + - go: 1.x + arch: amd64 + install: + go get github.com/golangci/golangci-lint/cmd/golangci-lint + script: + - golangci-lint run --new-from-rev master install: - GO111MODULE=off go get -u gotest.tools/gotestsum language: go diff --git a/schema_test.go b/schema_test.go index 7dcaa5d..fe0535e 100644 --- a/schema_test.go +++ b/schema_test.go @@ -351,7 +351,7 @@ func TestSchemaErrors(t *testing.T) { assert.EqualValues(t, CompositeErrorCode, err2.Code()) assert.Equal(t, "validation failure list:\nfirst error\nsecond error", err2.Error()) - //func MultipleOfMustBePositive(name, in string, factor interface{}) *Validation { + // func MultipleOfMustBePositive(name, in string, factor interface{}) *Validation { err = MultipleOfMustBePositive("path", "body", float64(-10)) assert.Error(t, err) assert.EqualValues(t, MultipleOfMustBePositiveCode, err.Code()) @@ -368,52 +368,52 @@ func TestSchemaErrors(t *testing.T) { err = PropertyNotAllowed("path", "body", "key") assert.Error(t, err) assert.EqualValues(t, UnallowedPropertyCode, err.Code()) - //unallowedProperty = "%s.%s in %s is a forbidden property" + // unallowedProperty = "%s.%s in %s is a forbidden property" assert.Equal(t, "path.key in body is a forbidden property", err.Error()) err = PropertyNotAllowed("path", "", "key") assert.Error(t, err) assert.EqualValues(t, UnallowedPropertyCode, err.Code()) - //unallowedPropertyNoIn = "%s.%s is a forbidden property" + // unallowedPropertyNoIn = "%s.%s is a forbidden property" assert.Equal(t, "path.key is a forbidden property", err.Error()) - //func TooManyProperties(name, in string, n int64) *Validation { + // func TooManyProperties(name, in string, n int64) *Validation { err = TooManyProperties("path", "body", 10) assert.Error(t, err) assert.EqualValues(t, TooManyPropertiesCode, err.Code()) - //tooManyProperties = "%s in %s should have at most %d properties" + // tooManyProperties = "%s in %s should have at most %d properties" assert.Equal(t, "path in body should have at most 10 properties", err.Error()) err = TooManyProperties("path", "", 10) assert.Error(t, err) assert.EqualValues(t, TooManyPropertiesCode, err.Code()) - //tooManyPropertiesNoIn = "%s should have at most %d properties" + // tooManyPropertiesNoIn = "%s should have at most %d properties" assert.Equal(t, "path should have at most 10 properties", err.Error()) err = TooFewProperties("path", "body", 10) // func TooFewProperties(name, in string, n int64) *Validation { assert.Error(t, err) assert.EqualValues(t, TooFewPropertiesCode, err.Code()) - //tooFewProperties = "%s in %s should have at least %d properties" + // tooFewProperties = "%s in %s should have at least %d properties" assert.Equal(t, "path in body should have at least 10 properties", err.Error()) err = TooFewProperties("path", "", 10) // func TooFewProperties(name, in string, n int64) *Validation { assert.Error(t, err) assert.EqualValues(t, TooFewPropertiesCode, err.Code()) - //tooFewPropertiesNoIn = "%s should have at least %d properties" + // tooFewPropertiesNoIn = "%s should have at least %d properties" assert.Equal(t, "path should have at least 10 properties", err.Error()) - //func FailedAllPatternProperties(name, in, key string) *Validation { + // func FailedAllPatternProperties(name, in, key string) *Validation { err = FailedAllPatternProperties("path", "body", "key") assert.Error(t, err) assert.EqualValues(t, FailedAllPatternPropsCode, err.Code()) - //failedAllPatternProps = "%s.%s in %s failed all pattern properties" + // failedAllPatternProps = "%s.%s in %s failed all pattern properties" assert.Equal(t, "path.key in body failed all pattern properties", err.Error()) err = FailedAllPatternProperties("path", "", "key") assert.Error(t, err) assert.EqualValues(t, FailedAllPatternPropsCode, err.Code()) - //failedAllPatternPropsNoIn = "%s.%s failed all pattern properties" + // failedAllPatternPropsNoIn = "%s.%s failed all pattern properties" assert.Equal(t, "path.key failed all pattern properties", err.Error()) }