Skip to content

Commit 7a40003

Browse files
authored
Added Testing of assembly attributes (#23)
* Added Testing of assembly attributes * Updated build scripts to force a rebuild of all projects - The tests use nuget pkg resolution and would otherwise use whatever package was built last. * Added targets to PSSPROJ files to allow rebuilds to work * Marked IDE runs as in conclusive for packaged assembly validation. - Since tests resolve NUGET packages it isn't deterministic if the package was created via the IDE or a command line build. - IDE builds are determined by the presence of the environment variable "BuildTime". - This value is set by the build scripts for ALL of the builds so that all binaries produce the same version number for CI builds. (It is ignored for a release build) * Updated GH Action to upload test results even if failed as follow up action that updates a PR comment needs the results. * Removed IDE build detection * It was downright confusing and, obviously now, broke the automated builds - Now requires existence of a generated props file * Moved creation of the generated props file to a distinct script to make it easy to generate once for IDE work. - Directory.Build.Targets contains a check for it and will create an error if not found with a message indicating what to do to resolve the problem. * Added support to extract the CiBuildName from the build environment * Added additional logging to build tasks to aid with diagnostics - These are now low priority messages so that don't normally appear in output * Removed determination of build kind from tests as that's a build script only thing not needed in the tests now. * Adjusted tests to use the build index from the generatedversion.props * Sadly the buildIndex from a time stamp is non-deterministic making it impossible to create tests with an exact match. - Tests would need to adjust to acount for "close enough" - or, the better answer, I think, is that a new deterministic computation method is needed. --------- Co-authored-by: smaillet <25911635+smaillet@users.noreply.github.com>
1 parent ca15d2f commit 7a40003

19 files changed

+541
-386
lines changed

.editorconfig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ csharp_style_unused_value_assignment_preference = discard_variable:suggestion
9494
csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true:silent
9595
dotnet_diagnostic.SA1005.severity = none
9696

97+
# see: https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3920
98+
dotnet_diagnostic.SA1202.severity = none
99+
97100
# Analysis and refactoring rules for Ubiquity.NET
98101
# Description: Code analysis rules for Ubiquity.NET projects
99102

@@ -1408,8 +1411,6 @@ dotnet_diagnostic.SA1200.severity = error
14081411

14091412
dotnet_diagnostic.SA1201.severity = error
14101413

1411-
dotnet_diagnostic.SA1202.severity = error
1412-
14131414
dotnet_diagnostic.SA1203.severity = none
14141415

14151416
dotnet_diagnostic.SA1204.severity = silent

.github/workflows/pr-build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ jobs:
4949
- name: Run Tests
5050
run: ./Invoke-Tests.ps1
5151

52+
# Upload test results even if failed; unless cancelled
5253
- name: Upload Test Results
54+
if: (!cancelled())
5355
uses: actions/upload-artifact@v4
5456
with:
5557
name: Test Results

Build-All.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ try
4949
}
5050

5151
mkdir $buildInfo['NuGetOutputPath'] -ErrorAction SilentlyContinue | Out-Null
52-
53-
dotnet build -c $Configuration 'src/Ubiquity.NET.Versioning.slnx'
52+
.\New-GeneratedVersionProps.ps1 $buildInfo
53+
dotnet build -c $Configuration --no-incremental 'src/Ubiquity.NET.Versioning.slnx'
5454
}
5555
catch
5656
{

Directory.Build.props

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,15 @@
11
<Project>
2-
<!--
3-
For local builds of this solution in IDE ONLY
4-
FORCE the Build Versioning Info as there is no lib to rely on; (This repo builds it!) and the automated build
5-
scripts aren't used to build from within an IDE. Automated builds/Command line builds use the PowerShell
6-
scripts to setup the variables for use in the build. This, handles the case of builds directly from the IDE
7-
so that can complete a compilation.
8-
9-
Though, it should ONLY be used for local testing. Running the scripts locally from a command line is
10-
the final best test of a given set of changes to the source.
11-
-->
12-
<PropertyGroup Condition="'$(BuildingInsideVisualStudio)'=='true'">
13-
<!-- File Version for v5.0.0-alpha (See: https://csemver.org/playground/site/#/) [1.27597.27630.61954]-->
14-
<!-- CiBuildIndex => UInt16.MaxValue -->
15-
<!-- +1 to revision to account for CI build -->
16-
<FileVersion>1.27597.27630.61955</FileVersion>
17-
<PackageVersion>5.0.0-a.ci-4294967295.IDE</PackageVersion>
18-
<ProductVersion>5.0.0-alpha.ci-4294967295.IDE</ProductVersion>
19-
<AssemblyVersion>$(FileVersion)</AssemblyVersion>
20-
<InformationalVersion>$(ProductVersion)</InformationalVersion>
2+
<PropertyGroup>
3+
<GeneratedVersionProps>$(MSBuildThisFileDirectory)GeneratedVersion.props</GeneratedVersionProps>
214
</PropertyGroup>
22-
235
<!--
24-
For command line builds (including official PR/CI/Release automated builds) use the props file
25-
generated by the scripts.
6+
Import the generated version information for this build; Projects in this repo cannot use themselves
7+
to generate the version information. Tests VALIDATE that the actual built packages do contain
8+
expected values though so the duplication of computing the versioning is verified to produce the same
9+
results, at least for the packages tested. The existence is tested again in the targets file and reported
10+
as an error if not present.
2611
-->
27-
<Import Condition="'$(BuildingInsideVisualStudio)'!='true' AND '$(MSBuildProjectExtension)'!='.pssproj'" Project="GeneratedVersion.props" />
12+
<Import Condition="Exists('$(GeneratedVersionProps)')" Project="$(GeneratedVersionProps)" />
2813

2914
<!--
3015
Description:

Directory.Build.targets

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@
3838
where it belongs. For a good explanation of this problem see: https://rehansaeed.com/the-problem-with-csharp-10-implicit-usings/.
3939
For an explanation of the benefits of the language feature see: https://www.hanselman.com/blog/implicit-usings-in-net-6
4040
-->
41-
<Error Condition="'$(ImplicitUsings)'!='disable'" Text="$(MSBuildProjectFile) - Projects in this repository MUST NOT have ImplicitUsings enabled!"/>
41+
<Error Condition="'$(ImplicitUsings)'!='disable'" Code="REPO001" Text="$(MSBuildProjectFile) - Projects in this repository MUST NOT have ImplicitUsings enabled!"/>
4242

43-
<Warning Condition="'$(BuildingInsideVisualStudio)' == 'true'" Text="!!! This is an IDE build. Version numbering is 'FAKED' !!!"/>
43+
<!--Verify that GeneratedVersion.props exists; and produce a, hopefully, informative message on how to create it if it doesn't -->
44+
<Error Condition="!Exists('$(GeneratedVersionProps)')" Code="REPO002" Text="$(GeneratedVersionProps) file does not exist, it must be created by `New-GeneratedBersionProps.ps1` BEFORE building in the IDE for consistent results"/>
4445
</Target>
4546
</Project>

0 commit comments

Comments
 (0)