Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run returns 0 on build failure #2357

Closed
4 tasks done
antoineco opened this issue Nov 13, 2021 · 1 comment · Fixed by #2471
Closed
4 tasks done

Run returns 0 on build failure #2357

antoineco opened this issue Nov 13, 2021 · 1 comment · Fixed by #2471
Labels
bug Something isn't working

Comments

@antoineco
Copy link

antoineco commented Nov 13, 2021

Welcome

  • Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc).
  • Yes, I've tried with the standalone linter if available. (https://golangci-lint.run/usage/linters/)

Description of the problem

I noticed while looking at the CI logs of the following PR that golangci-lint run was returning with an exit code of 0, although the code doesn't compile: triggermesh/triggermesh#263

I can see the following warning in the logs:

WARN [runner] Can't run linter goanalysis_metalinter: buildir: failed to load package cortex: could not load export data: no export data for "go.opentelemetry.io/contrib/exporters/metric/cortex"

The dependency that fails to build is indeed the one I expected, but the outcome and the message are surprising to me.
My reasoning is that:

  1. If such failure occurs, it's unlikely that the code can be considered acceptable.
  2. If I see this message in isolation from the change, I'm unlikely to be able to determine where the linter failed, and why.

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version v1.43.0 built from (unknown, mod sum: "h1:SLwZFEmDgopqZpfP495zCtV9REUf551JJlJ51Ql7NZA=") on (unknown)

Configuration file

linters:
  enable:
  - gofmt
  - stylecheck

run:
  timeout: 10m

Go environment

$ go version && go env
go version go1.17.2 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/acotten/.cache/go-build"
GOENV="/home/acotten/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/acotten/go/pkg/mod"
GONOPROXY="github.com/triggermesh/*"
GONOSUMDB="github.com/triggermesh/*"
GOOS="linux"
GOPATH="/home/acotten/go"
GOPRIVATE="github.com/triggermesh/*"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17.2"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/acotten/go/src/github.com/triggermesh/triggermesh/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2177709345=/tmp/go-build -gno-record-gcc-switches"

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /home/acotten/go/src/github.com/triggermesh/triggermesh /home/acotten/go/src/github.com/triggermesh /home/acotten/go/src/github.com /home/acotten/go/src /home/acotten/go /home/acotten /home /]
INFO [config_reader] Used config file .golangci.yaml
INFO [lintersdb] Active 12 linters: [deadcode errcheck gofmt gosimple govet ineffassign staticcheck structcheck stylecheck typecheck unused varcheck]
INFO [loader] Go packages loading at mode 575 (deps|exports_file|compiled_files|files|imports|name|types_sizes) took 2.9607695s
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 94.7101ms
INFO [linters context/goanalysis] analyzers took 9m18.8387247s with top 10 stages: buildir: 6m32.1698428s, nilness: 48.5924902s, typedness: 6.8536132s, inspect: 4.6726596s, fact_deprecated: 4.2246186s, gofmt: 3.88425s, fact_purity: 3.8326054s, ctrlflow: 3.3801925s, printf: 3.1457179s, unused: 2.4407979s
WARN [runner] Can't run linter goanalysis_metalinter: buildir: failed to load package cortex: could not load export data: no export data for "go.opentelemetry.io/contrib/exporters/metric/cortex"
INFO [runner] processing took 4.9µs with stages: max_same_issues: 1.1µs, nolint: 500ns, skip_dirs: 500ns, autogenerated_exclude: 300ns, filename_unadjuster: 300ns, identifier_marker: 300ns, cgo: 300ns, max_from_linter: 200ns, exclude: 200ns, skip_files: 200ns, path_prettifier: 200ns, diff: 100ns, source_code: 100ns, path_prefixer: 100ns, uniq_by_line: 100ns, exclude-rules: 100ns, max_per_file_from_linter: 100ns, sort_results: 100ns, path_shortener: 100ns, severity-rules: 0s
INFO [runner] linters took 1m9.6487956s with stages: goanalysis_metalinter: 1m9.6485264s
INFO File cache stats: 0 entries of total size 0B
INFO Memory: 524 samples, avg is 2190.5MB, max is 2950.1MB
INFO Execution took 1m12.7177277s

Code example or link to a public repository

See aforementioned PR.

The error is in this specific package:

https://github.com/triggermesh/triggermesh/tree/dependabot/go_modules/go.opentelemetry.io/otel/sdk/metric-0.25.0/pkg/targets/adapter/opentelemetrytarget

@antoineco antoineco added the bug Something isn't working label Nov 13, 2021
@ldez
Copy link
Member

ldez commented Nov 13, 2021

Hello,

WARN [runner] Can't run linter goanalysis_metalinter: buildir: failed to load package cortex: could not load export data: no export data for "go.opentelemetry.io/contrib/exporters/metric/cortex"

buildir is one of the passes of the staticcheck linters (staticcheck, stylecheck, gosimple, unused)

The typecheck/compile step seems to be skipped in this case, for now, I don't know why but I will try to investigate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants