Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to net7.0 and use latest Bicep versions #51

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,23 @@ jobs:
run: dotnet publish --configuration release --self-contained true -p:AssemblyVersion=${{ steps.get-version.outputs.version }} -p:Version=${{ steps.get-version.outputs.version }} -p:PublishTrimmed=true -p:PublishSingleFile=true -p:TrimmerDefaultAction=copyused -p:SuppressTrimAnalysisWarnings=true -r ${{ matrix.rid }} ./src/BicepDocs.Cli/BicepDocs.Cli.csproj
- name: Rename binary
if: matrix.rid != 'win-x64'
run: mv ./src/BicepDocs.Cli/bin/release/net6.0/${{ matrix.rid }}/publish/bicepdocs ./src/BicepDocs.Cli/bin/release/net6.0/${{ matrix.rid }}/publish/bicepdocs-${{ matrix.rid }}
run: mv ./src/BicepDocs.Cli/bin/release/net7.0/${{ matrix.rid }}/publish/bicepdocs ./src/BicepDocs.Cli/bin/release/net7.0/${{ matrix.rid }}/publish/bicepdocs-${{ matrix.rid }}
- name: Rename binary (win)
if: matrix.rid == 'win-x64'
run: mv ./src/BicepDocs.Cli/bin/release/net6.0/${{ matrix.rid }}/publish/bicepdocs.exe ./src/BicepDocs.Cli/bin/release/net6.0/${{ matrix.rid }}/publish/bicepdocs-${{ matrix.rid }}.exe
run: mv ./src/BicepDocs.Cli/bin/release/net7.0/${{ matrix.rid }}/publish/bicepdocs.exe ./src/BicepDocs.Cli/bin/release/net7.0/${{ matrix.rid }}/publish/bicepdocs-${{ matrix.rid }}.exe
- name: Upload BicepDocs
if: matrix.rid != 'win-x64'
uses: actions/upload-artifact@v3
with:
name: bicepdocs-${{ matrix.rid }}
path: ./src/BicepDocs.Cli/bin/release/net6.0/${{ matrix.rid }}/publish/bicepdocs-${{ matrix.rid }}
path: ./src/BicepDocs.Cli/bin/release/net7.0/${{ matrix.rid }}/publish/bicepdocs-${{ matrix.rid }}
if-no-files-found: error
- name: Upload BicepDocs
if: matrix.rid == 'win-x64'
uses: actions/upload-artifact@v3
with:
name: bicepdocs-${{ matrix.rid }}
path: ./src/BicepDocs.Cli/bin/release/net6.0/${{ matrix.rid }}/publish/bicepdocs-${{ matrix.rid }}.exe
path: ./src/BicepDocs.Cli/bin/release/net7.0/${{ matrix.rid }}/publish/bicepdocs-${{ matrix.rid }}.exe
if-no-files-found: error
release:
name: Create Release
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ jobs:
- name: Run tests
run: dotnet test --configuration release src/BicepDocs.sln
- name: Build binary
run: dotnet publish --configuration release --self-contained true -p:PublishTrimmed=true -p:PublishSingleFile=true -p:TrimmerDefaultAction=copyused -p:SuppressTrimAnalysisWarnings=true -r ${{ matrix.rid }} ./src/BicepDocs.Cli/BicepDocs.Cli.csproj
run: dotnet publish --configuration release --self-contained true -p:PublishTrimmed=true -p:PublishSingleFile=true -p:SuppressTrimAnalysisWarnings=true -r ${{ matrix.rid }} ./src/BicepDocs.Cli/BicepDocs.Cli.csproj
- name: Test samples
if: matrix.rid != 'win-x64'
run: |
mv ./src/BicepDocs.Cli/bin/release/net6.0/${{ matrix.rid }}/publish/bicepdocs .
mv ./src/BicepDocs.Cli/bin/release/net7.0/${{ matrix.rid }}/publish/bicepdocs .
./bicepdocs generate filesystem \
--folderPath docs/formatters/examples/inputs \
--out ./docs/formatters/examples/generated-output/markdown \
Expand All @@ -50,5 +50,5 @@ jobs:
- name: Test samples (win)
if: matrix.rid == 'win-x64'
run: |
mv .\src\BicepDocs.Cli\bin\release\net6.0\${{ matrix.rid }}\publish\bicepdocs.exe .
mv .\src\BicepDocs.Cli\bin\release\net7.0\${{ matrix.rid }}\publish\bicepdocs.exe .
.\bicepdocs.exe generate filesystem --folderPath docs\formatters\examples\inputs --out .\docs\formatters\examples\generated-output\markdown --config docs\example-config.yml --formatter markdown
5 changes: 3 additions & 2 deletions src/BicepDocs.Cli/BicepDocs.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<RootNamespace>LandingZones.Tools.BicepDocs.Cli</RootNamespace>
<StartupObject>LandingZones.Tools.BicepDocs.Cli.Program</StartupObject>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Authors>Joachim Dalen</Authors>
Expand All @@ -15,10 +15,11 @@
<RepositoryType>git</RepositoryType>
<PackageTags>bicep documentation azure arm</PackageTags>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<TrimMode>partial</TrimMode>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Bicep.Decompiler" Version="0.14.85" />
<PackageReference Include="Azure.Bicep.Decompiler" Version="0.23.1" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="System.CommandLine.Hosting" Version="0.4.0-alpha.22272.1" />
Expand Down
4 changes: 2 additions & 2 deletions src/BicepDocs.Core.UnitTests/BicepDocs.Core.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<PropertyGroup>
<AssemblyName>LandingZones.Tools.BicepDocs.Core.UnitTests</AssemblyName>
<RootNamespace>LandingZones.Tools.BicepDocs.Core.UnitTests</RootNamespace>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Bicep.Core" Version="0.14.85" />
<PackageReference Include="Azure.Bicep.Core" Version="0.23.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
Expand Down
6 changes: 2 additions & 4 deletions src/BicepDocs.Core.UnitTests/ResourceLinkBuilderTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Collections.Immutable;
using Bicep.Core.Resources;

