Skip to content

Commit 344ad3c

Browse files
committed
Refactoring of the documentation updater. Propagating the --no-sign flag to dotnet build.
1 parent 3a3a990 commit 344ad3c

19 files changed

Lines changed: 510 additions & 372 deletions

src/PostSharp.Engineering.BuildTools/AppExtensions.cs

Lines changed: 158 additions & 154 deletions
Large diffs are not rendered by default.

src/PostSharp.Engineering.BuildTools/Build/Model/Product.cs

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public Product( DependencyDefinition dependencyDefinition )
5151
this.DockerBaseImage = dependencyDefinition.ProductFamily.DockerBaseImage;
5252
}
5353

54+
public bool AddDefaultCommands { get; init; } = true;
55+
5456
public ProductFamily ProductFamily => this.DependencyDefinition.ProductFamily;
5557

5658
public string BuildExePath { get; }
@@ -215,7 +217,7 @@ public ParametrizedDependency[] ParametrizedDependencies
215217
public DockerImageComponent[] AdditionalDockerImageComponents { get; init; } = [];
216218

217219
public bool UseDockerInTeamcity { get; init; }
218-
220+
219221
public bool IsPublishingNonReleaseBranchesAllowed { get; init; }
220222

221223
public bool TryGetDependency( string name, [NotNullWhen( true )] out ParametrizedDependency? dependency )
@@ -676,7 +678,7 @@ public bool TryReadMainVersionFile(
676678
BuildContext context,
677679
[NotNullWhen( true )] out MainVersionFileInfo? mainVersionFileInfo )
678680
=> this.TryReadMainVersionFile( context, out mainVersionFileInfo, out _ );
679-
681+
680682
/// <summary>
681683
/// Reads MainVersion.props but does not interpret anything.
682684
/// </summary>
@@ -732,7 +734,7 @@ public bool TryReadMainVersionFile(
732734

733735
ProjectCollection.GlobalProjectCollection.UnloadAllProjects();
734736

735-
mainVersionFileInfo = new(
737+
mainVersionFileInfo = new MainVersionFileInfo(
736738
mainVersion,
737739
overriddenPatchVersion,
738740
suffix,
@@ -1367,7 +1369,7 @@ private bool TryGenerateManifestFileContent(
13671369
out string manifestFileContent )
13681370
{
13691371
var success = true;
1370-
1372+
13711373
manifestFileContent = $@"
13721374
<!-- File generated by PostSharp.Engineering {VersionHelper.EngineeringVersion}, method {nameof(Product)}.{nameof(this.TryGenerateManifestFileContent)}. -->
13731375
<Project>
@@ -1596,11 +1598,11 @@ void CleanNugetCache()
15961598
foreach ( var subDir in dir.EnumerateDirectories() )
15971599
{
15981600
var directoryPath = Path.Combine( nugetCacheDirectory, dir.Name, subDir.Name );
1599-
1601+
16001602
if ( subDir.Name.Equals( VersionHelper.EngineeringVersion, StringComparison.OrdinalIgnoreCase ) )
16011603
{
16021604
context.Console.WriteMessage( $"Skipping directory '{directoryPath}'." );
1603-
1605+
16041606
continue;
16051607
}
16061608

@@ -1764,7 +1766,7 @@ public bool PrePublish( BuildContext context, PublishSettings settings )
17641766
{
17651767
return false;
17661768
}
1767-
1769+
17681770
if ( TeamCityHelper.IsTeamCityBuild( settings ) )
17691771
{
17701772
// When on TeamCity, Git user credentials are set to TeamCity.
@@ -1792,19 +1794,19 @@ public bool PrePublish( BuildContext context, PublishSettings settings )
17921794

17931795
return false;
17941796
}
1795-
1797+
17961798
if ( !TryUpdateAutoUpdatedDependencies( context, settings ) )
17971799
{
17981800
context.Console.WriteError( "Failed to update auto-updated dependencies." );
1799-
1801+
18001802
return false;
18011803
}
1802-
1804+
18031805
if ( !GitHelper.TryPullAndMergeAndPush( context, settings, targetBranch ) )
18041806
{
18051807
return false;
18061808
}
1807-
1809+
18081810
// Act as a local dependency for subsequent projects, that use the --use-local-dependencies flag.
18091811
this.WriteImportFile( context, settings.BuildConfiguration );
18101812

@@ -1818,7 +1820,7 @@ public bool Publish( BuildContext context, PublishSettings settings )
18181820
if ( !context.Product.IsPublishingNonReleaseBranchesAllowed && !settings.IsStandalone )
18191821
{
18201822
var publishingBranch = context.Product.DependencyDefinition.PublishingBranch;
1821-
1823+
18221824
if ( context.Branch != publishingBranch )
18231825
{
18241826
context.Console.WriteError(
@@ -1837,7 +1839,7 @@ public bool Publish( BuildContext context, PublishSettings settings )
18371839
{
18381840
return false;
18391841
}
1840-
1842+
18411843
// TODO: Verification is broken - NuGet verification is slow and makes the verification fail
18421844
// on seemimngly unpublished packages.
18431845
// if ( settings.BuildConfiguration == BuildConfiguration.Public )
@@ -1853,7 +1855,7 @@ public bool Publish( BuildContext context, PublishSettings settings )
18531855
var directories = this.GetArtifactsDirectories( context, buildInfo );
18541856
var configurationInfo = this.Configurations.GetValue( configuration );
18551857
var hasTarget = false;
1856-
1858+
18571859
if ( !Publisher.PublishDirectory(
18581860
context,
18591861
settings,
@@ -1889,7 +1891,7 @@ public bool Publish( BuildContext context, PublishSettings settings )
18891891
return false;
18901892
}
18911893
}
1892-
1894+
18931895
if ( !this.TryAddTagToLastCommit( context, settings ) )
18941896
{
18951897
context.Console.WriteError( "Failed to tag the latest commit." );
@@ -1942,12 +1944,12 @@ public bool Publish( BuildContext context, PublishSettings settings )
19421944
public bool PostPublish( BuildContext context, PublishSettings settings )
19431945
{
19441946
context.Console.WriteHeading( "Finishing publishing." );
1945-
1947+
19461948
if ( !this.PrepareVersionsFile( context, settings, out _ ) )
19471949
{
19481950
return false;
19491951
}
1950-
1952+
19511953
if ( TeamCityHelper.IsTeamCityBuild( settings ) )
19521954
{
19531955
// When on TeamCity, Git user credentials are set to TeamCity.
@@ -1956,7 +1958,7 @@ public bool PostPublish( BuildContext context, PublishSettings settings )
19561958
return false;
19571959
}
19581960
}
1959-
1961+
19601962
var sourceBranch = context.Product.DependencyDefinition.ReleaseBranch;
19611963

19621964
if ( sourceBranch == null )
@@ -1965,7 +1967,7 @@ public bool PostPublish( BuildContext context, PublishSettings settings )
19651967

19661968
return false;
19671969
}
1968-
1970+
19691971
if ( context.Branch != sourceBranch )
19701972
{
19711973
context.Console.WriteError(
@@ -1977,10 +1979,10 @@ public bool PostPublish( BuildContext context, PublishSettings settings )
19771979
if ( !this.TryAddTagToLastCommit( context, settings ) )
19781980
{
19791981
context.Console.WriteError( "Failed to tag the latest commit." );
1980-
1982+
19811983
return false;
19821984
}
1983-
1985+
19841986
// Merge the release branch back to develop branch.
19851987
if ( !GitHelper.TryPullAndMergeAndPush( context, settings, context.Product.DependencyDefinition.Branch ) )
19861988
{
@@ -1989,7 +1991,7 @@ public bool PostPublish( BuildContext context, PublishSettings settings )
19891991

19901992
// Act as a local dependency for subsequent projects, that use the --use-local-dependencies flag.
19911993
this.WriteImportFile( context, settings.BuildConfiguration );
1992-
1994+
19931995
context.Console.WriteSuccess( "Publishing finished successfuly." );
19941996

19951997
return true;
@@ -2305,7 +2307,7 @@ private bool TryReadDependencyVersionsFromSourceRepos(
23052307
}
23062308

23072309
var mainVersionFile = $"{dependency.EngineeringDirectory}/MainVersion.props";
2308-
2310+
23092311
if ( !dependency.VcsRepository.TryDownloadTextFile( context.Console, dependency.Branch, mainVersionFile, out var mainVersionContent ) )
23102312
{
23112313
return false;
@@ -2446,10 +2448,11 @@ internal bool GenerateTeamcityConfiguration( BuildContext context, CommonCommand
24462448
}
24472449

24482450
teamCityBuildSteps.Add( new TeamCityEngineeringBuildBuildStep( configuration, true, this.UseDockerInTeamcity ) );
2449-
2451+
24502452
if ( !this.UseDockerInTeamcity )
24512453
{
2452-
teamCityBuildSteps.Add( new TeamCityEngineeringCommandBuildStep( "PostKill", "Kill background processes before next build", "tools kill" ) );
2454+
teamCityBuildSteps.Add(
2455+
new TeamCityEngineeringCommandBuildStep( "PostKill", "Kill background processes before next build", "tools kill" ) );
24532456
}
24542457

24552458
// The default branch for the public build cannot be set to the release branch,
@@ -2641,7 +2644,7 @@ [new TeamCityEngineeringCommandBuildStep( "Bump", "Bump", "bump", areCustomArgum
26412644
return false;
26422645
}
26432646
}
2644-
2647+
26452648
var teamCityProject = new TeamCityProject( teamCityBuildConfigurations.ToArray() );
26462649

26472650
TeamCityHelper.GeneratePom( context, this.DependencyDefinition.CiConfiguration.ProjectId.Id, this.DependencyDefinition.CiConfiguration.BaseUrl );
@@ -2775,7 +2778,7 @@ private bool TryAddTagToLastCommit( BuildContext context, PublishSettings settin
27752778
{
27762779
return false;
27772780
}
2778-
2781+
27792782
var versionTag = string.Concat( "release/", preparedVersionInfo.Version, preparedVersionInfo.PackageVersionSuffix );
27802783

27812784
ToolInvocationHelper.InvokeTool(
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using PostSharp.Engineering.BuildTools.ContinuousIntegration.Model;
1+
// Copyright (c) SharpCrafters s.r.o. See the LICENSE.md file in the root directory of this repository root for details.
2+
3+
using PostSharp.Engineering.BuildTools.ContinuousIntegration.Model;
24
using Spectre.Console.Cli;
35
using System.Collections.Generic;
46

@@ -8,5 +10,5 @@ public abstract class ProductExtension
810
{
911
internal abstract bool AddTeamcityBuildConfiguration( BuildContext context, List<TeamCityBuildConfiguration> teamCityBuildConfigurations );
1012

11-
internal abstract bool AddTool( IConfigurator<CommandSettings> tools );
13+
internal abstract bool AddCommands( IConfigurator root, BaseCommandData data );
1214
}

src/PostSharp.Engineering.BuildTools/Search/Backends/ConsoleBackend.cs renamed to src/PostSharp.Engineering.BuildTools/Search/Backends/DrySearchBackend.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99

1010
namespace PostSharp.Engineering.BuildTools.Search.Backends;
1111

12-
public class ConsoleBackend : SearchBackendBase
12+
public class DrySearchBackend : SearchBackendBase
1313
{
1414
private readonly ConsoleHelper _console;
1515

16-
public ConsoleBackend( ConsoleHelper console )
16+
public DrySearchBackend( ConsoleHelper console )
1717
{
1818
this._console = console;
1919
}
@@ -26,14 +26,14 @@ public override Task CreateCollectionAsync( Schema schema )
2626
{
2727
this._console.WriteMessage( $" {field.Name}: {field.Type}, facet: {field.Facet}" );
2828
}
29-
29+
3030
this._console.WriteMessage( "" );
3131

3232
return Task.CompletedTask;
3333
}
3434

3535
public override Task DeleteCollectionAsync( string collection ) => throw new NotSupportedException();
36-
36+
3737
public override Task<bool> TryDeleteCollectionAsync( string collection ) => Task.FromResult( false );
3838

3939
public override Task<IEnumerable<CollectionResponse>> RetrieveCollectionsAsync() => throw new NotSupportedException();
@@ -49,7 +49,7 @@ public override Task CreateCollectionAsync( Schema schema )
4949
private void WriteObject( object o, int indentation = 0 )
5050
{
5151
var indentationString = new string( ' ', indentation );
52-
52+
5353
foreach ( var property in o.GetType().GetProperties() )
5454
{
5555
var value = property.GetValue( o )!;

src/PostSharp.Engineering.BuildTools/Search/Crawlers/DocFxApiArticleHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace PostSharp.Engineering.BuildTools.Search.Crawlers;
88

9-
public static class DocFxApiArticleHelper
9+
internal static class DocFxApiArticleHelper
1010
{
1111
public static NextParagraphStrategy GetNextParagraphStrategy( HtmlNode paragraphInitialNode )
1212
{
@@ -48,7 +48,7 @@ public static NextParagraphStrategy GetNextParagraphStrategy( HtmlNode paragraph
4848
}
4949

5050
break;
51-
51+
5252
case 5:
5353
var text = paragraphInitialNode.GetText().Trim();
5454
isIgnored = text != "Remarks";

0 commit comments

Comments
 (0)