Skip to content

NextVersion.txt and GitVersionConfig.yaml support for dynamic repositories #352

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

Closed
wants to merge 7 commits into from
Closed

NextVersion.txt and GitVersionConfig.yaml support for dynamic repositories #352

wants to merge 7 commits into from

Conversation

GeertvanHorrik
Copy link
Contributor

See #351

@SimonCropp
Copy link
Contributor

obligatory "can this be tested?"...

@GeertvanHorrik
Copy link
Contributor Author

I knew that question would come. As always, time and resources are limited, but I understand.

@SimonCropp
Copy link
Contributor

:) think we r on the same page. your call. is this worth the effort to test or not?

@GeertvanHorrik
Copy link
Contributor Author

Not really worth the effort, but will add them anyways. @JakeGinnivan already put in effort to make the repositories offline. I can add a few files to test it.

@SimonCropp
Copy link
Contributor

@GeertvanHorrik thanks

@GeertvanHorrik
Copy link
Contributor Author

Unit tests added. I had to improve some generic methods as well to support creation of dynamic files in fixtures. I couldn't run because I get a invalid read/write on memory access thing, I assume this has to do with the latest update to libgit2sharp, but maybe you can double check / verify?

@SimonCropp
Copy link
Contributor

can u rebase?

@SimonCropp
Copy link
Contributor

i know how much u love to use git ;)

@GeertvanHorrik
Copy link
Contributor Author

Not sure how I should do that once I have committed. I hope I don't have to revert commits?

@SimonCropp
Copy link
Contributor

i can manually merge if it is too much hassle. just tell me if u dont have time

@GeertvanHorrik
Copy link
Contributor Author

I am searching for info, but cannot find the right stuff. I think I should have chose rebase instead of merge when I pushed, but once it is already pushed I don't know how to rebase. Happy to do it, just need some guidance (link?).

@GeertvanHorrik
Copy link
Contributor Author

$ git rebase pr/NextVersionForDynamicRepositories
Current branch pr/NextVersionForDynamicRepositories is up to date.

@GeertvanHorrik
Copy link
Contributor Author

I have rebased on my master branch now. Is that better?

@SimonCropp
Copy link
Contributor

github says still no automerge
prob best ref is https://github.com/edx/edx-platform/wiki/How-to-Rebase-a-Pull-Request

…into pr/NextVersionForDynamicRepositories

Conflicts:
	GitVersionExe.Tests/GitPreparerTests.cs
@GeertvanHorrik
Copy link
Contributor Author

Ah, just had to do a "git pull upstream master" :-)

@SimonCropp
Copy link
Contributor

ok the merge is OK but the build server says no. is it building on your machine?

@GeertvanHorrik
Copy link
Contributor Author

What does the build serve say now?

@SimonCropp
Copy link
Contributor

Test(s) failed. LibGit2Sharp.EmptyCommitException : No changes; nothing to commit.
   at LibGit2Sharp.Repository.Commit(String message, Signature author, Signature committer, CommitOptions options)
   at LibGit2Sharp.RepositoryExtensions.Commit(IRepository repository, String message, Signature author, Signature committer)
   at GitTestExtensions.CreateFileAndCommit(IRepository repository, String relativeFileName, DateTimeOffset dateTimeOffset) in c:\BuildAgent\work\68ea6bfb44e5afb\GitVersionCore.Tests\Helpers\GitTestExtensions.cs:line 55
   at GitPreparerTests.WorksCorrectlyWithRemoteRepository(String branchName, String expectedBranchName, Boolean checkConfig) in c:\BuildAgent\work\68ea6bfb44e5afb\GitVersionExe.Tests\GitPreparerTests.cs:line 45
------- Stderr: -------
Created git repository at 'C:\BuildAgent\work\68ea6bfb44e5afb\GitVersionExe.Tests\bin\Release\TestRepositories\970a4ec4-4458-498e-9976-45fb6ca97e2b'

@SimonCropp
Copy link
Contributor

Test(s) failed. LibGit2Sharp.EmptyCommitException : No changes; nothing to commit.
   at LibGit2Sharp.Repository.Commit(String message, Signature author, Signature committer, CommitOptions options)
   at LibGit2Sharp.RepositoryExtensions.Commit(IRepository repository, String message, Signature author, Signature committer)
   at GitTestExtensions.CreateFileAndCommit(IRepository repository, String relativeFileName, DateTimeOffset dateTimeOffset) in c:\BuildAgent\work\68ea6bfb44e5afb\GitVersionCore.Tests\Helpers\GitTestExtensions.cs:line 55
   at GitPreparerTests.WorksCorrectlyWithRemoteRepository(String branchName, String expectedBranchName, Boolean checkConfig) in c:\BuildAgent\work\68ea6bfb44e5afb\GitVersionExe.Tests\GitPreparerTests.cs:line 45
------- Stderr: -------
Created git repository at 'C:\BuildAgent\work\68ea6bfb44e5afb\GitVersionExe.Tests\bin\Release\TestRepositories\19d0296a-8071-4a50-96c3-b1b1923c6764'

@GeertvanHorrik
Copy link
Contributor Author

Somehow I either get this:

  1. System.AccessViolationException : Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

-or-

  1. No changes; nothing to commit.

Somehow something is screwed on my system. I tried deleting all bin/obj, but doesn't seem to help either. Continuing my quest...

@SimonCropp
Copy link
Contributor