namespace LandingZones.Tools.BicepDocs.Core.UnitTests;
Expand All @@ -10,14 +9,13 @@ public class ResourceLinkBuilderTests

[TestMethod]
[DataRow(
"Microsoft.Web", "microsoft.web,sites", "2018-11-01",
"Microsoft.Web", "microsoft.web/sites", "2018-11-01",
"microsoft.web/2018-11-01/sites",
DisplayName = "Parses one level resource"
)]
public void TestMethod1(string provider, string resource, string apiVersion, string expected)
{
var resourceParts = resource.Split(",").ToImmutableArray();
var resourceRef = new ResourceTypeReference(resourceParts, apiVersion);
var resourceRef = new ResourceTypeReference(resource, apiVersion);
var generatedLink = ResourceLinkBuilder.GetResourceUrl(resourceRef);
Assert.AreEqual($"{Base}{expected}", generatedLink);
}
Expand Down
4 changes: 2 additions & 2 deletions src/BicepDocs.Core/BicepDocs.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
<PropertyGroup>
<AssemblyName>LandingZones.Tools.BicepDocs.Core</AssemblyName>
<RootNamespace>LandingZones.Tools.BicepDocs.Core</RootNamespace>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Bicep.Decompiler" Version="0.14.85" />
<PackageReference Include="Azure.Bicep.Decompiler" Version="0.23.1" />
<PackageReference Include="System.CommandLine.Hosting" Version="0.4.0-alpha.22272.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="System.IO.Abstractions.TestingHelpers" Version="20.0.4" />
Expand Down
39 changes: 23 additions & 16 deletions src/BicepDocs.Core/Installer.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Collections.Immutable;
using System.IO.Abstractions;
using System.IO.Abstractions.TestingHelpers;
using Bicep.Core;
Expand All @@ -10,33 +11,39 @@
using Bicep.Core.Registry;
using Bicep.Core.Registry.Auth;
using Bicep.Core.Semantics.Namespaces;
using Bicep.Core.TypeSystem;
using Bicep.Core.TypeSystem.Az;
using Bicep.Core.Utils;
using Bicep.Decompiler;
using LandingZones.Tools.BicepDocs.Core.Abstractions;
using LandingZones.Tools.BicepDocs.Core.Services;
using Microsoft.Extensions.DependencyInjection;
using BicepConfigurationManager = Bicep.Core.Configuration.ConfigurationManager;


namespace LandingZones.Tools.BicepDocs.Core;

public class EmptyModuleRegistryProvider : IArtifactRegistryProvider
{
public ImmutableArray<IArtifactRegistry> Registries(Uri _) => ImmutableArray<IArtifactRegistry>.Empty;
}

