diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1a0f663215901c43a469bcc989a28fcac8daf979..d6cdee3521052226078b7692282ea40c5189d1f4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,6 +20,7 @@ include: - template: Security/SAST.gitlab-ci.yml - template: Security/Dependency-Scanning.gitlab-ci.yml - template: Security/Secret-Detection.gitlab-ci.yml + - local: ".gitlab/ci/lint.gitlab-ci.yml" # From: https://docs.gitlab.com/ee/ci/caching/#cache-go-dependencies diff --git a/.gitlab/ci/lint.gitlab-ci.yml b/.gitlab/ci/lint.gitlab-ci.yml index 29ca259d7053c6e12fc9a35555b43b81ec7b5be6..cad0601492357001fd2102390df41880bde8515e 100644 --- a/.gitlab/ci/lint.gitlab-ci.yml +++ b/.gitlab/ci/lint.gitlab-ci.yml @@ -2,12 +2,14 @@ lint: image: registry.gitlab.com/gitlab-org/gitlab-build-images:golangci-lint-alpine stage: test script: + - golangci-lint --version # Use default .golangci.yml file from the image if one is not present in the project root. - '[ -e .golangci.yml ] || cp /golangci/.golangci.yml .' # Write the code coverage report to gl-code-quality-report.json - # and print linting issues to stdout in the format: path/to/file:line description # remove `--issues-exit-code 0` or set to non-zero to fail the job if linting issues are detected - - golangci-lint run --issues-exit-code 0 --out-format code-climate | tee gl-code-quality-report.json | jq -r '.[] | "\(.location.path):\(.location.lines.begin) \(.description)"' + - golangci-lint run --issues-exit-code 1 --out-format colored-line-number:stdout,code-climate:gl-code-quality-report.json + allow_failure: + exit_codes: 1 artifacts: reports: codequality: gl-code-quality-report.json diff --git a/.golangci.yml b/.golangci.yml index f3f3e90f9b9bf217ee6f91020566df84c53a92e9..ccf71c623607fdf83ba776bbeb631e34bb60cb99 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,6 +1,16 @@ linters: enable: + - errcheck + - gosimple - gofmt + - govet + - ineffassign + - staticcheck + - typecheck + - unused + - exhaustive + - exportloopref + - prealloc run: timeout: 5m