Skip to content

Commit 51b0543

Browse files
authored
Merge pull request #989 from asbjornu/feature/mode-documentation-cleanup
Mode and configuration documentation cleanup
2 parents 330a5c1 + 1e0ccfb commit 51b0543

File tree

8 files changed

+415
-140
lines changed

8 files changed

+415
-140
lines changed

docs/configuration.md

Lines changed: 215 additions & 63 deletions
Large diffs are not rendered by default.

docs/reference/continuous-delivery.md

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,58 @@
11
# Continuous Delivery
2-
Continuous delivery is the practice of having a deployment pipeline. Each stage of the pipeline gets the code going through the pipeline closer to production.
2+
Continuous Delivery is the practice of having a deployment pipeline and is the
3+
default mode in GitVersion. Each stage of the pipeline gets the code going
4+
through the pipeline closer to production.
35

4-
The topic itself is rather large, here we will just focus on the building and creation of *releasable* artifacts. This is only a part of continuous delivery as a whole, with the hard part being the ability to measure the impacts of what you have deployed into production.
6+
The topic itself is rather large, here we will just focus on the building and
7+
creation of *releasable* artifacts. This is only a part of continuous delivery
8+
as a whole, with the hard part being the ability to measure the impacts of what
9+
you have deployed into production.
510

611
In essence continuous delivery means:
712

813
- Your code is automatically built and tested
9-
- If any of the automated tests fail, the teams #1 priority is to fix the build
14+
- If any of the automated tests fail, the team's #1 priority is to fix the
15+
build
1016
- If the build is green, the application can be deployed at any time
1117
- Ideally the business should make that decision
1218
- The same artifacts which were built and tested should be deployed
1319
- That means no rebuilding everything when you are deploying
1420

