Skip to content

Commit b6772d1

Browse files
committed
GitTools#4017 - added Approval tests for default Configuration Workflows
If the configuration for a workflow will change the unit test will fail and will require to accept the new changes. These changes are then copied to the docs
1 parent cd89b91 commit b6772d1

File tree

11 files changed

+471
-27
lines changed

11 files changed

+471
-27
lines changed

docs/input/docs/workflows/GitFlow/v1.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
assembly-versioning-scheme: MajorMinorPatch
1+
assembly-versioning-scheme: MajorMinorPatch
22
assembly-file-versioning-scheme: MajorMinorPatch
33
tag-prefix: '[vV]?'
44
version-in-branch-pattern: (?<version>[vV]?\d+(\.\d+)?(\.\d+)?).*

docs/input/docs/workflows/GitHubFlow/v1.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
assembly-versioning-scheme: MajorMinorPatch
1+
assembly-versioning-scheme: MajorMinorPatch
22
assembly-file-versioning-scheme: MajorMinorPatch
33
tag-prefix: '[vV]?'
44
version-in-branch-pattern: (?<version>[vV]?\d+(\.\d+)?(\.\d+)?).*
@@ -57,12 +57,12 @@ branches:
5757
increment: Inherit
5858
prevent-increment:
5959
when-current-commit-tagged: false
60+
track-merge-message: true
6061
regex: ^features?[/-](?<BranchName>.+)
6162
source-branches:
6263
- main
6364
- release
6465
is-source-branch-for: []
65-
track-merge-message: true
6666
is-main-branch: false
6767
pre-release-weight: 30000
6868
pull-request:
@@ -73,28 +73,28 @@ branches:
7373
of-merged-branch: true
7474
when-current-commit-tagged: false
7575
label-number-pattern: '[/-](?<number>\d+)'
76+
track-merge-message: true
7677
regex: ^(pull|pull\-requests|pr)[/-]
7778
source-branches:
7879
- main
7980
- release
8081
- feature
8182
is-source-branch-for: []
82-
track-merge-message: true
8383
pre-release-weight: 30000
8484
unknown:
8585
mode: ManualDeployment
8686
label: '{BranchName}'
8787
increment: Inherit
8888
prevent-increment:
8989
when-current-commit-tagged: false
90+
track-merge-message: false
9091
regex: (?<BranchName>.+)
9192
source-branches:
9293
- main
9394
- release
9495
- feature
9596
- pull-request
9697
is-source-branch-for: []
97-
track-merge-message: false
9898
is-main-branch: false
9999
ignore:
100100
sha: []

docs/input/docs/workflows/TrunkBased/preview1.yml

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
assembly-versioning-scheme: MajorMinorPatch
1+
assembly-versioning-scheme: MajorMinorPatch
22
assembly-file-versioning-scheme: MajorMinorPatch
33
tag-prefix: '[vV]?'
44
version-in-branch-pattern: (?<version>[vV]?\d+(\.\d+)?(\.\d+)?).*
@@ -12,55 +12,74 @@ merge-message-formats: {}
1212
update-build-number: true
1313
semantic-version-format: Strict
1414
strategies:
15-
- Mainline
1615
- ConfiguredNextVersion
16+
- Mainline
1717
branches:
1818
main:
1919
mode: ContinuousDeployment
2020
label: ''
2121
increment: Patch
2222
prevent-increment:
2323
of-merged-branch: true
24-
when-current-commit-tagged: true
2524
track-merge-target: false
25+
track-merge-message: true
2626
regex: ^master$|^main$
2727
source-branches: []
28+
is-source-branch-for: []
2829
tracks-release-branches: false
2930
is-release-branch: false
3031
is-main-branch: true
3132
pre-release-weight: 55000
3233
feature:
34+
mode: ContinuousDelivery
35+
label: '{BranchName}'
3336
increment: Minor
34-
regex: ^features?[/-](?<BranchName>.+)
3537
prevent-increment:
3638
when-current-commit-tagged: false
39+
track-merge-message: true
40+
regex: ^features?[/-](?<BranchName>.+)
3741
source-branches:
3842
- main
43+
is-source-branch-for: []
44+
is-main-branch: false
3945
pre-release-weight: 30000
4046
hotfix:
47+
mode: ContinuousDelivery
48+
label: '{BranchName}'
4149
increment: Patch
42-
regex: ^hotfix(es)?[/-](?<BranchName>.+)
4350
prevent-increment:
4451
when-current-commit-tagged: false
52+
regex: ^hotfix(es)?[/-](?<BranchName>.+)
4553
source-branches:
4654
- main
55+
is-source-branch-for: []
56+
is-release-branch: true
57+
is-main-branch: false
4758
pre-release-weight: 30000
4859
pull-request:
4960
mode: ContinuousDelivery
5061
label: PullRequest
5162
increment: Inherit
63+
prevent-increment:
64+
of-merged-branch: true
65+
when-current-commit-tagged: false
5266
label-number-pattern: '[/-](?<number>\d+)'
67+
track-merge-message: true
5368
regex: ^(pull|pull\-requests|pr)[/-]
5469
source-branches:
5570
- main
71+
- feature
72+
- hotfix
73+
is-source-branch-for: []
5674
pre-release-weight: 30000
5775
unknown:
5876
increment: Patch
59-
regex: (?<BranchName>.+)
6077
prevent-increment:
6178
when-current-commit-tagged: false
79+
regex: (?<BranchName>.+)
6280
source-branches:
6381
- main
82+
is-source-branch-for: []
6483
pre-release-weight: 30000
6584
ignore:
6685
sha: []
@@ -75,6 +94,8 @@ track-merge-target: false
7594
track-merge-message: true
7695
commit-message-incrementing: Enabled
7796
regex: ''
97+
source-branches: []
98+
is-source-branch-for: []
7899
tracks-release-branches: false
79100
is-release-branch: false
80101
is-main-branch: false

src/GitVersion.Configuration.Tests/GitVersion.Configuration.Tests.csproj

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,17 @@
33
<ProjectReference Include="..\GitVersion.Configuration\GitVersion.Configuration.csproj" />
44
<ProjectReference Include="..\GitVersion.Core.Tests\GitVersion.Core.Tests.csproj" />
55
</ItemGroup>
6+
7+
<!-- Add the following target to copy the workflow files to the docs folder.
8+
Whenever the Workflow changes, the docs folder will be updated with the latest version.
9+
-->
10+
<Target Name="CopyWorkflowFiles" BeforeTargets="BeforeBuild">
11+
<ItemGroup>
12+
<WorkflowFiles Include="Workflows\approved\**\*.yml" />
13+
</ItemGroup>
14+
15+
<Copy SourceFiles="@(WorkflowFiles)"
16+
DestinationFiles="@(WorkflowFiles->'..\..\docs\input\docs\workflows\%(RecursiveDir)%(Filename)%(Extension)')" />
17+
</Target>
18+
619
</Project>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
namespace GitVersion.Configuration.Tests.Configuration;
2+
3+
[TestFixture]
4+
public class WorkflowsTests
5+
{
6+
private readonly ConfigurationSerializer serializer = new();
7+
8+
private static readonly object[][] Workflows =
9+
[
10+
["GitFlow/v1", GitFlowConfigurationBuilder.New],
11+
["GitHubFlow/v1", GitHubFlowConfigurationBuilder.New],
12+
["TrunkBased/preview1", TrunkBasedConfigurationBuilder.New]
13+
];
14+
15+
[Test(Description = "This test is to ensure that the configuration for workflow is up to date")]
16+
[TestCaseSource(nameof(Workflows))]
17+
public void CheckWorkflowsAreUpdated(string workflow, IConfigurationBuilder configurationBuilder)
18+
{
19+
var configuration = configurationBuilder.Build();
20+
21+
var serializedConfiguration = serializer.Serialize(configuration);
22+
var segments = workflow.Split("/");
23+
var folderName = segments[0];
24+
var fileName = segments[^1];
25+
26+
serializedConfiguration.ShouldMatchApproved(builder => builder
27+
.WithFilenameGenerator((_, _, type, extension) => FilenameGenerator(fileName, type, extension))
28+
.WithFileExtension("yml")
29+
.SubFolder($"approved/{folderName}"));
30+
}
31+
32+
private static string FilenameGenerator(string fileName, string type, string ext) =>
33+
type == "approved"
34+
? $"{fileName}.{ext}"
35+
: $"{fileName}.{type}.{ext}";
36+
}
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
assembly-versioning-scheme: MajorMinorPatch
2+
assembly-file-versioning-scheme: MajorMinorPatch
3+
tag-prefix: '[vV]?'
4+
version-in-branch-pattern: (?<version>[vV]?\d+(\.\d+)?(\.\d+)?).*
5+
major-version-bump-message: '\+semver:\s?(breaking|major)'
6+
minor-version-bump-message: '\+semver:\s?(feature|minor)'
7+
patch-version-bump-message: '\+semver:\s?(fix|patch)'
8+
no-bump-message: '\+semver:\s?(none|skip)'
9+
tag-pre-release-weight: 60000
10+
commit-date-format: yyyy-MM-dd
11+
merge-message-formats: {}
12+
update-build-number: true
13+
semantic-version-format: Strict
14+
strategies:
15+
- Fallback
16+
- ConfiguredNextVersion
17+
- MergeMessage
18+
- TaggedCommit
19+
- TrackReleaseBranches
20+
- VersionInBranchName
21+
branches:
22+
develop:
23+
mode: ContinuousDelivery
24+
label: alpha
25+
increment: Minor
26+
prevent-increment:
27+
when-current-commit-tagged: false
28+
track-merge-target: true
29+
track-merge-message: true
30+
regex: ^dev(elop)?(ment)?$
31+
source-branches:
32+
- main
33+
is-source-branch-for: []
34+
tracks-release-branches: true
35+
is-release-branch: false
36+
is-main-branch: false
37+
pre-release-weight: 0
38+
main:
39+
label: ''
40+
increment: Patch
41+
prevent-increment:
42+
of-merged-branch: true
43+
track-merge-target: false
44+
track-merge-message: true
45+
regex: ^master$|^main$
46+
source-branches: []
47+
is-source-branch-for: []
48+
tracks-release-branches: false
49+
is-release-branch: false
50+
is-main-branch: true
51+
pre-release-weight: 55000
52+
release:
53+
mode: ManualDeployment
54+
label: beta
55+
increment: Minor
56+
prevent-increment:
57+
of-merged-branch: true
58+
when-current-commit-tagged: false
59+
track-merge-target: false
60+
regex: ^releases?[/-](?<BranchName>.+)
61+
source-branches:
62+
- main
63+
- support
64+
is-source-branch-for: []
65+
tracks-release-branches: false
66+
is-release-branch: true
67+
is-main-branch: false
68+
pre-release-weight: 30000
69+
feature:
70+
mode: ManualDeployment
71+
label: '{BranchName}'
72+
increment: Inherit
73+
prevent-increment:
74+
when-current-commit-tagged: false
75+
track-merge-message: true
76+
regex: ^features?[/-](?<BranchName>.+)
77+
source-branches:
78+
- develop
79+
- main
80+
- release
81+
- support
82+
- hotfix
83+
is-source-branch-for: []
84+
is-main-branch: false
85+
pre-release-weight: 30000
86+
pull-request:
87+
mode: ContinuousDelivery
88+
label: PullRequest
89+
increment: Inherit
90+
prevent-increment:
91+
of-merged-branch: true
92+
when-current-commit-tagged: false
93+
label-number-pattern: '[/-](?<number>\d+)'
94+
track-merge-message: true
95+
regex: ^(pull|pull\-requests|pr)[/-]
96+
source-branches:
97+
- develop
98+
- main
99+
- release
100+
- feature
101+
- support
102+
- hotfix
103+
is-source-branch-for: []
104+
pre-release-weight: 30000
105+
hotfix:
106+
mode: ManualDeployment
107+
label: beta
108+
increment: Inherit
109+
prevent-increment:
110+
when-current-commit-tagged: false
111+
regex: ^hotfix(es)?[/-](?<BranchName>.+)
112+
source-branches:
113+
- main
114+
- support
115+
is-source-branch-for: []
116+
is-release-branch: true
117+
is-main-branch: false
118+
pre-release-weight: 30000
119+
support:
120+
label: ''
121+
increment: Patch
122+
prevent-increment:
123+
of-merged-branch: true
124+
track-merge-target: false
125+
regex: ^support[/-](?<BranchName>.+)
126+
source-branches:
127+
- main
128+
is-source-branch-for: []
129+
tracks-release-branches: false
130+
is-release-branch: false
131+
is-main-branch: true
132+
pre-release-weight: 55000
133+
unknown:
134+
mode: ManualDeployment
135+
label: '{BranchName}'
136+
increment: Inherit
137+
prevent-increment:
138+
when-current-commit-tagged: true
139+
regex: (?<BranchName>.+)
140+
source-branches:
141+
- main
142+
- develop
143+
- release
144+
- feature
145+
- pull-request
146+
- hotfix
147+
- support
148+
is-source-branch-for: []
149+
is-main-branch: false
150+
ignore:
151+
sha: []
152+
mode: ContinuousDelivery
153+
label: '{BranchName}'
154+
increment: Inherit
155+
prevent-increment:
156+
of-merged-branch: false
157+
when-branch-merged: false
158+
when-current-commit-tagged: true
159+
track-merge-target: false
160+
track-merge-message: true
161+
commit-message-incrementing: Enabled
162+
regex: ''
163+
source-branches: []
164+
is-source-branch-for: []
165+
tracks-release-branches: false
166+
is-release-branch: false
167+
is-main-branch: false

0 commit comments

Comments
 (0)