public static class Installer
{
public static IServiceCollection AddBicepCore(this IServiceCollection services) => services
.AddScoped<INamespaceProvider, DefaultNamespaceProvider>()
.AddScoped<IAzResourceTypeLoader, AzResourceTypeLoader>()
.AddScoped<IContainerRegistryClientFactory, ContainerRegistryClientFactory>()
.AddScoped<ITemplateSpecRepositoryFactory, TemplateSpecRepositoryFactory>()
.AddScoped<IModuleDispatcher, ModuleDispatcher>()
.AddScoped<IModuleRegistryProvider, DefaultModuleRegistryProvider>()
.AddScoped<ITokenCredentialFactory, TokenCredentialFactory>()
.AddScoped<IFileResolver, FileResolver>()
.AddScoped<IFileSystem, MockFileSystem>()
.AddScoped<IConfigurationManager, BicepConfigurationManager>()
.AddScoped<IApiVersionProviderFactory, ApiVersionProviderFactory>()
.AddScoped<IBicepAnalyzer, LinterAnalyzer>()
.AddScoped<IFeatureProviderFactory, FeatureProviderFactory>()
.AddScoped<ILinterRulesProvider, LinterRulesProvider>()
.AddScoped<BicepCompiler>();
.AddSingleton<IResourceTypeLoader, AzResourceTypeLoader>()
.AddSingleton<IResourceTypeLoaderFactory, AzResourceTypeLoaderFactory>()
.AddSingleton<INamespaceProvider, DefaultNamespaceProvider>()
.AddSingleton<IModuleDispatcher, ModuleDispatcher>()
.AddSingleton<IArtifactRegistryProvider, EmptyModuleRegistryProvider>()
.AddSingleton<ITokenCredentialFactory, TokenCredentialFactory>()
.AddSingleton<IFileResolver, FileResolver>()
.AddSingleton<IEnvironment, Bicep.Core.Utils.Environment>()
.AddSingleton<IFileSystem, MockFileSystem>()
.AddSingleton<IConfigurationManager, ConfigurationManager>()
.AddSingleton<IBicepAnalyzer, LinterAnalyzer>()
.AddSingleton<IFeatureProviderFactory, FeatureProviderFactory>()
.AddSingleton<ILinterRulesProvider, LinterRulesProvider>()
.AddSingleton<BicepCompiler>();

public static IServiceCollection AddBicepDecompiler(this IServiceCollection services) => services
.AddScoped<BicepDecompiler>();
Expand Down
2 changes: 1 addition & 1 deletion src/BicepDocs.Core/Services/BicepFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public static string FormatBicepCode(string input)
var parser = new Parser(input);
var programSyntax = parser.Program();
var options = new PrettyPrintOptions(NewlineOption.Auto, IndentKindOption.Space, 2, false);
return PrettyPrinter.PrintProgram(programSyntax, options);
return PrettyPrinter.PrintProgram(programSyntax, options, parser.LexingErrorLookup, parser.ParsingErrorLookup);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<AssemblyName>LandingZones.Tools.BicepDocs.Destination.FileSystem.UnitTests</AssemblyName>
<RootNamespace>LandingZones.Tools.BicepDocs.Destination.FileSystem.UnitTests</RootNamespace>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<AssemblyName>LandingZones.Tools.BicepDocs.Destination.FileSystem</AssemblyName>
<RootNamespace>LandingZones.Tools.BicepDocs.Destination.FileSystem</RootNamespace>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<AssemblyName>LandingZones.Tools.BicepDocs.Formatter.Docusaurus.UnitTests</AssemblyName>
<RootNamespace>LandingZones.Tools.BicepDocs.Formatter.Docusaurus.UnitTests</RootNamespace>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<AssemblyName>LandingZones.Tools.BicepDocs.Formatter.Docusaurus</AssemblyName>
<RootNamespace>LandingZones.Tools.BicepDocs.Formatter.Docusaurus</RootNamespace>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<AssemblyName>LandingZones.Tools.BicepDocs.Formatter.Markdown.UnitTests</AssemblyName>
<RootNamespace>LandingZones.Tools.BicepDocs.Formatter.Markdown.UnitTests</RootNamespace>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,14 @@ public void BuildResources_Input_BuildsCorrectly()
{
var expected = @"## Resources

- [Microsoft.Web/sites/2022-12-18](https://learn.microsoft.com/en-us/azure/templates/microsoft.web/2022-12-18/sites)".ToPlatformLineEndings() + Environment.NewLine;
- [Microsoft.Web/sites/2022-12-18](https://learn.microsoft.com/en-us/azure/templates/microsoft.web/2022-12-18/sites)"
.ToPlatformLineEndings() + Environment.NewLine;
var resources = new List<ParsedResource>
{
new("Microsoft.Web/sites/2022-12-18", "Microsoft.Web", "sites")
{
DocUrl = ResourceLinkBuilder.GetResourceUrl(new ResourceTypeReference(new List<string>
{
"microsoft.web",
"sites"
}.ToImmutableArray(), "2022-12-18"))
DocUrl = ResourceLinkBuilder.GetResourceUrl(new ResourceTypeReference("microsoft.web/sites",
"2022-12-18"))
}
}.ToImmutableList();

Expand All @@ -47,24 +45,19 @@ public void BuildResources_MultipleOfSame_BuildsSingle()
{
var expected = @"## Resources

- [Microsoft.Web/sites/2022-12-18](https://learn.microsoft.com/en-us/azure/templates/microsoft.web/2022-12-18/sites)".ToPlatformLineEndings() + Environment.NewLine;
- [Microsoft.Web/sites/2022-12-18](https://learn.microsoft.com/en-us/azure/templates/microsoft.web/2022-12-18/sites)"
.ToPlatformLineEndings() + Environment.NewLine;
var resources = new List<ParsedResource>
{
new("Microsoft.Web/sites/2022-12-18", "Microsoft.Web", "sites")
{
DocUrl = ResourceLinkBuilder.GetResourceUrl(new ResourceTypeReference(new List<string>
{
"microsoft.web",
"sites"
}.ToImmutableArray(), "2022-12-18"))
DocUrl = ResourceLinkBuilder.GetResourceUrl(new ResourceTypeReference("microsoft.web/sites",
"2022-12-18"))
},
new("Microsoft.Web/sites/2022-12-18", "Microsoft.Web", "sites")
{
DocUrl = ResourceLinkBuilder.GetResourceUrl(new ResourceTypeReference(new List<string>
{
"microsoft.web",
"sites"
}.ToImmutableArray(), "2022-12-18"))
DocUrl = ResourceLinkBuilder.GetResourceUrl(new ResourceTypeReference("microsoft.web/sites",
"2022-12-18"))
}
}.ToImmutableList();

Expand All @@ -83,7 +76,8 @@ public async Task BuildResources_InputTemplate_BuildsSingle()
{
var expected = @"## Resources

- [Microsoft.Resources/resourceGroups@2021-01-01](https://learn.microsoft.com/en-us/azure/templates/microsoft.resources/2021-01-01/resourcegroups)".ToPlatformLineEndings() + Environment.NewLine;
- [Microsoft.Resources/resourceGroups@2021-01-01](https://learn.microsoft.com/en-us/azure/templates/microsoft.resources/2021-01-01/resourcegroups)"
.ToPlatformLineEndings() + Environment.NewLine;

const string template = @"resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-01-01' = {
name: resourceGroupName
Expand Down Expand Up @@ -160,11 +154,7 @@ public void BuildReferencedResources_Input_BuildsCorrectly()
Name = "siteOne",
Scope = "subscription()",
IsExisting = true,
DocUrl = ResourceLinkBuilder.GetResourceUrl(new ResourceTypeReference(new List<string>
{
"microsoft.web",
"sites"
}.ToImmutableArray(), "2022-12-18"))
DocUrl = ResourceLinkBuilder.GetResourceUrl(new ResourceTypeReference("microsoft.web/sites", "2022-12-18"))
}
}.ToImmutableList();

Expand Down Expand Up @@ -194,22 +184,14 @@ public void BuildReferencedResources_MultipleOfSame_BuildsAll()
Name = "siteOne",
Scope = "subscription()",
IsExisting = true,
DocUrl = ResourceLinkBuilder.GetResourceUrl(new ResourceTypeReference(new List<string>
{
"microsoft.web",
"sites"
}.ToImmutableArray(), "2022-12-18"))
DocUrl = ResourceLinkBuilder.GetResourceUrl(new ResourceTypeReference("microsoft.web/sites", "2022-12-18"))
},
new("Microsoft.Web/sites/2022-12-18", "Microsoft.Web", "sites")
{
Name = "siteTwo",
Scope = "subscription()",
IsExisting = true,
DocUrl = ResourceLinkBuilder.GetResourceUrl(new ResourceTypeReference(new List<string>
{
"microsoft.web",
"sites"
}.ToImmutableArray(), "2022-12-18"))
DocUrl = ResourceLinkBuilder.GetResourceUrl(new ResourceTypeReference("microsoft.web/sites", "2022-12-18"))
}
}.ToImmutableList();

Expand All @@ -230,7 +212,8 @@ public async Task BuildReferencedResources_InputTemplate_BuildsSingle()

| Provider | Name | Scope |
| --- | --- | --- |
| Microsoft.Resources/resourceGroups@2021-01-01 | `resourceGroupName` | - |".ToPlatformLineEndings() + Environment.NewLine;
| Microsoft.Resources/resourceGroups@2021-01-01 | `resourceGroupName` | - |".ToPlatformLineEndings() +
Environment.NewLine;

const string template = @"resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-01-01' existing = {
name: resourceGroupName
Expand Down Expand Up @@ -303,4 +286,4 @@ public async Task BuildReferencedResources_NoExistingResources_DoesNotGenerate()
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<AssemblyName>LandingZones.Tools.BicepDocs.Formatter.Markdown</AssemblyName>
<RootNamespace>LandingZones.Tools.BicepDocs.Formatter.Markdown</RootNamespace>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand All @@ -13,7 +13,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Markdig" Version="0.33.0" />
<PackageReference Include="Markdig" Version="0.34.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<AssemblyName>LandingZones.Tools.BicepDocs.Source.FileSystem.UnitTests</AssemblyName>
<RootNamespace>LandingZones.Tools.BicepDocs.Source.FileSystem.UnitTests</RootNamespace>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
Expand Down
Loading