@GeertvanHorrik perhaps something to do with mismatching libgit files? although not sure how that could happen?

@GeertvanHorrik
Copy link
Contributor Author

I deleted packages/bin/obj several times:

Checking out files that might be needed later in dynamic repository
  Trying to check out 'NextVersion.txt'
Checking out files that might be needed later in dynamic repository
  Trying to check out 'GitVersionConfig.yaml'
System.AccessViolationException : Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

@SimonCropp
Copy link
Contributor

do u have a stack trace?

@GeertvanHorrik
Copy link
Contributor Author

   at NUnit.Framework.Assert.IncrementAssertCount()
   at NUnit.Framework.Assert.That(Object actual, IResolveConstraint expression, String message, Object[] args)
   at GitPreparerTests.WorksCorrectlyWithRemoteRepository(String branchName, String expectedBranchName, Boolean checkConfig) in GitPreparerTests.cs: line 62

@GeertvanHorrik
Copy link
Contributor Author

btw. I am using x86 2.6.4 NUnit runner in R#.

@GeertvanHorrik
Copy link
Contributor Author

I had to explicitly set the platform of R# unit test runner to x86.

@GeertvanHorrik
Copy link
Contributor Author

The "LibGit2Sharp.EmptyCommitException : No changes; nothing to commit." is very random. Sometimes it works, sometimes it doesn't. Alsmost looks like async code that is not being awaited. Need to investigate the repository fixture.

@GeertvanHorrik
Copy link
Contributor Author

Adding this to the fixture solves it:

        // GHK: 2015-01-18: I know it's very ugly, but somehow we need to retry here otherwise "there is nothing to commit"
        int retryCount = 3;
        while (retryCount > 0)
        {
            try
            {
                repository.Stage(randomFile);

                return repository.Commit(string.Format("Test Commit for file '{0}'", relativeFileName),
                    Constants.Signature(dateTimeOffset), Constants.Signature(dateTimeOffset));
            }
            catch (EmptyCommitException)
            {
                if (retryCount <= 0)
                {
                    throw;
                }

                Thread.Sleep(100);
            }

            retryCount--;
        }

I don't want to know what's happening under the hood ;-)

@SimonCropp
Copy link
Contributor

@GeertvanHorrik i tried explicit 2.6.3 and x86 and could not repro. if u switch back to to 2.6.3 does it still happen?

@SimonCropp
Copy link
Contributor

@nulltoken can u weigh in here? re LibGit2Sharp.EmptyCommitException : No changes; nothing to commit. ?

@GeertvanHorrik
Copy link
Contributor Author

"number of inspection errors is too large: 1 "

What's that?

@SimonCropp
Copy link
Contributor

@GeertvanHorrik resharper inspections

@JakeGinnivan
Copy link
Contributor

@GeertvanHorrik runs r# inspections on the build server

GitTestExtensions.cs (1)
56: Use implicitly typed local variable declaration

Is the error

@GeertvanHorrik
Copy link
Contributor Author

Cool, thanks. How do you run R# on the build server. Is it a TC thing or separate executable?

File.WriteAllText(randomFile, Guid.NewGuid().ToString());

// GHK: 2015-01-18: I know it's very ugly, but somehow we need to retry here otherwise "there is nothing to commit"
int retryCount = 3;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make this a var

@SimonCropp
Copy link
Contributor

it is built into TC. but there is a command line

File.WriteAllText(randomFile, Guid.NewGuid().ToString());

// GHK: 2015-01-18: I know it's very ugly, but somehow we need to retry here otherwise "there is nothing to commit"
var retryCount = 3;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JakeGinnivan @nulltoken thoughts on how to avoid doing this retry?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed config based versioning branch to increment the commit time for each commit - 14487a0#diff-c7ff189f687fa58758611ef26120e6dcR8

Not sure if this would fix the issue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SimonCropp @JakeGinnivan EmptyCommitException is raised when the tree about to be committed matches the tree from the parent commit. This means that no modification has been detected. My guess is that is related to a known issue in libgit2 (see libgit2/libgit2sharp#688).

Meanwhile, in order to work around this, just make sure that your files are of random length

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already implemented random content, but we can also add random length as well. Doesn't libgit see a difference when the file contents are different but equal length?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GeertvanHorrik Time is also a variable of the equation. See libgit2/libgit2sharp#688 (comment)

@gep13
Copy link
Member

gep13 commented Jan 18, 2015

@GeertvanHorrik You can find it here: https://chocolatey.org/packages/resharper-clt choco install resharper-clt we use it as part of the build process for ChocolateyGUI since we are using AppVeyor and not TeamCity. The version that is installed with TeamCity is slightly different to the command line version, but I have found the results to be very similar in what they turn up. The command line version is driven by a config file that specifies files to exclude etc.

@GeertvanHorrik
Copy link
Contributor Author

Thanks for all the info, will incorporate that into all my builds tomorrow as well.

@gep13
Copy link
Member

gep13 commented Jan 18, 2015

If you are interested, the ChocolateyGUI build process for both InspectCode and DupFinder starts here:

https://github.com/chocolatey/ChocolateyGUI/blob/develop/BuildScripts/default.ps1#L395

I create a very basic HTML file from the generated XML file (this is really what TeamCity does for you automagically) to make deciphering the output a bit easier. Feel free to borrow and extend them if you want.

@JakeGinnivan
Copy link
Contributor

Have manually merged into #364

Also fixed the retry hack by appending a changing number of .'s after the guid contents

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants