forked from GitTools/GitVersion
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
11 changed files
with
471 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
36 changes: 36 additions & 0 deletions
36
src/GitVersion.Configuration.Tests/Workflows/WorkflowsTests.cs
This file contains 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,36 @@ | ||
namespace GitVersion.Configuration.Tests.Configuration; | ||
|
||
[TestFixture] | ||
public class WorkflowsTests | ||
{ | ||
private readonly ConfigurationSerializer serializer = new(); | ||
|
||
private static readonly object[][] Workflows = | ||
[ | ||
["GitFlow/v1", GitFlowConfigurationBuilder.New], | ||
["GitHubFlow/v1", GitHubFlowConfigurationBuilder.New], | ||
["TrunkBased/preview1", TrunkBasedConfigurationBuilder.New] | ||
]; | ||
|
||
[Test(Description = "This test is to ensure that the configuration for workflow is up to date")] | ||
[TestCaseSource(nameof(Workflows))] | ||
public void CheckWorkflowsAreUpdated(string workflow, IConfigurationBuilder configurationBuilder) | ||
{ | ||
var configuration = configurationBuilder.Build(); | ||
|
||
var serializedConfiguration = serializer.Serialize(configuration); | ||
var segments = workflow.Split("/"); | ||
var folderName = segments[0]; | ||
var fileName = segments[^1]; | ||
|
||
serializedConfiguration.ShouldMatchApproved(builder => builder | ||
.WithFilenameGenerator((_, _, type, extension) => FilenameGenerator(fileName, type, extension)) | ||
.WithFileExtension("yml") | ||
.SubFolder($"approved/{folderName}")); | ||
} | ||
|
||
private static string FilenameGenerator(string fileName, string type, string ext) => | ||
type == "approved" | ||
? $"{fileName}.{ext}" | ||
: $"{fileName}.{type}.{ext}"; | ||
} |
167 changes: 167 additions & 0 deletions
167
src/GitVersion.Configuration.Tests/Workflows/approved/GitFlow/v1.yml
This file contains 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,167 @@ | ||
assembly-versioning-scheme: MajorMinorPatch | ||
assembly-file-versioning-scheme: MajorMinorPatch | ||
tag-prefix: '[vV]?' | ||
version-in-branch-pattern: (?<version>[vV]?\d+(\.\d+)?(\.\d+)?).* | ||
major-version-bump-message: '\+semver:\s?(breaking|major)' | ||
minor-version-bump-message: '\+semver:\s?(feature|minor)' | ||
patch-version-bump-message: '\+semver:\s?(fix|patch)' | ||
no-bump-message: '\+semver:\s?(none|skip)' | ||
tag-pre-release-weight: 60000 | ||
commit-date-format: yyyy-MM-dd | ||
merge-message-formats: {} | ||
update-build-number: true | ||
semantic-version-format: Strict | ||
strategies: | ||
- Fallback | ||
- ConfiguredNextVersion | ||
- MergeMessage | ||
- TaggedCommit | ||
- TrackReleaseBranches | ||
- VersionInBranchName | ||
branches: | ||
develop: | ||
mode: ContinuousDelivery | ||
label: alpha | ||
increment: Minor | ||
prevent-increment: | ||
when-current-commit-tagged: false | ||
track-merge-target: true | ||
track-merge-message: true | ||
regex: ^dev(elop)?(ment)?$ | ||
source-branches: | ||
- main | ||
is-source-branch-for: [] | ||
tracks-release-branches: true | ||
is-release-branch: false | ||
is-main-branch: false | ||
pre-release-weight: 0 | ||
main: | ||
label: '' | ||
increment: Patch | ||
prevent-increment: | ||
of-merged-branch: true | ||
track-merge-target: false | ||
track-merge-message: true | ||
regex: ^master$|^main$ | ||
source-branches: [] | ||
is-source-branch-for: [] | ||
tracks-release-branches: false | ||
is-release-branch: false | ||
is-main-branch: true | ||
pre-release-weight: 55000 | ||
release: | ||
mode: ManualDeployment | ||
label: beta | ||
increment: Minor | ||
prevent-increment: | ||
of-merged-branch: true | ||
when-current-commit-tagged: false | ||
track-merge-target: false | ||
regex: ^releases?[/-](?<BranchName>.+) | ||
source-branches: | ||
- main | ||
- support | ||
is-source-branch-for: [] | ||
tracks-release-branches: false | ||
is-release-branch: true | ||
is-main-branch: false | ||
pre-release-weight: 30000 | ||
feature: | ||
mode: ManualDeployment | ||
label: '{BranchName}' | ||
increment: Inherit | ||
prevent-increment: | ||
when-current-commit-tagged: false | ||
track-merge-message: true | ||
regex: ^features?[/-](?<BranchName>.+) | ||
source-branches: | ||
- develop | ||
- main | ||
- release | ||
- support | ||
- hotfix | ||
is-source-branch-for: [] | ||
is-main-branch: false | ||
pre-release-weight: 30000 | ||
pull-request: | ||
mode: ContinuousDelivery | ||
label: PullRequest | ||
increment: Inherit | ||
prevent-increment: | ||
of-merged-branch: true | ||
when-current-commit-tagged: false | ||
label-number-pattern: '[/-](?<number>\d+)' | ||
track-merge-message: true | ||
regex: ^(pull|pull\-requests|pr)[/-] | ||
source-branches: | ||
- develop | ||
- main | ||
- release | ||
- feature | ||
- support | ||
- hotfix | ||
is-source-branch-for: [] | ||
pre-release-weight: 30000 | ||
hotfix: | ||
mode: ManualDeployment | ||
label: beta | ||
increment: Inherit | ||
prevent-increment: | ||
when-current-commit-tagged: false | ||
regex: ^hotfix(es)?[/-](?<BranchName>.+) | ||
source-branches: | ||
- main | ||
- support | ||
is-source-branch-for: [] | ||
is-release-branch: true | ||
is-main-branch: false | ||
pre-release-weight: 30000 | ||
support: | ||
label: '' | ||
increment: Patch | ||
prevent-increment: | ||
of-merged-branch: true | ||
track-merge-target: false | ||
regex: ^support[/-](?<BranchName>.+) | ||
source-branches: | ||
- main | ||
is-source-branch-for: [] | ||
tracks-release-branches: false | ||
is-release-branch: false | ||
is-main-branch: true | ||
pre-release-weight: 55000 | ||
unknown: | ||
mode: ManualDeployment | ||
label: '{BranchName}' | ||
increment: Inherit | ||
prevent-increment: | ||
when-current-commit-tagged: true | ||
regex: (?<BranchName>.+) | ||
source-branches: | ||
- main | ||
- develop | ||
- release | ||
- feature | ||
- pull-request | ||
- hotfix | ||
- support | ||
is-source-branch-for: [] | ||
is-main-branch: false | ||
ignore: | ||
sha: [] | ||
mode: ContinuousDelivery | ||
label: '{BranchName}' | ||
increment: Inherit | ||
prevent-increment: | ||
of-merged-branch: false | ||
when-branch-merged: false | ||
when-current-commit-tagged: true | ||
track-merge-target: false | ||
track-merge-message: true | ||
commit-message-incrementing: Enabled | ||
regex: '' | ||
source-branches: [] | ||
is-source-branch-for: [] | ||
tracks-release-branches: false | ||
is-release-branch: false | ||
is-main-branch: false |
Oops, something went wrong.