Skip to content

Commit

Permalink
Merge template/faithlife-build.
Browse files Browse the repository at this point in the history
  • Loading branch information
ejball committed Jul 3, 2024
2 parents 6fd26fb + 4a90067 commit c18f091
Show file tree
Hide file tree
Showing 19 changed files with 127 additions and 70 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ resharper_comment_typo_highlighting = none
resharper_identifier_typo_highlighting = none
resharper_string_literal_typo_highlighting = none

[Directory.Packages.props]
insert_final_newline = false

[dotnet-tools.json]
insert_final_newline = false

Expand Down Expand Up @@ -87,6 +90,7 @@ csharp_style_prefer_local_over_anonymous_function = true : suggestion
csharp_style_prefer_not_pattern = true : suggestion
csharp_style_prefer_null_check_over_type_check = true : suggestion
csharp_style_prefer_pattern_matching = true : suggestion
csharp_style_prefer_primary_constructors = true : suggestion
csharp_style_prefer_range_operator = true : suggestion
csharp_style_prefer_switch_expression = true : suggestion
csharp_style_prefer_tuple_swap = true : warning
Expand Down Expand Up @@ -203,7 +207,9 @@ dotnet_diagnostic.IDE0160.severity = suggestion
dotnet_diagnostic.IDE0161.severity = suggestion
dotnet_diagnostic.IDE0170.severity = suggestion
dotnet_diagnostic.IDE0180.severity = warning
dotnet_diagnostic.IDE0290.severity = suggestion
dotnet_diagnostic.IDE1005.severity = suggestion
dotnet_diagnostic.NUnit2045.severity = suggestion
dotnet_diagnostic.SA0001.severity = none
dotnet_diagnostic.SA1003.severity = none
dotnet_diagnostic.SA1008.severity = none
Expand Down Expand Up @@ -326,6 +332,7 @@ resharper_arrange_missing_parentheses_highlighting = hint
resharper_arrange_trailing_comma_in_multiline_lists_highlighting = warning
resharper_comment_typo_highlighting = none
resharper_compare_of_floats_by_equality_operator_highlighting = suggestion
resharper_convert_to_primary_constructor_highlighting = hint
resharper_csharp_align_first_arg_by_paren = false
resharper_csharp_align_linq_query = false
resharper_csharp_align_multiline_argument = false
Expand All @@ -347,6 +354,7 @@ resharper_csharp_indent_anonymous_method_block = false
resharper_csharp_indent_nested_for_stmt = true
resharper_csharp_indent_nested_foreach_stmt = true
resharper_csharp_indent_nested_while_stmt = true
resharper_csharp_indent_raw_literal_string = indent
resharper_csharp_int_align = false
resharper_csharp_keep_existing_arrangement = true
resharper_csharp_nested_ternary_style = simple_wrap
Expand Down
32 changes: 15 additions & 17 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,39 +1,37 @@
name: Build

on:
workflow_dispatch:
push:
paths-ignore:
- '*.md'
- 'docs/**'
branches:
- 'master'
tags-ignore:
- '**'
branches: [master]
tags-ignore: ['**']
pull_request:
paths-ignore:
- '*.md'
- 'docs/**'
workflow_dispatch:

env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_NOLOGO: 1
DOTNET_CLI_TELEMETRY_OPTOUT: 1

defaults:
run:
shell: pwsh

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Install .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
8.0.x
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up .NET 7
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
fetch-depth: 0 # required to publish docs
- name: Restore
run: .\build.ps1 restore
- name: Build
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/publish-docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Publish Docs

on:
workflow_dispatch:

env:
DOTNET_NOLOGO: 1
DOTNET_CLI_TELEMETRY_OPTOUT: 1

defaults:
run:
shell: pwsh

jobs:
publish-docs:
runs-on: windows-latest
steps:
- name: Install .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
8.0.x
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 0 # required to publish docs
- name: Publish Docs
env:
BUILD_BOT_PASSWORD: ${{ secrets.BUILD_BOT_PASSWORD }}
run: .\build.ps1 publish --no-test --trigger publish-docs
13 changes: 7 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
.vs/
.idea/
artifacts/
bin/
obj/
release/
.vs/
.idea/
Thumbs.db

