-
Notifications
You must be signed in to change notification settings - Fork 652
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
Exclude LibGit2Sharp from ILRepack in NuGet.CommandLine #890
Conversation
@eatdrinksleepcode Thanks! Do you think it's possible to test the output from this somehow, so we know that the final merged and package |
That's actually a bit of a complicated question. We are a bit lucky in that regard on the Windows side: there is already a test of this package happening during the Windows build as a consequence of GitVersion dogfooding itself. If you look at the AppVeyor build for this PR: Line 38 - solution is built If I run that same process locally after breaking the package (by commenting out line 154 of GitVersionExe.csproj so that the LibGit2Sharp files are not copied into the package), the build correctly fails; when I fix the package, it succeeds. So that confirms that the package works correctly on Windows. Testing as part of the Linux build is unfortunately not possible right now. Package building currently does not occur during the Linux build at all; I don't know why it was disabled originally, but when I try to re-enable it, ILRepack fails with a NullReferenceException. I have debugged into that and found that the model that Mono.Cecil is generating for one of the methods in GitVersionCore.dll has a null operand for a brtrue.s instruction, which should not be possible. The IL for the method in question is correct, and monodis represents it correctly when disassembling it. So there seems to be a bug in Mono.Cecil, but why it affects this particular instruction I don't know yet. I am going to look further into that now that I have this PR up :) In the meantime, I have manually validated the new package by installing it from the Windows build into a repository on OSX and confirming that it works correctly (and also that it doesn't work when I intentionally break it). Until we enable package building on Linux, I think that's the best we can do. |
@eatdrinksleepcode I would love to await the work you do in #891 and have that merged as an updated Fody and working Linux build first, so we can get a test in this PR to ensure this functionality never regresses on Unix/Linux. |
I added a commit which fixes #891 (by updating the Fody.Caseless version), builds packages on Linux, and dogfoods the CommandLine package during the Travis build (just like the AppVeyor build). However, that dogfooding is failing during the Travis build (see below) for reasons that I don't understand and cannot reproduce locally. Can someone who knows more about the implementation details of GitVersion take a look? |
@eatdrinksleepcode Awesome work! 👍 😄 I've run the test locally and don't see anything wrong there either, so it's just weird that Travis is failing the build. Do you think you can add a commit or do something to trigger a new build, so we can see if the error was temporal? If it's not, I'd rather not merge before we figure out why Travis is failing, since that would make all builds fail going forward. |
5fcec7e
to
8d19c7f
Compare
I triggered a new Travis build twice, once by force pushing a no-edit amend, and again by rebasing on master. Both Travis runs failed before starting the actual build while installing Mono with an error about gpg keys. Looks like something is wrong with the Travis setup. I will try again later today. |
8d19c7f
to
c8b51dd
Compare
The Mono/gpg problem didn't recur, but now the previous error is happening again when running GitVersion within the build. |
@eatdrinksleepcode Ok, looks like this is what is failing the build: mono ./build/NuGetCommandLineBuild/tools/GitVersion.exe -l -console -output buildserver -updateAssemblyInfo It doesn't seem like |
070e99b
to
967c341
Compare
Adding some logging has revealed multiple problems. First, Travis performs a shallow clone, which is why GitVersion can't find some of the objects it is looking for (possibly something GitVersion should try to detect). Unfortunately there is no way to tell Travis NOT to perform a shallow clone; but I was able to perform a The next problem is that GitVersion is detecting a detached HEAD on Travis, whereas it detects the PR branch in AppVeyor. I can reproduce this behavior on my own machine by following the same sequence of Git commands from the build log. The strange thing is that it also reproduces locally when following the sequence from the AppVeyor log. So at this point I am not sure why AppVeyor works, or what to do to the Travis build to make it work also. |
With AppVeyor (and teamcity) the branch name is available through a variable. GitVersion has a feature called dynamic repositories, it will checkout the git repo into a temp folder on the machine, it means that GitVersion doesn't need a git folder which the build server has created. We may have to use that on travis? |
That is a potential alternative to running
So is the best option to implement Travis as a supported CI server in GitVersion? |
I'm a little confused because the TeamCity implementation of BuildServerBase overrides GetCurrentBranch to get the current branch from the "Git_Branch" environment variable. But AppVeyor doesn't override GetCurrentBranch; so how is GitVersion getting the branch from an environment variable in AppVeyor? |
This sounds like the same reason that the Cake Build PR that I created isn't building correctly on Travis. |
Yes, I believe so.
Good question. @JakeGinnivan, do you know?
They might be related. I haven't looked into why the Cake build PR is failing, but it might be worth rebasing once this PR is merged to see if that helps. |
Actually looks like it isn't :P |
Replace slash with dash in the command line argument switches for gitversion.exe, so it is more Unix friendly. It will still fail exeucting on OS X due to GitTools/GitVersion#890, but once that has been fixed, this should ensure that GitVersion executes successfully on OS X.
@eatdrinksleepcode The reason stuff works without the AppVeyor build server provider without it returning the branch name from an environment variable, is that GitVersion then defaults to its own heuristics by querying the remotes. This seems to work on AppVeyor, but not on Travis. So if we get a build server provider working for Travis, that should fix the problem, given that Travis actually expose the name of the branch it is building (something I have no idea whether it is or isn't). Would you like to tackle the Travis build server provider in this or another PR? |
Here is a little info I found regarding Travis and getting the currently building git branch: http://graysonkoonce.com/getting-the-current-branch-name-during-a-pull-request-in-travis-ci/ Unfortunately, it doesn't seem as straight-forward as one would hope. There is a Travis feature request that would simplify the process but it hasn't been addressed in 2 years: travis-ci/travis-ci#5731 |
I think it has to be done in this PR, because there is no other way to test it. I think I can get that done this weekend.
|
@eatdrinksleepcode Brilliant, thanks! |
Replace slash with dash in the command line argument switches for gitversion.exe, so it is more Unix friendly. It will still fail exeucting on OS X due to GitTools/GitVersion#890, but once that has been fixed, this should ensure that GitVersion executes successfully on OS X.
Hmmm... Travis build outputs
whereas AppVeyor ouputs
Although the raw content of HEAD and FETCH_HEAD are identical, the buildversion log for
I'm not sure to understand where does the content of the There's indeed something weird... somewhere. @eatdrinksleepcode Would you be able to create the tiniest possible repro of this? Would this portion of code actually put under the light something incosistent at the libgit2(sharp) level, I'm pretty sure @ethomson and @carlosmn would be happy to hear about it. |
@eatdrinksleepcode Dammit! Cross-posting... Happy you eventually found the issue. Congrats on the hunt! |
@eatdrinksleepcode: 🎊 Fantastic work! 🎉
You never know. I have a theory that programming while half asleep lets problems enter the subconsciousness easier, which is where they need to go to be solved anyway. 😄
Indeed! Excellent!
Include a rebase and this sounds like a cunning plan! Great work! 👍 |
…rp.dll.config in NuGet.CommandLine
Have stripped everything back down to just the desired changes and rebased with master. I think this is ready for review. |
@@ -7,6 +7,7 @@ os: | |||
- linux | |||
- osx | |||
before_install: # We need to download nuget.exe due to: https://github.com/travis-ci/travis-ci/issues/5932 | |||
- git fetch --unshallow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this required? If so, can you please explain why with a comment?
@eatdrinksleepcode I think this looks like amazeballs! But given the amplitude of the change, I'd love if @pascalberger, @gep13 or @JakeGinnivan could have a look too. Big 👍 and ❤️ for the work you've put into this! |
Added some comments and fixed up some minor formatting issues. |
@eatdrinksleepcode Thanks for your work! There still seems to be some indentation issues in several files (eg. Since you also added support for Travis can you add documentation for that (here and in a new markdown file containing Travis specific documentation). Beside that and some minor issues for which I added comments it looks good to me. |
@@ -4,9 +4,11 @@ | |||
|
|||
public class TeamCity : BuildServerBase | |||
{ | |||
public override bool CanApplyToCurrentContext() | |||
public const string EnvironmentVariableName = "TEAMCITY_VERSION"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor issue: Wouldn't a static readonly variable fit better? For cases where this value is used in another assembly and the core assembly is replaced (But most probably this won't happen anyway :)
Gonna because I want to rebase the Cake script on this. |
We can fix the tabs vs spaces in master |
Fixes #854
This is a short-term fix for NuGet.CommandLine on Mono. It excludes LibGit2Sharp from ILRepack, and copies LibGit2Sharp (and its config file) into the package instead. Only NuGet.CommandLine is affected; changing the other packages build by GitVersionExe might (or might not) make sense, but that decision is being deferred to get this change in, in order to unblock other work.