无法在 Bitbucket CI 上运行 golangci-lint。

huangapple go评论90阅读模式
英文:

Unable to run golangci-lint on bitbuckt CI

问题

我在我的开发环境中使用makefile配置了golangci-lint。

Makefile

build: lint_provider
    go build -o ${BINARY}

lint_provider:
    golangci-lint run -c .golangci.yml

install: build
    mkdir -p ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}...
    mv ${BINARY} ~/terraform.d/plugins/....
   

bitbucket-pipelines.yml

pipelines:
  default:
    - step:
      image:
        hashicorp/terraform:latest
      script:
        - apk add go
        - apk add make
        - wget -0- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.44.2
        - make install
        - cd terraformprovider/examples/test
        - ./testall.sh

这个流水线失败了,显示如下错误:

+ make install
golangci-lint run -c .golangci.yml
make: golangci-lint: No such file or directory
make: *** [Makefile:12: lint_provider] Error 127

Makefile的第12行是:

golangci-lint run -c .golangci.yml

相同的设置在开发环境中是有效的,在开发环境中,使用以下命令安装了golangci-lint:

brew install golangci-lint

我该如何在bitbucket pipeline环境中执行golangci-lint?

英文:

I have setup golangci-lint in my development enviroment with configuring makefile,

MakeFile

build: lint_provider
    go build -o ${BINARY}

lint_provider:
    golangci-lint run -c .golangci.yml

install: build
    mkdir -p ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}...
    mv ${BINARY} ~/terraform.d/plugins/....
   

bitbucket-pipelines.yml

pipelines:
  default:
    - step:
      image:
        hashicorp/terraform:latest
      script:
        - apk add go
        - apk add make
        - wget -0- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.44.2
        - make install
        - cd terraformprovider/examples/test
        - ./testall.sh

this pipelining failed with

+ make install
golangci-lint run -c .golangci.yml
make: golangci-lint: No such file or directory
make: *** [Makefile:12: lint_provider] Error 127

Makefile : 12 is
golangci-lint run -c .golangci.yml

the same setup is working with the development environment
in the development environment, golangci-lint installed with
brew install golangci-lint

how do I execute golangci-lint with bitbucket pipeline environment?

答案1

得分: 1

看起来 golangci-lint 没有成功安装,或者安装在了 PATH 之外的目录中。

默认情况下,这个安装程序使用 ./bin 目录,所以你可以尝试运行 ./bin/golangci-lint run -c .golangci.yml,或者你可以使用 BINDIR 变量来设置安装路径。

英文:

Looks like golangci-lint isnt installed succesfully or installed in the directory outside of the PATH

By default this installer uses ./bin directory, so you can try ./bin/golangci-lint run -c .golangci.yml, or you can use BINDIR variable to set installation path.

huangapple
  • 本文由 发表于 2022年3月10日 19:28:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/71423369.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定