Clean checkout removes coverage.out from previous step
Closed this issue · 7 comments
Hi, thanks for the tool!
I'm using the Go integration testing feature to calculate code coverage across a number of runs of a CLI tool, so I wanted to make use of the new "coverage-file" feature.
When I run my tests in the "Test" step, it creates a coverage.out
file in the directory. I have checked that it's there, by running an ls
command as per this sample workflow.
However, the first step in the composite workflow is to do a clean checkout of the code - thereby erasing the coverage.out
file!
To work around it, I've had to copy the coverage.out
file to the runner's temp directory and then reference it from there.
- name: Test
uses: joerdav/run-xc@1.0.0
with:
task: test-cover
- name: List files
run: ls -lah
- name: Copy coverage.out to temp
run: cp coverage.out $RUNNER_TEMP
- name: List temp
run: ls -lah $RUNNER_TEMP
- name: Update coverage report
uses: ncruces/go-coverage-report@21fa4b59396f242b81896a3cd212a463589b6742
with:
coverage-file: ${{ runner.temp }}/coverage.out
report: 'true'
chart: 'true'
reuse-go: 'true'
if: |
github.event_name == 'push'
continue-on-error: true
Skipping the checkout step optional if the coverage-file
variable is set would seem to be the way to solve that?
This is interesting. 🤔
We're gradually moving in the direction where this action does very little (except generate the badge, chart, HTML report). And that's good, IMO, no harm.
Problem is, and I'm not an expert on GitHub Actions, I want to express something that I don't really know how to express. And it's this: I need Go installed (I don't need or want to install it); I need the repo checked out (I don't need to check it out myself). And adding knobs for these seems wrong.
But maybe you're right. If I already have the coverage file, maybe I don't need to check out the repo at all.
Or maybe I never want to ever be checking out the repo or installing Go. I don't know, what do other Actions do? Because apparently, this always gets used as part of a larger pipeline that already does these things.
I don't think I'd check out code, install Go or run the tests etc. There are other actions for that, so I'd leave it to them.
That way, all of their action settings are accessible too.
I think keeping it as minimal as possible is the way with GitHub actions. They're time consuming to troubleshoot at the best of times.
But, I'm no expert either! :)
I think I'll do your fix, cause I don't see any obvious flaws. Then I need to read up more on Actions to decide, because that'd be a breaking change for people on v0
, so l need to make sure it's the right call.
Well, no pressure. I've got a workaround, and it's documented for others. It's slightly slower than it could be, since it checks the code out again, but it's all good!
Thanks for putting this together. I wanted to get a badge so I could try and get my open source project added to awesome-go, and this was much more attractive than signing up to another service that can read everything in my Github account.
Hopefully 6a57a39 fixes it.
Thanks for the feedback!
Yeah, not having to signup for yet another service is the entire point for me.
With proper support for supplying your own coverage.out
, I'd just like to sort out something for the multiple branch (make sure I only run this on main…) and/or PR workflow (post a comment in the PR?)
Hello @ncruces
I think that the action shall rather checkout the repo if no coverage file is supplied:
steps:
- name: Checkout code
uses: actions/checkout@v3
if: inputs.coverage-file == ''
otherwise the issue mentioned here still stands.
You're right. I'm now using this method in one of my repos just to make sure it's working.