-
-
Notifications
You must be signed in to change notification settings - Fork 653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
‘no such file or directory’ running coverage #1456
Comments
heyo @plastikfan - the docs for cover profiles are here Ginkgo won’t make directories for you. “Standard” usage is to just generate the coverage files in the package directory itself. When you are running multiple suites Ginkgo will, by default, generate a single coverage file and put it at the location from which the specs were run and then delete the individual cover profiles (I believe…) if you wan to keep them separate you can use `—keep-separate-cover profiles. So, you should be able to run: ginkgo —json-report=ginkgo.report -coverpkg=./… -coverprofile=coverage.out -r if you don’t want the coverprofile in the root directory then you can midir -p ./reports
ginkgo —json-report=ginkgo.report -coverpkg=./… -coverprofile=coverage.out -output-dir=./reports -r this will put both |
Hi @onsi, I am still having major problems with this (particularly in ci) and I am wondering if there is actually an issue here that needs adressing. Compare these 2 approaches, the first uses the standard go test command to generate coverage, and the second uses ginkgo (github actions):
The first one works (ish, explained below), but the ginkgo version does not; the coverage file can't be found:
As you can see, both use the same path for the coverage.out file, but for some reason, ginkgo is not creating this file. Now the issue I have with the first version using the go test command, is that it is not producing very credible results, there are a lot of files being reported as having 0% coverage, which I know is incorrect. When I run ginkgo locally, I am getting better results. So I am trying to re-create what I have got running locally to run the same in ci with ginkgo, but ginkgo is not producing the .out file so that it can be published; the strange thing is that ginkgo appears to behave differently in ci than to a local run.
|
heyo, what happens if you do:
can you try that? |
sorry, that results in the exact same error! |
is this open source? i can look at the code + action? this should generate a single coverage.out in the same location as the json report file |
so... |
yeah sure, my repo is at: traverse and you'll see from the actions tab, the history of failed runs of me trying to fix the issue. |
thanks for the link. this: https://github.com/snivilised/traverse/actions/runs/10781150231/job/29898448042#step:10:1 is still looking for the coverage file under |
hey @onsi, thanks for trying to help me out on this. I dont think this is a ginkgo issue. Doing this type of thing in gh-actions is a real pain in the arse. I've tried to simplify this by defining a variable and only using the variable, but even getting this working is pain because there are so many restrictions on how to use a variable and different syntaxes depending on the context. If you have any workflows already defined that use ginkgo from a workflow, I'd be interested to see it. Thanks again for your help. The only other thing I would request is for there to be a fix for ginkgo to create the required intermediate directories instead of failing. That way, we wouldn't have to create them manually (eg mkdir -p ./internal/filtering/coverage as seen in my original post) and have some pain taken away. |
ok, I think there is in fact an issue with ginkgo afterall. I'm going close this issue and raise another as I have managed to reproduce the issue found in ci, locally, so it has nothing to do with ci. |
A common problem I come across when I run go tool cover, are coverage failures due to coverage location not being present. I have found that to resolve this issue, I need to create coverage directories first.
I am using Taskfile to run my tasks so here is an example coverage task:
This does fix my issue, but it is 'unnecessarily' verbose. Is there a way to configure coverage to create the coverage directory automatically if it doesn't exist, so that I can remove all the 'mkdir -p' that are currently required in my setup, to avoid 'no such file or directory' errors.
For larger projects, with many directories, I baulk at the prospect of having litter my task file with these mkdir commands, so I hope that I am indeed missing something that I have so far not found a solution for.
PS: an example output showing the error is:
I have also tried adding:
but this made no difference. What am I missing?
The text was updated successfully, but these errors were encountered: