Skip to content

git.properties: support transitive references from shared projects - #1724

Open
bart-vmware wants to merge 2 commits into
mainfrom
gitproperties-allow-transitive
Open

git.properties: support transitive references from shared projects#1724
bart-vmware wants to merge 2 commits into
mainfrom
gitproperties-allow-transitive

Conversation

@bart-vmware

Copy link
Copy Markdown
Member

Summary

Steeltoe.Management.GitProperties.Build can now be referenced from a shared project (like an Aspire ServiceDefaults) and made transitive, so every host app referencing that shared project gets its own git.properties automatically — without adding the package to each host app individually. The test suite was also overhauled to consume the package the same way a real application does, most notably by introducing a fake Steeltoe.Management.Endpoint package so tests exercise the real auto-detection path instead of bypassing it.

Production change

  • The package's .targets file is now packed only into buildTransitive\ (previously build\).
  • PackageReadme.md:
    • States explicitly that the package adds no runtime dependency to the application.
    • Documents that the "dirty" check is never cached: each project re-runs git status on every build, even though commit/branch/tag info comes from the shared cache.
    • Adds a new "Using this package in a shared project" section explaining how to install the package once in a shared project (e.g. ServiceDefaults) with PrivateAssets="none" and GenerateGitProperties=false, so host apps referencing that shared project pick up the transitive reference and generate their own git.properties via the default auto setting, including a ServiceDefaults.csproj example and a caution block about the added per-project git cost.
    • Removes the old "Build-time only" and "Performance impact" bullets from "Good to know" (superseded by the points above).

Test infrastructure changes

Fake Steeltoe.Management.Endpoint package

A new FakeSteeltoeManagementEndpointPackager builds and packs an empty, fake Steeltoe.Management.Endpoint package into the same isolated local NuGet feed used for Steeltoe.Management.GitProperties.Build. It's packed once per test session.

The default TestApp now references both the real packed Steeltoe.Management.GitProperties.Build package and this fake Steeltoe.Management.Endpoint package via genuine PackageReferences, and no longer forces GenerateGitProperties=true. This makes it match the shape of a real Steeltoe host app and exercises the actual auto-detection code path (which looks for a Steeltoe.Management.Endpoint reference in the dependency graph) instead of sidestepping it. Several AutoDetection and SharedCache tests were simplified to use repository.TestApp directly, or to reference Workspace.FakeEndpointPackageReference, instead of building a bespoke dependency/consumer project pair per test.

Packing and NuGet isolation

  • GitPropertiesSourcePackager now dotnet builds the real Steeltoe.Management.GitProperties.Build project directly from its source location in the repository (instead of first copying the source tree and shared build-infrastructure files like shared.props, stylecop.json, PackageReadme.md, etc. into a temporary directory) and moves the resulting .nupkg into a session-scoped NuGet feed directory.
  • PackGitPropertiesSourceOnceFixture (renamed from CompileGitPropertiesBuildOnceFixture) creates one session directory per test run, containing feed and packages subdirectories, and packs both the real and fake packages into it once via [assembly: AssemblyFixture].
  • Every test project's nuget.config now also pins globalPackagesFolder to the session's packages directory, so package extraction is isolated per test run instead of relying on the machine-wide NuGet cache.
  • Every test now consumes Steeltoe.Management.GitProperties.Build via a real PackageReference restored from that feed. The previous dedicated PublishPush/NuGetPackageConsumedViaPackageReferenceGeneratesGitPropertiesTest (which built and restored an isolated one-off package/consumer to prove this) was removed since it's now implicit in every other test.

Temp-directory handling

  • ProcessRunner now redirects the TMP/TEMP/TMPDIR environment variables of every spawned dotnet process to a session-scoped temp directory. This is a workaround for Stop using the default temp directory and temp file paths dotnet/msbuild#6219, where MSBuild/NuGet processes otherwise leave behind stray directories directly under the machine's real temp folder.
  • Each test project now lives under tests\<TestClassName> inside the single session directory, rather than each test creating its own top-level directory directly under the machine temp folder.
  • Cleanup of read-only attributes on disposal now only recurses into .git directories, instead of walking every file in the test directory (including bin/obj output), since only files under .git are ever marked read-only.

GitRepository API

Collapsed from several narrowly-named, single-purpose methods (AddProjectAsync, AddDependencyProjectAsync, AddTestAppReferencingAsync, AddPackageConsumerProjectAsync) into two general, composable ones:

  • AddTestAppAsync(name, packageReferences, projectReferences, targetFrameworks)
  • AddTestLibraryAsync(name, generateGitProperties, packageReferences, projectReferences)

Both build their project file via the new ProjectFileBuilder, PackageReference (PackageId, Version, PrivateAssets), and ProjectReference (ProjectName) types, replacing hand-rolled, duplicated string interpolation previously spread across TestProjectWriter.

CloneAsShallowAsync, AddWorktreeAsync, AddSubmoduleAsync, and SimulatePush now reference the TestApp project that Git itself already copied into the clone/worktree/submodule/push destination (GetExistingTestApp), instead of regenerating a brand-new test app project there.

Other changes

  • TestProjectWriter.cs reduced from ~300 to ~90 lines, now only responsible for writing files for an already-built ProjectFileBuilder (WriteAppProjectAsync, WriteLibraryProjectAsync, WriteFakeGitProjectAsync, WriteNonZeroExitCodeGitProjectAsync, WriteNuGetConfigAsync).
  • Renamed GitPropertiesBuildTestBaseGitPropertiesTestBase, GitPropertiesTestWorkspaceTestWorkspace, and PublishPush\Publishing\.
  • New Transitivity\PrivateAssetsControlsPackageReferenceTransitivityTest verifies the ServiceDefaults scenario end-to-end for all three PrivateAssets values (unset/none/all): a host app generates git.properties only when the library it references has PrivateAssets unset or "none", and the library itself never generates its own.
  • Removed two AutoDetection tests (AutoDetectionGeneratesGitPropertiesWhenConsumingPackageReferencedTest, AutoDetectionExplicitFalseWinsOverDetectedConsumingPackageReferenceTest) that became redundant once TestApp itself started referencing the fake Endpoint package and using the auto default — their behavior is now covered incidentally by PropertyContent\GitPropertiesMatchGitOutputTest and by the Diagnostics\*WarnsByDefaultTest tests, respectively.

Quality checklist

  • Your code complies with our Coding Style.
  • You've updated unit and/or integration tests for your change, where applicable.
  • You've updated documentation for your change, where applicable.
    If your change affects other repositories, such as Documentation and/or Samples, add linked PRs here.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.
  • You've added required license files and/or file headers (explaining where the code came from with proper attribution), where code is copied from StackOverflow, a blog, or OSS.

@bart-vmware bart-vmware added this to the 4.3.0 milestone Aug 2, 2026
@bart-vmware bart-vmware added Component/Management Issues related to Steeltoe Management (actuators) ReleaseLine/4.x Identified as a feature/fix for the 4.x release line labels Aug 2, 2026
@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Summary - All Code Coverage (ubuntu-latest)

Line coverage Branch coverage

Assembly Line coverage Branch coverage
Steeltoe.Bootstrap.AutoConfiguration 97.4% 83.3%
Steeltoe.Common 86.4% 77%
Steeltoe.Common.Certificates 97.2% 80.2%
Steeltoe.Common.Hosting 83.5% 65%
Steeltoe.Common.Http 97.4% 80.9%
Steeltoe.Common.Logging 81.1% 56.2%
Steeltoe.Common.Net 64.5% 66.6%
Steeltoe.Configuration.Abstractions 96.3% 89.4%
Steeltoe.Configuration.CloudFoundry 97.8% 92.7%
Steeltoe.Configuration.ConfigServer 91.6% 86.2%
Steeltoe.Configuration.Encryption 97.6% 87.8%
Steeltoe.Configuration.Kubernetes.ServiceBindings 95.6% 82.6%
Steeltoe.Configuration.Placeholder 93.8% 82.6%
Steeltoe.Configuration.RandomValue 93.2% 83.3%
Steeltoe.Configuration.SpringBoot 98.3% 85%
Steeltoe.Connectors 94.5% 85.6%
Steeltoe.Connectors.EntityFrameworkCore 79.7% 65.3%
Steeltoe.Discovery.Configuration 96.3% 75%
Steeltoe.Discovery.Consul 91.5% 84%
Steeltoe.Discovery.Eureka 91.6% 81.3%
Steeltoe.Discovery.HttpClients 89.9% 91.4%
Steeltoe.Logging.Abstractions 99.4% 95.6%
Steeltoe.Logging.DynamicConsole 100% 92.3%
Steeltoe.Logging.DynamicSerilog 99.1% 95.4%
Steeltoe.Management.Abstractions 100% 100%
Steeltoe.Management.Endpoint 96% 87.1%
Steeltoe.Management.GitProperties.Build 95.1% 83.9%
Steeltoe.Management.Prometheus 95.8% 76.9%
Steeltoe.Management.Tasks 95.2% 80%
Steeltoe.Management.Tracing 100% 75%
Steeltoe.Security.Authentication.JwtBearer 100% 93.7%
Steeltoe.Security.Authentication.OpenIdConnect 87.7% 66.6%
Steeltoe.Security.Authorization.Certificate 95.6% 61.5%
Steeltoe.Security.DataProtection.Redis 100% ****

…teeltoe.Management.GitProperties.Build and fake Steeltoe.Management.Endpoint package.
@bart-vmware
bart-vmware force-pushed the gitproperties-allow-transitive branch from 75d6dc4 to e0d9477 Compare August 2, 2026 02:44
@bart-vmware
bart-vmware marked this pull request as ready for review August 2, 2026 03:01
@bart-vmware
bart-vmware requested a review from TimHess August 2, 2026 03:08
@sonarqubecloud

sonarqubecloud Bot commented Aug 2, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component/Management Issues related to Steeltoe Management (actuators) ReleaseLine/4.x Identified as a feature/fix for the 4.x release line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant