codecov / codecov-exe

.exe report uploader for Codecov https://codecov.io
MIT License
25 stars 21 forks source link

Resolve VCS info through command parameters? #11

Closed jasoncavaliere closed 7 years ago

jasoncavaliere commented 7 years ago

Hi Hi!

Not sure if we're a unique case or not, but here's where we stand: we have a multi step build process where we run a full analysis separate from the unit test suite. This is the point where the codecov upload needs to happen, but we're not connected to Git at this point, it's all from packaged nuget files.

I have the following PS command in my psake scripts:

        Write-Host "Uploading to codecov"

        (New-Object System.Net.WebClient).DownloadFile("https://github.com/codecov/codecov-exe/releases/download/0.2.0-beta/codecov.exe", "$codecovLocation")
        $command = "cmd.exe /C BuildOutput\codecov.exe -f `"BuildOutput\coverage.xml`" -t `"<repo-token>`" -b `"$branch`" -b $env:BUILD_NUMBER"
        Invoke-Expression -Command:$command  |Out-File "$coverageLocation\pushcoverage.log" -Append

In teamcity we get the following error:


[21:51:56][Step 1/4] fatal: Not a git repository (or any of the parent directories): .git
[21:51:56][Step 1/4] fatal: Cannot change to 'rev-parse': No such file or directory
[21:51:56][Step 1/4] fatal: Not a git repository (or any of the parent directories): .git
[21:51:56][Step 1/4] fatal: Cannot change to 'rev-parse': No such file or directory
[21:51:56][Step 1/4] fatal: Not a git repository (or any of the parent directories): .git
[21:51:56][Step 1/4] fatal: Cannot change to 'config': No such file or directory
[21:51:56][Step 1/4] fatal: Not a git repository (or any of the parent directories): .git
[21:51:56][Step 1/4] fatal: Not a git repository (or any of the parent directories): .git
[21:51:57][Step 1/4] fatal: Cannot change to 'ls-tree': No such file or directory

Locally the upload works great - any ideas on how to work around this? Also, it looks like when we try to execute codecov.exe directly from powershell, it hangs on the build servers, hence the wrap around the execution with a call to command

Thanks!

larzw commented 7 years ago

Hi @jasoncavaliere

Thanks for the feedback! I'm in early development and never got a chance to test on TeamCity. Is it correctly detecting TeamCity? The output in the console should say something like "TeamCity CI detected."? Or, does it default to git and say "No CI provider detected, using Git."?

FYI for teamCity: see

Even if it does correctly detect TeamCity. I think it will still crash, because I use git to append a list containing the source code files to the top of the coverage report. @stevepeak any ideas on how to handle such a situation? Should I just skip appending the source files to the uploaded coverage report?

"Also, it looks like when we try to execute codecov.exe directly from powershell, it hangs on the build servers, hence the wrap around the execution with a call to command"

I'm not sure why... I'll have to setup a test on TeamCity to investigate. @stevepeak do you have a build server setup with TeamCity I could use?

jasoncavaliere commented 7 years ago

@larzw Thanks for the quick ping back!

looks like the environment variables set as parameters didn't work for us ( didn't know that was a requirement at all). I'm going to look and see if it's possible to run a full build on that step as an interim, it might make everyone's life easier.

I'd hoped we'd be able to pass every parameter necessary and you could pick up what you needed from github, but I guess that was my own desires and not what you guys had in mind? Or is that the end goal?

What we'd like to see is an .exe we can pull from Chocolatey that we could pass xml, vcs parameters, and a key, and let you guys figure out the rest.

larzw commented 7 years ago

@jasoncavaliere,

I've got a package in the works for Chocolatey. I like the idea of using github's api to bypass situations where git is not installed. Let see if @stevepeak has any suggestions as I don't think any of the other global uploaders do that, but it does not mean this one could not. FYI I'm working on a standalone .NET core version of this (It will support win7 x64 and above). I should have that merged in a few day.

Thanks!

jasoncavaliere commented 7 years ago

@larzw Nice! I've got the repo watched and I'll check in from time to time to see what's brewing.

stevepeak commented 7 years ago

Concerning the git ls-files

We do have a technique to gather the file list when git is missing. See here.

Concerning TeamCity environment

See here

Concerning passing parameters into the uploader

We do support this in most of the uploaders. Following this layout:

-C commit-sha
-B branch
-P pullid

more here

@larzw we standardize as many of these cli arguments as possible.


@jasoncavaliere Checkout http://docs.codecov.io/docs/flags they will help group your coverage reports. --flag unittests via here

larzw commented 7 years ago

Thanks @stevepeak and @jasoncavaliere!

@jasoncavaliere what version of powershell were you using on the build server?

larzw commented 7 years ago

Hi @jasoncavaliere,

Just wanted to give you an FYI. This issue should be resolved.

Now your above script would looking something like...

choco install codecov -pre
codecov -f "BuildOutput\coverage.xml" -t "<repo-token>" --branch "<branch>" --build "<build-number>"

There are a few more VCS parameters you may want/need to set (commit, slug...ect.): see. You may even want to use the flag --disable network

Since I've made some major changes I would recommend testing locally first. For example, run the uploader with the coverage report inside a folder that is not a git repository, since that is your use case??

Let me know if this does not work!

Thanks

jasoncavaliere commented 7 years ago

@larzw awesome! thank you, I'll give it a whirl when I'm in the office! And yes that's out use case !

jasoncavaliere commented 7 years ago

@larzw looks good!

We have another issue, something's up with your chocolatey setup, it's trying to reinstall every time when we check from our psake scripts. Going to create a new card for it in a few, once I can write it up.

Keep fighting the good fight!

larzw commented 7 years ago

@jasoncavaliere,

Glad this issue is fixed. This is my first time putting a choco package together so a new ticket explaining the issue would be appreciated.

Thanks!