简体   繁体   中英

Github actions can't find package within repository

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM