Skip to content
Merged

Dev #12

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
18 changes: 13 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,25 @@ jobs:
- name: Set dotnet version
id: dotnet-version
run: |
$version = [version]::new('${{ steps.setup-dotnet.outputs.dotnet-version }}')
$str = '${{ steps.setup-dotnet.outputs.dotnet-version }}'.Split('-')[0]
$version = [version]::new($str)
$label = 'net{0}{1}' -f $version.Major, $version.Minor
echo $label

"label=$label" >> $env:GITHUB_OUTPUT

- name: Run tests
run: dotnet.exe test .\src\UserRights.sln --configuration Release --runtime win-x64
- name: Run CLI tests
run: |
cd .\src
dotnet.exe test --project .\Tests.Cli\Tests.Cli.csproj --configuration Debug --runtime win-x64 --output Detailed

- name: Run Application tests
run: |
cd .\src
dotnet.exe test --project .\Tests.Application\Tests.Application.csproj --configuration Debug --runtime win-x64 --output Detailed

- name: Clean solution
run: dotnet.exe clean .\src\UserRights.sln --configuration Release
run: dotnet.exe clean .\src\UserRights.slnx --configuration Debug

- name: Publish runtime-dependent release
run: dotnet.exe publish .\src\UserRights\UserRights.csproj --configuration Release --runtime win-x64 --no-self-contained --output .\publish
Expand All @@ -58,7 +66,7 @@ jobs:
if-no-files-found: error

- name: Clean solution
run: dotnet.exe clean .\src\UserRights.sln --configuration Release
run: dotnet.exe clean .\src\UserRights.slnx --configuration Release

- name: Publish self-contained release
run: dotnet.exe publish .\src\UserRights\UserRights.csproj --configuration Release --runtime win-x64 --self-contained --output .\publish-packed -p:PublishSingleFile=true -p:PublishReadyToRun=true
Expand Down
96 changes: 96 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Unit Tests
on:
push:
branches-ignore: [master]
pull_request:
branches: [master]
workflow_dispatch:

env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_GENERATE_ASPNET_CERTIFICATE: false
DOTNET_NOLOGO: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true

jobs:
unit-tests:
runs-on: windows-latest
permissions:
pull-requests: write
contents: read

steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Setup dotnet
id: setup-dotnet
uses: actions/setup-dotnet@v5
with:
global-json-file: src/global.json

- name: Setup report generator
run: dotnet.exe tool install -g dotnet-reportgenerator-globaltool

- name: Run CLI tests
run: |
cd src
dotnet.exe test `
--project .\Tests.Cli\Tests.Cli.csproj `
--configuration Debug `
--runtime win-x64 `
--output Detailed `
--diagnostic `
--diagnostic-output-directory diags `
--report-trx `
--coverage `
--coverage-settings .\testconfig.json

- name: Run Application tests
run: |
cd src
dotnet.exe test `
--project .\Tests.Application\Tests.Application.csproj `
--configuration Debug `
--runtime win-x64 `
--output Detailed `
--diagnostic `
--diagnostic-output-directory diags `
--report-trx `
--coverage `
--coverage-settings .\testconfig.json

