Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
devlead committed Oct 22, 2023
2 parents 2d77bb7 + 41e581b commit 269162c
Show file tree
Hide file tree
Showing 14 changed files with 266 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ jobs:
with:
dotnet-version: '6.0.x'

- name: Install .NET SDK 7.0.x
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'

- name: Install .NET SDK
uses: actions/setup-dotnet@v3
with:
Expand Down
38 changes: 38 additions & 0 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,44 @@ Task("Clean")
context.Information("Validated version {0}", data.Version);
}
)
.Then("Integration-Tests-Tool-Validate-Markdown")
.Does<BuildData>(
static (context, data) => {

context.DotNetTool(
"tool",
new DotNetToolSettings {
ArgumentCustomization = args => args
.Append("run")
.Append("dpi")
.Append("nuget")
.AppendSwitchQuoted("--output", "markdown")
.AppendSwitchQuoted("--file", data.MarkdownIndexPath.FullPath)
.Append("../../../")
.Append("analyze")
.AppendSwitchQuoted("--buildversion", data.Version),
WorkingDirectory = data.IntegrationTestPath,
}
);
}
)
.Then("Integration-Tests-Upload-Results")
.WithCriteria(BuildSystem.IsRunningOnGitHubActions, nameof(BuildSystem.IsRunningOnGitHubActions))
.Does<BuildData>(
async (context, data) => {
await GitHubActions.Commands.UploadArtifact(
data.MarkdownPath,
"Markdown"
);
GitHubActions.Commands.SetStepSummary(
string.Join(
System.Environment.NewLine,
context.FileSystem.GetFile(data.MarkdownIndexPath)
.ReadLines(Encoding.UTF8)
)
);
}
)
.Then("Integration-Tests")
.Default()
.Then("Push-GitHub-Packages")
Expand Down
6 changes: 5 additions & 1 deletion build/records.cake
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ public record BuildData(
)
{
private const string IntegrationTest = "integrationtest";
private const string Markdown = nameof(Markdown);
public DirectoryPath NuGetOutputPath { get; } = OutputPath.Combine("nuget");
public DirectoryPath BinaryOutputPath { get; } = OutputPath.Combine("bin");
public DirectoryPath IntegrationTestPath { get; } = OutputPath.Combine(IntegrationTest);
public DirectoryPath MarkdownPath { get; } = OutputPath.Combine(Markdown);
public FilePath MarkdownIndexPath { get; } = OutputPath.Combine(Markdown).CombineWithFilePath("index.md");

public string GitHubNuGetSource { get; } = System.Environment.GetEnvironmentVariable("GH_PACKAGES_NUGET_SOURCE");
public string GitHubNuGetApiKey { get; } = System.Environment.GetEnvironmentVariable("GH_PACKAGES_NUGET_APIKEY");
Expand All @@ -36,7 +39,8 @@ public record BuildData(
public ICollection<DirectoryPath> DirectoryPathsToClean = new []{
ArtifactsPath,
OutputPath,
OutputPath.Combine(IntegrationTest)
OutputPath.Combine(IntegrationTest),
OutputPath.Combine(Markdown)
};
}

Expand Down
5 changes: 2 additions & 3 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"sdk": {
"version": "7.0.306",
"rollForward": "latestFeature",
"allowPrerelease": false
"version": "8.0.100-rc.2.23502.2",
"rollForward": "latestFeature"
}
}
2 changes: 1 addition & 1 deletion src/DPI/Attributes/TableGroupAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
[AttributeUsage(AttributeTargets.Property)]
public class TableGroupAttribute : Attribute
{
}
}
6 changes: 6 additions & 0 deletions src/DPI/Attributes/TableSourceAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace DPI.Attributes;

[AttributeUsage(AttributeTargets.Property)]
public class TableSourceAttribute : TableGroupAttribute
{
}
2 changes: 1 addition & 1 deletion src/DPI/Commands/Settings/NuGet/NuGetSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public DirectoryPath SourcePath
public bool Silent { get; init; }

