Github actions can't find package within repository

时光怂恿深爱的人放手 提交于 2020-07-10 04:51:33

问题


When setting up a github actions pipeline, I can't get it to find packages that are within my repository, and the test fails because it's missing packages.

What happens is that it clones the repo someplace but doesn't include the cloned repo's directories to look for packages. That fails because I am importing packages from within that repo in my code.

I believe my directory structure is sound because I have no trouble testing and building locally:

.                                                                                                                                                           │
├── extractors                                                                                                                                              │
│   ├── fip.go                                                                                                                                              │
│   └── fip_test.go                                                                                                                                         │
├── fixtures                                                                                                                                                │
│   └── fip                                                                                                                                                 │
│       ├── bad_req.json                                                                                                                                    │
│       └── history_response.json                                                                                                                           │
├── .github                                                                                                                                                 │
│   └── workflows                                                                                                                                           │
│       └── go_test.yml                                                                                                                                     │
├── main.go                                                                                                                                                 │
├── Makefile                                                                                                                                                │
├── playlist                                                                                                                                                │
│   └── playlist.go                                                                                                                                         │
├── README.md                                                                                                                                                                                                                                                                                          │
└── utils                                                                                                                                                   │
    ├── logger                                                                                                                                              │
    │   └── logger.go                                                                                                                                       │
    └── mocks                                                                                                                                               │
        └── server.go                                                                                                                                       │
                                                                                                                                                            │

View the run here

How do I make Github actions look for the package within the cloned dir as well?


回答1:


Make sure to run go mod init MODULE_NAME (if the project is outside GOROOT or GOPATH) or just simply go mod init (if the project is inside GOROOT or GOPATH). The command should be run on the root folder of your project. This would create a go.mod file that would enable go resolve your packages.



来源:https://stackoverflow.com/questions/62568643/github-actions-cant-find-package-within-repository

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!