#strange problem with go mod & go test

6 messages · Page 1 of 1 (latest)

undone forum
#

i am trying to merge a pr, and the ci test step keep failing with

go: updates to go.mod needed; to update it:                                                                                                                    
     go mod tidy

previous steps in our ci are successfully running go mod tidy, and they also make sure there are no un-committed changes afterwards.
the test step is basically running

for d in $(go list ./...); do
    go test -v $d
done

and it passes successfully on the main branch, on the PR branch on my machine, and also inside the same container image as the test step in our ci. i even executed all the previous steps in that container, in order. just to make sure there are no leftovers from previous steps that mess things up. but i couldn't reproduce the problem anywhere except for the build pipeline.

i tried to debug it, and added go mod tidy as well as git status inside the test loop. as expected - the tidy did nothing, and the status showed no file was changed. but the tests do pass this way.

i really don't understand this issue. has anyone encountered anything similar, and can help shed some light on the cause for this problem?

i will happily give any required details to anybody who is willing to help me.
thanks in advance.

tame widget
#

@undone forum try find -type f -name "go.mod" | while read p; do cd $(dirname $p); go mod tidy; cd -; done

#

btw you can do go test -v ./... this will be multithreaded and better cache and should be faster

undone forum
#

i only have "go.mod" at the root of my project, and go mod tidy does nothing when i run it.
i replaced the test loop with the one-liner. but our original test step is using -coverprofile=profile.out, and i think maybe actually running all tests in parallel will mess this up. but i'm giving it a go right now, just to see if it might actually get the tests passing.

undone forum
#

yeah - the tests miraculously pass now.
even adding the coverage is working fine (after fixing a small error I made in the process)

why would running the tests in a loop cause the go mod error? any idea?

regardless - thanks for the tip. I don't understand what went wrong, but for now my ci passes.

tame widget
#

-race ?