[CommandOption("-o|--output <FORMAT>")]
[Description("Specifies optional result output format JSON,TABLE.")]
[Description("Specifies optional result output format JSON,TABLE,MARKDOWN.")]
public OutputFormat? Output { get; init; }

[CommandOption("-f|--file <FILEPATH>")]
Expand Down
20 changes: 16 additions & 4 deletions src/DPI/DPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<Nullable>enable</Nullable>
<PackageIcon>icon/dpi.png</PackageIcon>
<ImplicitUsings>enable</ImplicitUsings>
<PackageReadmeFile>README.md</PackageReadmeFile>
<LangVersion>11</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Spectre.Console" Version="0.47.0" />
<PackageReference Include="Spectre.Console.Cli" Version="0.47.0" />
<PackageReference Include="Spectre.Console.Cli.Extensions.DependencyInjection" Version="0.1.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.9" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Cake.Core" Version="3.1.0" />
Expand All @@ -23,9 +22,22 @@
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == 'net7.0'">
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0-rc.2.23479.6" />
</ItemGroup>

<ItemGroup>
<None Include="../../icon/LICENSE.md" Pack="true" PackagePath="icon" />
<None Include="../../icon/dpi.png" Pack="true" PackagePath="icon" />
<None Include="../../README.md" Pack="true" PackagePath="\"/>
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 6 additions & 4 deletions src/DPI/Helper/GenericTableHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ static string[] GetPropertyValues(ICollection<PropertyInfo> properties, T row)
// ReSharper disable once ParameterTypeCanBeEnumerable.Local
// ReSharper disable once ReturnTypeCanBeEnumerable.Local
static GroupProperty[] GetPropertyNameValues(
ICollection<(PropertyInfo PropertyInfo, bool IsTitle)> properties, T row)
ICollection<(PropertyInfo PropertyInfo, bool IsTitle, bool IsSource)> properties, T row)
=> properties
.Select(property => new GroupProperty(
property.PropertyInfo.Name,
GetPropertyValue(property.PropertyInfo.GetValue, row),
property.IsTitle
property.IsTitle,
property.IsSource
)
)
.ToArray();
Expand All @@ -50,7 +51,7 @@ static string GetPropertyValue(Func<object?, object?> getValue, T row)
| BindingFlags.Instance
).ToArray();

(PropertyInfo PropertyInfo, bool IsTitle)[] groupProperties = (
(PropertyInfo PropertyInfo, bool IsTitle, bool IsSource)[] groupProperties = (
from propertyInfo in propertyInfos
let tableGroupAttributes = propertyInfo
.GetCustomAttributes(typeof(TableGroupAttribute))
Expand All @@ -61,7 +62,8 @@ where tableGroupAttributes.Any()

select (
propertyInfo,
tableGroupAttributes.OfType<TableGroupTitleAttribute>().Any()
tableGroupAttributes.OfType<TableGroupTitleAttribute>().Any(),
tableGroupAttributes.OfType<TableSourceAttribute>().Any()
)
).ToArray();

Expand Down
1 change: 1 addition & 0 deletions src/DPI/Models/NuGet/PackageReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public record PackageReference(
[property: JsonPropertyName("sourceType")] [property: JsonConverter(typeof(JsonStringEnumConverter))]
NuGetSourceType SourceType = NuGetSourceType.Unknown,

[property: TableSource]
[property: TableGroupTitle]
[property: JsonPropertyName("source")] [property: JsonConverter(typeof(FilePathJsonConverter))]
FilePath? Source = null,
Expand Down
3 changes: 2 additions & 1 deletion src/DPI/Models/OutputFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public enum OutputFormat
{
Json,
Table
Table,
Markdown
}
}
2 changes: 1 addition & 1 deletion src/DPI/Models/Records.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace DPI.Models
{
public record GroupProperty(string Name, string Value, bool IsTitle);
public record GroupProperty(string Name, string Value, bool IsTitle, bool IsSource);
}
Loading

0 comments on commit 269162c

Please sign in to comment.