*.cache
*.user
*.userprefs
*.log
*.ncrunchproject
*.ncrunchsolution
*.user
launchSettings.json
nCrunchTemp*
_ReSharper*
.DS_Store
launchSettings.json
22 changes: 9 additions & 13 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

<PropertyGroup>
<VersionPrefix>2.8.0</VersionPrefix>
<LangVersion>11.0</LangVersion>
<PackageValidationBaselineVersion>2.8.0</PackageValidationBaselineVersion>
<LangVersion>12.0</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NoWarn>$(NoWarn);1591;1998;NU1507;NU5105</NoWarn>
<NeutralLanguage>en-US</NeutralLanguage>
<NoWarn>$(NoWarn);1591;1998;NU5105</NoWarn>
<DebugType>embedded</DebugType>
<GitHubOrganization>FacilityApi</GitHubOrganization>
<RepositoryName>FacilityMarkdown</RepositoryName>
Expand All @@ -20,26 +21,21 @@
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<AnalysisLevel>latest-all</AnalysisLevel>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<IsPackable>false</IsPackable>
<IsTestProject>false</IsTestProject>
<SelfContained>false</SelfContained>
<UseArtifactsOutput>true</UseArtifactsOutput>
<EnableStrictModeForCompatibleFrameworksInPackageValidation>true</EnableStrictModeForCompatibleFrameworksInPackageValidation>
<EnableStrictModeForCompatibleTfms>true</EnableStrictModeForCompatibleTfms>
<DisablePackageBaselineValidation Condition=" $(PackageValidationBaselineVersion) == $(VersionPrefix) or $(PackageValidationBaselineVersion) == '0.0.0' ">true</DisablePackageBaselineValidation>
</PropertyGroup>

<PropertyGroup Condition=" '$(BuildNumber)' != '' ">
<AssemblyVersion>$(VersionPrefix).$(BuildNumber)</AssemblyVersion>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

<PropertyGroup>
<FacilityVersion>2.11.0</FacilityVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Faithlife.Analyzers" Version="1.4.0" PrivateAssets="All" IncludeAssets="runtime; build; native; contentfiles; analyzers" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.507" PrivateAssets="All" IncludeAssets="runtime; build; native; contentfiles; analyzers" />
</ItemGroup>