15-
Continuous delivery does not work well with GitFlow. The reason is that you are required to *merge* to master to do a release, triggering a rebuild and a new set of artifacts to go through your pipeline. Depending on how long your pipeline is, this could be a while.
16-
17-
GitHubFlow is a better fit for Continuous delivery, the [mainline development](mainline-development.md) model means that every merged feature branch will be built as a *stable* version and if the build/builds go green then you are free to deploy to production at any time.
18-
19-
## How continuous delivery affects GitVersion
20-
The thing about continuous delivery is that there will be *multiple* candidates to deploy to production and it is a human choice to deploy. This means that GitVersion will build **the same semantic version** until that version is deployed.
21-
22-
GitVersion assumes Continuous Delivery by default in it's [configuration](../configuration.md), if you want to do [continuous deployment](continuous-deployment.md) then just change the configuration setting.
21+
Continuous delivery does not work well with GitFlow. The reason is that you are
22+
required to *merge* to master to do a release, triggering a rebuild and a new
23+
set of artifacts to go through your pipeline. Depending on how long your
24+
pipeline is, this could be a while.
25+
26+
GitHubFlow is a better fit for Continuous delivery, the
27+
[mainline development](mainline-development.md) model means that every merged
28+
feature branch will be built as a *stable* version and if the build/builds go
29+
green then you are free to deploy to production at any time.
30+
31+
## Usage
32+
By default, GitVersion is set up to do Continuous Delivery on all branches but
33+
`develop`, which is set up with [Continuous Deployment](continuous-deployment.md).
34+
To change the mode to Continuous Delivery, change your
35+
[configuration](../configuration.md) to:
36+
37+
```yaml
38+
mode: ContinuousDelivery
39+
```
40+
41+
## How Continuous Delivery affects GitVersion
42+
The thing about continuous delivery is that there will be *multiple* candidates
43+
to deploy to production and it is a human choice to deploy. This means that
44+
GitVersion will build **the same semantic version** until that version is
45+
deployed. For instance:
46+
47+
- 1.1.0+5
48+
- 1.1.0+6
49+
- 1.1.0+7 <-- This is the artifact we release, tag the commit which created
50+
this version
51+
- 1.1.1+0
52+
53+
Tags are required in this mode to communicate when the release is done as it's
54+
an external manual process.
2355
2456
## Resources
2557
- [Continuous Delivery on Uncyclopedia](https://en.wikipedia.org/wiki/Continuous_delivery)
26-
- [Continuous Delivery, the book](http://www.amazon.com/Continuous-Delivery-Deployment-Automation-Addison-Wesley/dp/0321601912)
58+
- [Continuous Delivery, the book](http://www.amazon.com/Continuous-Delivery-Deployment-Automation-Addison-Wesley/dp/0321601912)
Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,33 @@
11
# Continuous Deployment
2-
Continuous deployment is the process of checking into master, running all the tests and if everything goes green it is automatically pushed to production.
2+
Continuous Deployment is the process of checking into master, running all the
3+
tests and if everything goes green it is automatically pushed to production.
34

4-
By default GitVersion is *not* setup to do this. The good news is in v3 of GitVersion this behavior is configurable!
5+
A good case for Continuous Deployment is when using Octopus deploy, as you
6+
cannot publish the same version of a package into the same feed.
57

6-
The default behavior for v3 and how v1 & 2 worked was that the version only incremented after a tag, which signified a release. In v3 you can simply switch the default mode in the [configuration](../configuration.md) from `continuous-delivery` to `continuous-deployment` and the version will then increment each commit, giving you the features of GitVersion with continuous deployment.
8+
For this mode we follow the logic in [this blog post by Xavier Decoster][blog]
9+
on the issues of incrementing automatically.
10+
11+
As such we force a pre-release tag on all branches, this is fine for
12+
applications but can cause problems for libraries. As such this mode may or may
13+
not work for you, which leads us into a new mode in v4 of GitVersion:
14+
[Mainline Development](mainline-development.md).
15+
16+
### Usage
17+
By default GitVersion is set up to do Continuous Deployment versioning on the
18+
`develop` branch, but for all other branches,
19+
[Continuous Delivery](continuous-delivery.md) is the default mode. From version
20+
3 of GitVersion this behavior is [configurable](../configuration.md).
21+
22+
The default behavior for v3 and how v1 & 2 worked was that the version only
23+
incremented after a tag, which signified a release. In v3 you can simply switch
24+
the default mode in the [configuration](../configuration.md) from
25+
`ContinuousDelivery` to `ContinuousDeployment` and the version will then
26+
increment each commit, giving you the features of GitVersion with continuous
27+
deployment:
28+
29+
```yaml
30+
mode: ContinuousDeployment
31+
```
32+
33+
[blog]: http://www.xavierdecoster.com/semantic-versioning-auto-incremented-nuget-package-versions
Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,57 @@
11
# Mainline development
2-
Mainline development is enabled when using [GitHubFlow](../git-branching-strategies/githubflow.md) or any other strategy where you develop on `master`. The main rule of mainline development is that **master is always in a state that it could be deployed to production**. This means that pull requests should not be merged until they are ready to go out.
2+
Mainline Development is enabled when using
3+
[GitHubFlow](../git-branching-strategies/githubflow.md) or any other strategy
4+
where you develop on `master`. The main rule of mainline development is that
5+
**master is always in a state that it could be deployed to production**. This
6+
means that pull requests should not be merged until they are ready to go out.
37

4-
To properly achieve mainline development you need confidence in your test suite as if it goes green against a PR then you are confident that you can merge and release that pull request. Another property of mainline development is normally that you fix going forward, not revert. When an issue is discovered with a release, add a test or some sort of check to make sure it won't happen again, fix the issue, then do a release with the fix.
8+
To properly achieve mainline development you need confidence in your test suite
9+
as if it goes green against a PR then you are confident that you can merge and
10+
release that pull request. Another property of mainline development is normally
11+
that you fix going forward, not revert. When an issue is discovered with a
12+
release, add a test or some sort of check to make sure it won't happen again,
13+
fix the issue, then do a release with the fix.
514

6-
Like all things, it is an approach and will work for some people and not for others. GitVersion is unique in the fact that it works very well with mainline development and the version numbers it generates are *predictive* and indicate what the next version to be released is. Most other approaches require bumping the version number before the release which means that the version being built and the version number which will be deployed are often different.
15+
Like all things, it is an approach and will work for some people and not for
16+
others. GitVersion is unique in the fact that it works very well with mainline
17+
development and the version numbers it generates are *predictive* and indicate
18+
what the next version to be released is. Most other approaches require bumping
19+
the version number before the release which means that the version being built
20+
and the version number which will be deployed are often different.
21+
22+
This mode is great if you do not want to tag each release because you simply
23+
deploy every commit to master. The behaviour of this mode is as follows:
24+
25+
1. Calclate a base version (likely a tag in this mode)
26+
2. Walk all commits from the base version commit
27+
3. When a merge commit is found:
28+
- Calculate increments for each direct commit on master
29+
- Calculate the increment for the branch
30+
4. Calculate increments for each remaining direct commit
31+
5. For feature branches then calculate increment for the commits so far on your
32+
feature branch.
33+
34+
If you *do not want* GitVersion to treat a commit or a pull request as a release
35+
and increment the version you can use `+semver: none` or `+semver: skip` in a
36+
commit message to skip incrementing for that commit.
37+
38+
Here is an example of what mainline development looks like:
39+
40+
![Mainline mode](../img/mainline-mode.png)
41+
42+
**WARNING:** This approach can slow down over time, we recommend to tag
43+
intermitently (maybe for minor or major releases) because then GitVersion
44+
will start the version calculation from that point. Much like a snapshot in an
45+
event sourced system. We will probably add in warnings to tag when things are
46+
slowing down.
47+
48+
## Usage
49+
By default GitVersion is set up to do [Continuous Delivery](continuous-delivery.md)
50+
versioning on all branches but `develop` (which does
51+
[Continuous Deployment](continuous-deployment.md) by default). To change the
52+
[versioning mode](versioning-mode.md) to Mainline Development, just
53+
change the [configuration](../configuration.md) as such:
54+
55+
```yaml
56+
mode: Mainline
57+
```

docs/reference/versioning-mode.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Versioning modes
2+
GitVersion has multiple modes to fit different different ways of working.
3+
4+
## Continuous Delivery
5+
[Continuous Delivery](/reference/continuous-delivery) is the default mode. In
6+
this mode, GitVersion calculates the next version and will use that until that
7+
is released.
8+
9+
## Continuous Deployment
10+
Sometimes you just want the version to keep changing and deploy continuously.
11+
In this case, [Continuous Deployment](/reference/continuous-deployment) is a
12+
good mode to operate GitVersion by.
13+
14+
## Mainline Development
15+
[Mainline Development](/reference/mainline-development) works more like the
16+
[Continuous Delivery](/reference/continuous-delivery), except that it tells
17+
GitVersion to *infer* releases from merges and commits to `master`.

docs/versioning-mode.md

Lines changed: 0 additions & 42 deletions
This file was deleted.

mkdocs.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ repo_url: https://github.com/GitTools/GitVersion
44

55
pages:
66
- Home: index.md
7-
- Usage:
7+
- Usage:
88
- Usage: usage/usage.md
99
- Command Line: usage/command-line.md
1010
- MSBuild Task: usage/msbuild-task.md
1111
- NuGet Library: usage/nuget-library.md
1212
- Gem: usage/gem.md
1313
- Configuration: configuration.md
14-
- Build Server Support:
14+
- Build Server Support:
1515
- Introduction: build-server-support/build-server-support.md
1616
- Build Servers:
1717
- AppVeyor: build-server-support/build-server/appveyor.md
@@ -45,12 +45,15 @@ pages:
4545
- GitHubFlow Examples: git-branching-strategies/githubflow-examples.md
4646
- Converting to GitFlow: git-branching-strategies/converting-to-gitflow.md
4747
- Creating/Updating examples: git-branching-strategies/creating-updating-examples.md
48+
- Complete: git-branching-strategies/gitflow-examples_complete.md
4849

4950
- Reference:
5051
- Intro to SemVer: reference/intro-to-semver.md
5152
- Git setup: reference/git-setup.md
5253
- Feature branches: reference/feature-branches.md
5354
- Pull requests: reference/pull-requests.md
54-
- Mainline development: reference/mainline-development.md
55-
- Continous delivery: reference/continuous-delivery.md
56-
- Continuous deployment: reference/continuous-deployment.md
55+
- Versioning modes:
56+
- Versioning modes: reference/versioning-mode.md
57+
- Mainline development: reference/mainline-development.md
58+
- Continous delivery: reference/continuous-delivery.md
59+
- Continuous deployment: reference/continuous-deployment.md

src/GitVersionCore.Tests/DocumentationTests.cs

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414
[TestFixture]
1515
public class DocumentationTests
1616
{
17+
private DirectoryInfo docsDirectory;
18+
19+
[OneTimeSetUp]
20+
public void OneTimeSetUp()
21+
{
22+
docsDirectory = GetDocsDirectory();
23+
}
24+
1725
[Test]
1826
public void ConfigurationDocumentationIsUpToDate()
1927
{
@@ -32,7 +40,7 @@ public void ConfigurationDocumentationIsUpToDate()
3240

3341
foreach (var configProperty in configProperties)
3442
{
35-
var formattedConfigProperty = string.Format("**`{0}:`**", configProperty);
43+
var formattedConfigProperty = string.Format("### {0}", configProperty);
3644
configurationDocumentationFile.ShouldContain(formattedConfigProperty,
3745
Environment.NewLine + configurationDocumentationFile);
3846
}
@@ -54,8 +62,44 @@ public void VariableDocumentationIsUpToDate()
5462
}
5563
}
5664

65+
[Test]
66+
public void DocumentationIndexIsUpToDate()
67+
{
68+
var documentationIndexFile = ReadDocumentationFile("../mkdocs.yml");
69+
var docsDirectoryPath = new Uri(docsDirectory.FullName, UriKind.Absolute);
70+
71+
Console.WriteLine(docsDirectoryPath);
72+
73+
foreach (var markdownFile in docsDirectory.EnumerateFiles("*.md", SearchOption.AllDirectories))
74+
{
75+
var fullPath = new Uri(markdownFile.FullName, UriKind.Absolute);
76+
var relativePath = docsDirectoryPath
77+
.MakeRelativeUri(fullPath)
78+
.ToString()
79+
.Replace("docs/", string.Empty);
80+
81+
Console.WriteLine(fullPath);
82+
Console.WriteLine(relativePath);
83+
84+
documentationIndexFile.ShouldContain(relativePath, () => string.Format("The file '{0}' is not listed in 'mkdocs.yml'.", relativePath));
85+
}
86+
}
87+
88+
private string ReadDocumentationFile(string relativeDocumentationFilePath)
89+
{
90+
var documentationFilePath = Path.Combine(docsDirectory.FullName, relativeDocumentationFilePath);
91+
// Normalize path separators and such.
92+
documentationFilePath = new FileInfo(documentationFilePath).FullName;
93+
94+
if (!File.Exists(documentationFilePath))
95+
{
96+
throw new FileNotFoundException(string.Format("The documentation file '{0}' couldn't be found.", documentationFilePath), documentationFilePath);
97+
}
5798

58-
static string ReadDocumentationFile(string relativeDocumentationFilePath)
99+
return File.ReadAllText(documentationFilePath);
100+
}
101+
102+
private static DirectoryInfo GetDocsDirectory()
59103
{
60104
var currentDirectory = new FileInfo(typeof(DocumentationTests).Assembly.Location).Directory;
61105
while (currentDirectory != null)
@@ -78,15 +122,6 @@ static string ReadDocumentationFile(string relativeDocumentationFilePath)
78122
throw new DirectoryNotFoundException("Couldn't find the 'docs' directory.");
79123
}
80124

81-
var documentationFilePath = Path.Combine(currentDirectory.FullName, relativeDocumentationFilePath);
82-
// Normalize path separators and such.
83-
documentationFilePath = new FileInfo(documentationFilePath).FullName;
84-
85-
if (!File.Exists(documentationFilePath))
86-
{
87-
throw new FileNotFoundException(string.Format("The documentation file '{0}' couldn't be found.", documentationFilePath), documentationFilePath);
88-
}
89-
90-
return File.ReadAllText(documentationFilePath);
125+
return currentDirectory;
91126
}
92127
}

0 commit comments

Comments
 (0)