Uploaded image for project: 'OpenShift Bugs'
  1. OpenShift Bugs
  2. OCPBUGS-29785

golangci-lint fails with "gocritic" error

XMLWordPrintable

    • Quality / Stability / Reliability
    • False
    • Hide

      None

      Show
      None
    • None
    • None
    • No
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Description of problem:

          Unable to run `hack/go-lint.sh` from MacBook (Sonoma 14.3.1)

      Version-Release number of selected component (if applicable):

          

      How reproducible:

          Every time.

      Steps to Reproduce:

          1. (installer repo) hack/go-lint.sh
          2.
          3.
          

      Actual results:

      {{➜ installer git:(test-go-lint) hack/go-lint.sh git:(test-go-lint|) }}
      Trying to pull docker.io/golangci/golangci-lint:v1.53.1...
      Getting image source signatures
      Copying blob sha256:e48eb6dc33832efce80c6178184bd3f3c3d1885c629eca47356cc8f87eabed42
      Copying blob sha256:b04fae59f135dd79280e4a6da39408e04c6d703c617cbcb1c524dfe6f2962fe5
      Copying blob sha256:24cef00b9ad96bea3be667b285f4b22763747912cc8e4f2c3f145facb418d71d
      Copying blob sha256:1db91b65282bc9aae941329f294e69b2671a6429827e8b357b950a2c112ef783
      Copying blob sha256:c4272e98011d52d5967d5c90e0f0e20f10a769ca8f63d78ffeec4c70cb81790b
      Copying blob sha256:0485189e9a3745f2aa6388120c6069ba16121d7cca3544ca9cca209e38e19944
      Copying blob sha256:768893585f2fa3bcc33a989624a4b465f9e7f67b712f588fcd7b4fa46145cfc5
      Copying config sha256:c6a70838ab1b5d3234e7d0da54a21e7f92c66710e54ed2ef3bf2acb6b1368384
      Writing manifest to image destination
      Error: preparing container 4a49bf8833589e774b8a677ef86a0fe7334d84614ff4ff778da9701fc365ecc5 for attach: lsetxattr /Users/jnowicki/dev/github.com/jeffnowicki/installer/.git: operation not supported

      Expected results:

          To output any linting errors.

      Additional info:

       

      Suspecting the issue is related to the mount using `:z` option and podman not running as 'root'? Regardless, I haven't been able to resolve, and started using `docker` instead.

      (using `docker` uncovered a `gocritic` issue:

      {{docker run --rm \ git:(test-go-lint|) }}
      {{--env IS_CONTAINER=TRUE }}
      {{--volume "${PWD}:/go/src/github.com/openshift/installer:z" }}
      {{--workdir /go/src/github.com/openshift/installer }}
      {{docker.io/golangci/golangci-lint:v1.53.1 }}
      golangci-lint run --new-from-rev=dcf8122 "${@}"
      Unable to find image 'golangci/golangci-lint:v1.53.1' locally
      v1.53.1: Pulling from golangci/golangci-lint
      {{bd73737482dd: Pull complete }}
      {{6710592d62aa: Pull complete }}
      {{75256935197e: Pull complete }}
      {{948a624948ba: Pull complete }}
      {{147e02c24f40: Pull complete }}
      {{cd56b3199c0c: Pull complete }}
      {{47c9f1f884e2: Pull complete }}
      Digest: sha256:1d3e531d92b54c8ee7207d591cfc9c19ef96138ddad4c0103935501d5aca2616
      Status: Downloaded newer image for golangci/golangci-lint:v1.53.1
      level=error msg="[linters_context] gocritic: load embedded ruleguard rules: rules/rules.go:13: can't load fmt: setting an explicit GOROOT can fix this problem."

      led me to this issue/comment: https://github.com/golangci/golangci-lint/issues/3107#issuecomment-1886755808

      confirmed success:

      {{➜ installer git:(test-go-lint) ✗ docker run --rm \ git:(test-go-lint|…1 }}
      {{--env IS_CONTAINER=TRUE }}
      {{--volume "${PWD}:/go/src/github.com/openshift/installer:z" }}
      {{--workdir /go/src/github.com/openshift/installer }}
      {{docker.io/golangci/golangci-lint:v1.55.2 }}
      golangci-lint run --new-from-rev=dcf8122 "${@}"
      Unable to find image 'golangci/golangci-lint:v1.55.2' locally
      v1.55.2: Pulling from golangci/golangci-lint
      {{8457fd5474e7: Pull complete }}
      {{13baa2029dde: Pull complete }}
      {{325c5bf4c2f2: Pull complete }}
      {{c185020e1367: Pull complete }}
      {{16418b73e8ce: Pull complete }}
      {{d0b897dfffc2: Pull complete }}
      {{5ade916a2c13: Pull complete }}
      {{d309b1390c82: Pull complete }}
      Digest: sha256:e699df940be1810b08ba6ec050bfc34cc1931027283b5a7f607fb6a67b503876
      Status: Downloaded newer image for golangci/golangci-lint:v1.55.2
      pkg/asset/machines/baremetal/hosts_test.go:435:5: hb.Spec undefined (type *hostBuilder has no field or method Spec) (typecheck)
      hb.Spec.CustomDeploy = &baremetalhost.CustomDeploy{
      ^
      ...

              Unassigned Unassigned
              jeffbnowickirh Jeff Nowicki
              None
              None
              Gaoyun Pei Gaoyun Pei
              None
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: