Skip to content

heppu/go-review

Repository files navigation

GoDoc Build Status Coverage Status Go Report Card

Go Review

Publish reports from different Go linters as gerrit review comments as part of CI pipe.

Install

Specific release can be installed by downloading from releases page.

Latest version from master can be installed by running: go get github.com/heppu/go-review/...

Usage

go-review uses following environment variables to access gerrit review server:

  • GERRIT_REVIEW_URL: required
  • GERRIT_CHANGE_NUMBER: required
  • GERRIT_PATCHSET_NUMBER: required
  • GERRIT_USERNAME: optional
  • GERRIT_PASSWORD: optional - This is the HTTP Credential, not the password used to login to gerrit.

Behavior can be controlled with following flags:

  • -version: print versions details and exit
  • -dry-run: parse env vars and input but do not publish review
  • -show: print lines while parsing

Examples

Every linter that is able to produce similar output as go vet can be used as an input.

go vet

go vet ./... 2>&1 | go-review

golangci-lint

 golangci-lint run --out-format=line-number --print-issued-lines=false | go-review

staticcheck

staticcheck ./... | go-review

Jenkins pipeline

stage('Lint') {
    steps {
        sh 'golangci-lint run --new-from-rev=HEAD~ --out-format=line-number --print-issued-lines=false | go-review'
    }
}