Use golang image to run tests step#219
Conversation
8ba4670 to
4c6489c
Compare
4c6489c to
4d327ac
Compare
| env: | ||
| KUBEBUILDER_ASSETS: ${{ github.workspace }}/kubebuilder/bin | ||
| run: | | ||
| apk add --no-cache docker build-base git |
There was a problem hiding this comment.
I don't think we need docker to run unit tests
There was a problem hiding this comment.
Also Git is included in the go image
f7c0010 to
d7a3a47
Compare
|
Seems we have a problem. The issue I stumbled upon earlier when testing with the single container seems to be reproducible. I'm gonna see if I can reproduce this locally with the alpine image as well. EDIT: Seems this is caused by the fact that the container runs as root so tests that check for permissions will always fail because... root :) |
| --volume ~/go/pkg/mod:/root/go/pkg/mod \ | ||
| --env KUBEBUILDER_ASSETS=$KUBEBUILDER_ASSETS \ | ||
| --workdir $(pwd) golang:1.15-alpine /bin/sh -c \ | ||
| "apk add --no-cache build-base git ; make test" |
There was a problem hiding this comment.
I actually had to add git cause it was complaining that the git binary could not be located.
| "apk add --no-cache build-base git ; make test" | ||
| env: | ||
| KUBEBUILDER_ASSETS: ${{ github.workspace }}/kubebuilder/bin | ||
| - name: Check if working tree is dirty |
There was a problem hiding this comment.
It is not necessary to run this in the container as we're mirror mounting the workdir into the container.
3b67516 to
4df1777
Compare
|
Finally, a working version! 🎉 I resorted to creating a dedicated GitHub Action as the most elegant solution. |
4df1777 to
ee6b782
Compare
|
You can remove the go mod cache action as it's useless now, an action container doesn't have access to the host go modules dir. |
|
Ah it seems that you can mount host dirs https://stackoverflow.com/questions/58997638/docker-container-volume-does-not-get-mounted-in-github-actions |
|
Yes, if you expand the build step in the log you'll see exactly which directories are mounted inside the container from the host. The home dir is one of them. |
|
@relu if you look at the |
|
I'll look into it, I didn't realize it was not using the cache. |
80d3833 to
f5a722a
Compare
|
Ok, so I was wrong, it does not mount the actual home dir in the container but rather this location: EDIT: Should be good now. I actually had to force set the |
f5a722a to
489d0a2
Compare
Signed-off-by: Aurel Canciu <[email protected]>
489d0a2 to
27420c0
Compare
| FROM golang:1.15-alpine | ||
|
|
||
| # Add any build or testing essential system packages | ||
| RUN apk add --no-cache build-base git |
There was a problem hiding this comment.
@phillebaba once this gets merged, you'll be able to add the libgit2-dev dep here for #213.
No description provided.