- name: Run report generator
if: always()
run: |
reportgenerator.exe `
-reports:**/*.cobertura.xml `
-targetdir:${{ github.workspace }}/coveragereport `
'-reporttypes:Cobertura;HtmlInline;MarkdownSummary' `
'-title:Code Coverage' `
-tag:${{ github.run_number }}_${{ github.run_id }}

- name: Upload test result artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
path: |
${{ github.workspace }}/**/diags/**/*
${{ github.workspace }}/**/TestResults/**/*
if-no-files-found: error

- name: Upload coverage report artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-report
path: ${{ github.workspace }}/**/coveragereport/**/*
if-no-files-found: error

- name: Add coverage pr comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
path: ${{ github.workspace }}/coveragereport/Summary.md
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.idea/
.vs/
src/TestResults/**
**/bin/
**/obj/
*.user
46 changes: 22 additions & 24 deletions src/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -92,30 +92,28 @@ resharper_object_creation_when_type_not_evident = target_typed
resharper_redundant_name_qualifier_highlighting = none

# Analyzer inspection severities
dotnet_diagnostic.IDE0001.severity = none
dotnet_diagnostic.IDE0003.severity = none # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0003-ide0009
dotnet_diagnostic.IDE0039.severity = none
dotnet_diagnostic.IDE0046.severity = none
dotnet_diagnostic.IDE0058.severity = none

dotnet_diagnostic.CA1031.severity = none
dotnet_diagnostic.CA1515.severity = none
dotnet_diagnostic.CA1822.severity = none
dotnet_diagnostic.CA1848.severity = none

dotnet_diagnostic.MA0003.severity = none
dotnet_diagnostic.MA0007.severity = none
dotnet_diagnostic.MA0015.severity = none
dotnet_diagnostic.MA0038.severity = none
dotnet_diagnostic.MA0041.severity = none
dotnet_diagnostic.MA0051.severity = none

dotnet_diagnostic.SA1101.severity = none
dotnet_diagnostic.SA1118.severity = none
dotnet_diagnostic.SA1309.severity = none
dotnet_diagnostic.SA1312.severity = none
dotnet_diagnostic.SA1413.severity = none
dotnet_diagnostic.SA1633.severity = none
dotnet_diagnostic.IDE0001.severity = none # Simplify name.
dotnet_diagnostic.IDE0003.severity = none # Remove this or Me qualification.
dotnet_diagnostic.IDE0039.severity = none # Use local function instead of lambda.
dotnet_diagnostic.IDE0046.severity = none # Use conditional expression for return.
dotnet_diagnostic.IDE0058.severity = none # Remove unnecessary expression value.

dotnet_diagnostic.CA1515.severity = none # Consider making public types internal.
dotnet_diagnostic.CA1822.severity = none # Mark members as static.
dotnet_diagnostic.CA1848.severity = none # Use the LoggerMessage delegates.
dotnet_diagnostic.CA1873.severity = none # Evaluation of this argument may be expensive and unnecessary if logging is disabled.

dotnet_diagnostic.MA0003.severity = none # Add parameter name to improve readability.
dotnet_diagnostic.MA0007.severity = none # Add a comma after the last value.
dotnet_diagnostic.MA0051.severity = none # Method is too long.
dotnet_diagnostic.MA0177.severity = none # Use single-line XML comment syntax when possible.

dotnet_diagnostic.SA1101.severity = none # Prefix local calls with this.
dotnet_diagnostic.SA1118.severity = none # Parameter must not span multiple lines.
dotnet_diagnostic.SA1309.severity = none # Field names must not begin with underscore.
dotnet_diagnostic.SA1312.severity = none # Variable names must begin with lower case letter.
dotnet_diagnostic.SA1413.severity = none # Use trailing commas in multi line initializers.
dotnet_diagnostic.SA1633.severity = none # File must have header.

#### C# Coding Conventions ####
[*.cs]
Expand Down
17 changes: 10 additions & 7 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
<Product>Windows User Rights Assignment Utility</Product>
<Description>Utility for managing user right assignments.</Description>
<Copyright>Copyright © Joseph L. Casale 2022</Copyright>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.217">
<PackageReference Include="Meziantou.Analyzer">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers.Unstable" Version="1.2.0.556">
<PackageReference Include="StyleCop.Analyzers.Unstable">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -24,11 +25,13 @@
</Exec>

<PropertyGroup>
<PatternGitTag>^v((.+)-(\d+)-g(.+))</PatternGitTag>
<AssemblyVersion>$([System.Text.RegularExpressions.Regex]::Match($(GitTag), $(PatternGitTag)).Groups[2].Value)</AssemblyVersion>
<FileVersion>$([System.Text.RegularExpressions.Regex]::Match($(GitTag), $(PatternGitTag)).Groups[2].Value)</FileVersion>
<Version>$([System.Text.RegularExpressions.Regex]::Match($(GitTag), $(PatternGitTag)).Groups[2].Value)</Version>
<InformationalVersion>$([System.Text.RegularExpressions.Regex]::Match($(GitTag), $(PatternGitTag)).Groups[1].Value)</InformationalVersion>
<PatternGitTag>^v(((\d+\.\d+\.\d+\.\d+)(?:-[a-z]+\.\d+)?)-(\d+-g.+))</PatternGitTag>
<AssemblyVersion>$([System.Text.RegularExpressions.Regex]::Match($(GitTag), $(PatternGitTag)).Groups[3].Value)</AssemblyVersion>
<FileVersion>$([System.Text.RegularExpressions.Regex]::Match($(GitTag), $(PatternGitTag)).Groups[3].Value)</FileVersion>
<Version>$([System.Text.RegularExpressions.Regex]::Match($(GitTag), $(PatternGitTag)).Groups[3].Value)</Version>
<FullVersion>$([System.Text.RegularExpressions.Regex]::Match($(GitTag), $(PatternGitTag)).Groups[2].Value)</FullVersion>
<GitCommitInfo>$([System.Text.RegularExpressions.Regex]::Match($(GitTag), $(PatternGitTag)).Groups[4].Value)</GitCommitInfo>
<InformationalVersion>$(FullVersion)+$(GitCommitInfo)</InformationalVersion>
</PropertyGroup>

<Message Text="*** InformationalVersion $(InformationalVersion)" Importance="high" />
Expand Down
27 changes: 27 additions & 0 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="CsvHelper" Version="33.1.0" />
<PackageVersion Include="Meziantou.Analyzer" Version="2.0.253" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Ini" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Debug" Version="10.0.0" />
<PackageVersion Include="Microsoft.Windows.CsWin32" Version="0.3.248" />
<PackageVersion Include="Moq" Version="4.20.72" />
<PackageVersion Include="Moq.Analyzers" Version="0.3.1" />
<PackageVersion Include="Serilog" Version="4.3.0" />
<PackageVersion Include="Serilog.Enrichers.Environment" Version="3.0.1" />
<PackageVersion Include="Serilog.Enrichers.GlobalLogContext" Version="3.0.0" />
<PackageVersion Include="Serilog.Enrichers.Process" Version="3.0.0" />
<PackageVersion Include="Serilog.Expressions" Version="5.0.0" />
<PackageVersion Include="Serilog.Extensions.Logging" Version="9.0.2" />
<PackageVersion Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageVersion Include="Serilog.Sinks.EventLog" Version="4.0.0" />
<PackageVersion Include="StyleCop.Analyzers.Unstable" Version="1.2.0.556" />
<PackageVersion Include="System.CommandLine" Version="2.0.0" />
</ItemGroup>
</Project>
9 changes: 9 additions & 0 deletions src/Tests.Application/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[*.cs]
dotnet_diagnostic.CA1707.severity = none # Identifiers should not contain underscores.

[UserRightsManagerPrincipalTests.cs]
dotnet_diagnostic.SA1515.severity = none # Single-line comment should be preceded by blank line.

[UserRightsManagerPrivilegeTests.cs]
dotnet_diagnostic.SA1515.severity = none # Single-line comment should be preceded by blank line.
dotnet_diagnostic.MA0110.severity = none # Use the Regex source generator.
25 changes: 0 additions & 25 deletions src/Tests.Application/AdminOnlyFactAttribute.cs

This file was deleted.

25 changes: 0 additions & 25 deletions src/Tests.Application/LsaUserRightsConnectTests.cs

This file was deleted.

26 changes: 0 additions & 26 deletions src/Tests.Application/LsaUserRightsDisposeTests.cs

This file was deleted.

Loading