</Project>
20 changes: 20 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="CodeGenCore" Version="0.3.1" />
<PackageVersion Include="Facility.CodeGen.Console" Version="2.11.0" />
<PackageVersion Include="Facility.Definition" Version="2.11.0" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageVersion Include="NUnit" Version="4.1.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageVersion Include="XmlDocMarkdown.Core" Version="2.9.0" />
</ItemGroup>
<ItemGroup>
<GlobalPackageReference Include="Faithlife.Analyzers" Version="1.5.0" />
<GlobalPackageReference Include="NUnit.Analyzers" Version="4.2.0" />
<GlobalPackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556" />
</ItemGroup>
</Project>
3 changes: 2 additions & 1 deletion FacilityMarkdown.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
build.ps1 = build.ps1
.github\workflows\build.yaml = .github\workflows\build.yaml
Directory.Build.props = Directory.Build.props
dotnet-tools.json = dotnet-tools.json
Directory.Packages.props = Directory.Packages.props
global.json = global.json
LICENSE = LICENSE
nuget.config = nuget.config
README.md = README.md
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright 2022 Ed Ball
Copyright 2024 Ed Ball

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
11 changes: 3 additions & 8 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@
$ErrorActionPreference = 'Stop'
Push-Location $PSScriptRoot
try {
if (-not (Test-Path ./tools/bin/Build) -or
(Get-ChildItem ./tools/Build/* | Measure-Object LastWriteTime -Maximum).Maximum -gt
(Get-ChildItem ./tools/bin/Build/* | Measure-Object LastWriteTime -Maximum).Maximum) {
if (Test-Path ./tools/bin/Build) { Remove-Item ./tools/bin/Build -Recurse }
dotnet publish ./tools/Build/Build.csproj --output ./tools/bin/Build --nologo --verbosity quiet
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
}
dotnet ./tools/bin/Build/Build.dll $args
dotnet publish ./tools/Build/Build.csproj --artifacts-path ./artifacts --nologo --verbosity quiet
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
dotnet ./artifacts/publish/Build/release/Build.dll $args
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
}
finally {
Expand Down
6 changes: 6 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"sdk": {
"version": "8.0.100",
"rollForward": "latestFeature"
}
}
3 changes: 2 additions & 1 deletion nuget.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<configuration>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CodeGenCore" Version="0.3.1" />
<PackageReference Include="Facility.Definition" Version="$(FacilityVersion)" />
<PackageReference Include="CodeGenCore" />
<PackageReference Include="Facility.Definition" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Facility.CodeGen.Markdown/MarkdownGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public override CodeGenOutput GenerateOutput(ServiceInfo service)

return new CodeGenOutput(
files: files.Select(x => new CodeGenFile(x.Name, x.Text)).ToList(),
patternsToClean: new[] { new CodeGenPattern($"{service.Name}/*.md", CodeGenUtility.GetCodeGenComment(GeneratorName ?? "")) });
patternsToClean: [new CodeGenPattern($"{service.Name}/*.md", CodeGenUtility.GetCodeGenComment(GeneratorName ?? ""))]);
}

/// <summary>
Expand Down
12 changes: 6 additions & 6 deletions src/fsdgenmd/FsdGenMarkdownApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ public sealed class FsdGenMarkdownApp : CodeGeneratorApp
{
public static int Main(string[] args) => new FsdGenMarkdownApp().Run(args);

protected override IReadOnlyList<string> Description => new[]
{
protected override IReadOnlyList<string> Description =>
[
"Generates Markdown for a Facility Service Definition.",
};
];

protected override IReadOnlyList<string> ExtraUsage => new[]
{
protected override IReadOnlyList<string> ExtraUsage =>
[
" --no-http",
" Omit HTTP documentation.",
" --template <file-path>",
" Override the default template.",
};
];

protected override CodeGenerator CreateGenerator() => new MarkdownGenerator();

Expand Down
2 changes: 1 addition & 1 deletion src/fsdgenmd/fsdgenmd.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Facility.CodeGen.Console" Version="$(FacilityVersion)" />
<PackageReference Include="Facility.CodeGen.Console" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.3.1" />
<PackageReference Include="FluentAssertions" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="NUnit" />
<PackageReference Include="NUnit3TestAdapter" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public void GenerateExampleApiSuccess()
const string fileName = "Facility.CodeGen.Markdown.UnitTests.ConformanceApi.fsd";
var parser = new FsdParser();
var stream = GetType().GetTypeInfo().Assembly.GetManifestResourceStream(fileName);
Assert.IsNotNull(stream);
Assert.That(stream, Is.Not.Null);
using (var reader = new StreamReader(stream!))
service = parser.ParseDefinition(new ServiceDefinitionText(Path.GetFileName(fileName), reader.ReadToEnd()));

Expand All @@ -38,8 +38,8 @@ public void DtoWithExternDataType()
var output = generator.GenerateOutput(service);

var file = output.Files.First(x => x.Name == "TestApi/Test.md");
StringAssert.Contains("\"thing\": (Thing)", file.Text);
StringAssert.Contains("| thing | Thing | This is a description. |", file.Text);
Assert.That(file.Text, Does.Contain("\"thing\": (Thing)"));
Assert.That(file.Text, Does.Contain("| thing | Thing | This is a description. |"));
}

[Test]
Expand All @@ -55,7 +55,7 @@ public void DtoWithExternEnumType()
var output = generator.GenerateOutput(service);

var file = output.Files.First(x => x.Name == "TestApi/Test.md");
StringAssert.Contains("\"kind\": (Kind)", file.Text);
StringAssert.Contains("| kind | Kind | This is a description. |", file.Text);
Assert.That(file.Text, Does.Contain("\"kind\": (Kind)"));
Assert.That(file.Text, Does.Contain("| kind | Kind | This is a description. |"));
}
}
4 changes: 2 additions & 2 deletions tools/Build/Build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Faithlife.Build" Version="5.19.0" />
<PackageReference Include="Faithlife.Build" VersionOverride="5.*" />
</ItemGroup>

</Project>
Loading

0 comments on commit c18f091

Please sign in to comment.