-
Notifications
You must be signed in to change notification settings - Fork 658
Add demo test screnario #3191
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
Closed
Add demo test screnario #3191
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5ada1ae
Add demo test screnarion
bitbonk bc3204d
Add a reduced demo test
bitbonk e78e9d2
Add full release workflow demo with workaround
bitbonk b8192fb
Do some more cleanup
bitbonk a2b9231
Merge branch 'GitTools:main' into feature/demo-versioning-problem
bitbonk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
114 changes: 114 additions & 0 deletions
114
src/GitVersion.Core.Tests/IntegrationTests/VersioningDemoScenario.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
using GitTools.Testing; | ||
using GitVersion.Model.Configuration; | ||
using GitVersion.OutputVariables; | ||
using LibGit2Sharp; | ||
using NUnit.Framework; | ||
using Shouldly; | ||
|
||
namespace GitVersion.Core.Tests.IntegrationTests; | ||
|
||
public class VersioningDemoScenario | ||
{ | ||
[Test] | ||
public void ReleaseAndDevelopProblemDemo() | ||
{ | ||
var configuration = new Config | ||
{ | ||
// Settings the below NextVersion results in an exception | ||
// I wanted to set it to globally start with version 1 | ||
// Setting the version to 1.0 (which is not a valid semantic version) | ||
// works in GitVersion.yml but not here. | ||
|
||
// NextVersion = "1.0" | ||
}; | ||
|
||
// create main and develop branch, develop is two commits ahead of main | ||
using var fixture = new EmptyRepositoryFixture(); | ||
fixture.Repository.MakeACommit(); | ||
Commands.Checkout(fixture.Repository, fixture.Repository.CreateBranch("develop")); | ||
fixture.Repository.MakeACommit(); | ||
fixture.Repository.MakeACommit(); | ||
|
||
var previousVersion = GetSemVer(fixture.GetVersion(configuration)); | ||
|
||
// make a 3rd commit on develop | ||
fixture.Repository.MakeACommit(); | ||
|
||
var currentVersion = GetSemVer(fixture.GetVersion(configuration)); | ||
|
||
currentVersion.ShouldBeGreaterThan(previousVersion, | ||
"the semver should be incremented after a commit on develop"); | ||
|
||
// we are ready to prepare the 1.0.0 release, create and checkout release/1.0.0 | ||
Commands.Checkout(fixture.Repository, fixture.Repository.CreateBranch("release/1.0.0")); | ||
|
||
fixture.GetVersion(configuration).SemVer.ShouldBe("1.0.0-beta.1", | ||
"the first semver on release/1.0.0 should be beta1"); | ||
|
||
// make another commit on release/1.0.0 to prepare the actual beta1 release | ||
fixture.Repository.MakeACommit(); | ||
|
||
fixture.GetVersion(configuration).SemVer.ShouldBe("1.0.0-beta.1", | ||
"the semver on release/1.0.0 should still be be beta1"); | ||
|
||
Commands.Checkout(fixture.Repository, fixture.Repository.Branches["develop"]); | ||
|
||
previousVersion = currentVersion; | ||
currentVersion = GetSemVer(fixture.GetVersion(configuration)); | ||
|
||
currentVersion.ShouldBe(previousVersion, | ||
"the semver on develop should not have changed " + | ||
"even when release/1.0.0 has new commits due to beta 1 preparations"); | ||
|
||
// now some other team member makes changes on develop that may or may not end up in 1.0.0 | ||
fixture.Repository.MakeACommit(); | ||
fixture.Repository.MakeACommit(); | ||
|
||
previousVersion = currentVersion; | ||
currentVersion = GetSemVer(fixture.GetVersion(configuration)); | ||
|
||
currentVersion.ShouldBeGreaterThan(previousVersion, | ||
"the semver should be incremented after a even more commit on develop"); | ||
|
||
Commands.Checkout(fixture.Repository, fixture.Repository.Branches["release/1.0.0"]); | ||
|
||
// now we release the beta 1 | ||
fixture.Repository.ApplyTag("1.0.0-beta1"); | ||
|
||
fixture.GetVersion(configuration).SemVer.ShouldBe("1.0.0-beta.1", | ||
"the on release/1.0.0 should still be beta1 after the beta 1 tag"); | ||
|
||
// continue with more work on develop that may or may not end up in 1.0.0 | ||
Commands.Checkout(fixture.Repository, fixture.Repository.Branches["develop"]); | ||
fixture.Repository.MakeACommit(); | ||
fixture.Repository.MakeACommit(); | ||
|
||
previousVersion = currentVersion; | ||
currentVersion = GetSemVer(fixture.GetVersion(configuration)); | ||
|
||
currentVersion.ShouldBeGreaterThan(previousVersion, | ||
"the semver should be incremented after a even more commit on develop"); | ||
|
||
// now we decide that the three commits on develop should be part of the beta 2 release | ||
// se we merge it into release/1.0.0 with --no-ff because it is a protected branch | ||
Commands.Checkout(fixture.Repository, fixture.Repository.Branches["release/1.0.0"]); | ||
fixture.Repository.Merge( | ||
fixture.Repository.Branches["develop"], | ||
Generate.SignatureNow(), | ||
new MergeOptions {FastForwardStrategy = FastForwardStrategy.NoFastForward}); | ||
|
||
fixture.GetVersion(configuration).SemVer.ShouldBe("1.0.0-beta.2", | ||
"the next semver on release/1.0.0 should be beta2"); | ||
|
||
Commands.Checkout(fixture.Repository, fixture.Repository.Branches["develop"]); | ||
previousVersion = currentVersion; | ||
currentVersion = GetSemVer(fixture.GetVersion(configuration)); | ||
|
||
currentVersion.ShouldBeGreaterThanOrEqualTo(previousVersion, | ||
"the semver should be incremented (or unchanged) " + | ||
"after we merged develop into release/1.0.0"); | ||
|
||
static SemanticVersion GetSemVer(VersionVariables ver) | ||
=> SemanticVersion.Parse(ver.FullSemVer, null); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
To start with a
1.0.0
version, you just need to add agit tag
. You can do that in a test withfixture.Repository.MakeATaggedCommit("1.0.0")
.Uh oh!
There was an error while loading. Please reload this page.
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.
Making a tagged commit is a bit weird. When looking at the commit log, it looks like as if that commit was the 1.0.0 release.
That's what a version tag usually denotes (I would think)..
Also I was told, that using
NextVersion
in the config is a good approach here: #3123