Reputation: 630
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 │
│
How do I make Github actions look for the package within the cloned dir as well?
Upvotes: 1
Views: 1435
Reputation: 594
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.
Upvotes: 2