为什么 GitHub Actions 中的 linting 在本地工作时不起作用?
我正在构建一个 Go 项目,并且在每次签入时都使用 GitHub 操作。
该项目在这里: https://github.com/filecoin-project/bacalhau
当我在本地运行该项目,它运行良好 - 例如:
❯ golangci-lint run
❯
但是当我在 GitHub Actions 中执行相同的命令时,我收到警告,就像我没有正确地在模块中供应一样(猜测)。
Error: undeclared name: `libp2p` (typecheck)
Error: undeclared name: `libp2p` (typecheck)
Error: undeclared name: `libp2p` (typecheck)
Error: "github.com/libp2p/go-libp2p" imported but not used (typecheck)
Error: issues found
即使当我删除 linting 时,我也会遇到类似的问题(它无法正确构建 - 例如 https://github.com/filecoin-project/bacalhau/runs/5313987141?check_suite_focus=true
有一次我自己通过 ssh 登录并手动执行构建(例如 go build
),它失败并出现相同的错误,但这可以通过执行 来解决>go modvendor
, go mod tidy
inline 但是,这应该是不必要的,对吧?因为我已经签入了供应商目录?
谢谢!
I'm building a Go project, and I'm using GitHub actions on every checkin.
The project is here: https://github.com/filecoin-project/bacalhau
When I run the project locally, it runs fine - e.g.:
❯ golangci-lint run
❯
But when I do the same command in GitHub Actions, I get warnings like I haven't vendored in the modules correctly (guessing).
Error: undeclared name: `libp2p` (typecheck)
Error: undeclared name: `libp2p` (typecheck)
Error: undeclared name: `libp2p` (typecheck)
Error: "github.com/libp2p/go-libp2p" imported but not used (typecheck)
Error: issues found
Even when I remove the linting, I get similar problems (it doesn't build properly - e.g. https://github.com/filecoin-project/bacalhau/runs/5313987141?check_suite_focus=true
The ONE time I logged in myself, via ssh, and executed the build manually (e.g. go build
) it failed with the same error, but this was solveable by just doing go mod vendor
, go mod tidy
inline. HOWEVER, this shouldn't be necessary, right? Because I've checked in a vendor directory?
What am I missing? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过清除 /vendor 目录中的所有内容并 .gitignoring 它来解决这个问题。这迫使 GitHub actions 重新下载所有内容。不确定这是否是最有效的解决方案,但对我有用!
I solved this by blowing away everything in my /vendor dir, and .gitignoring it. This forced GitHub actions to redownload everything. Not sure if this was the most efficient solution, but worked for me!