Skip to content

Source tarball comparison validation#4740

Merged
mthalman merged 6 commits intodotnet:mainfrom
mthalman:dev/mthalman/sb5472-git-archive-comparison
Feb 12, 2026
Merged

Source tarball comparison validation#4740
mthalman merged 6 commits intodotnet:mainfrom
mthalman:dev/mthalman/sb5472-git-archive-comparison

Conversation

@mthalman
Copy link
Member

@mthalman mthalman commented Feb 9, 2026

Fixes dotnet/source-build#5472

Adds validation which compares the contents of the VMR repo with the output of the git archive command to ensure they have the expected contents.

Refactors the test code to move the baseline/exclusion infrastructure from SourceBuilt.Tests to TestUtilities.

The new test is added to Microsoft.DotNet.Tests project which can then use the baseline/exclusion infrastructure from TestUtilities. This test gathers the list of files from the git repo using the git ls-tree command so there's no danger of including other non-repo files like build artifacts. This file list is compared to the list of files that get included in the output of the git archive command.

- Move TarHelper (tar entry enumeration) to TestUtilities
- Move BaselineHelper (baseline comparison) to TestUtilities, returning
  messages instead of asserting directly
- Move ExclusionsHelper (glob-based exclusions) to TestUtilities with
  parameterized logsDirectory
- Update SourceBuild.Tests to use thin wrappers over shared helpers
- Refactor tar reading in SourceBuild.Tests and UnifiedBuild.Tests to
  use shared TarHelper
@mthalman mthalman changed the title Dev/mthalman/sb5472 git archive comparison Source tarball comparison validation Feb 9, 2026
Validates that all files tracked in the git repository are included in
the git archive output. Detects files excluded by export-ignore
directives in .gitattributes files within submodules.

Uses baseline comparison and glob-based exclusions via shared
TestUtilities helpers.

Also fixes exclusion file comment parsing to only treat full-line #
as comments, allowing # characters in file paths. Removes inline
comment syntax from existing exclusion files.

See dotnet/source-build#5472
@mthalman mthalman force-pushed the dev/mthalman/sb5472-git-archive-comparison branch from bdaff9d to b7150da Compare February 10, 2026 15:47
@mthalman mthalman marked this pull request as ready for review February 10, 2026 18:25
@mthalman mthalman requested review from a team as code owners February 10, 2026 18:25
Copilot AI review requested due to automatic review settings February 10, 2026 18:25
@mthalman
Copy link
Member Author

cc @omajid

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new validation test that compares the set of files tracked in the VMR git repo against the set of files produced by git archive, to detect unexpected export-ignore exclusions. It also refactors baseline/exclusion helpers into TestUtilities so multiple test projects can share the same infrastructure.

Changes:

  • Add SourceTarballContentTests to enumerate git ls-tree vs git archive and baseline the missing-from-archive set (with exclusions).
  • Move/shared-ize baseline + exclusions helpers into test/TestUtilities (including a new tar helper).
  • Update existing tests and exclusion baselines to use the shared helpers and updated exclusion-file comment format.

Reviewed changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/TestUtilities/TestUtilities.csproj Adds FileSystemGlobbing dependency needed by shared exclusion parsing.
test/TestUtilities/TarHelper.cs New helper to enumerate tar entry names from a stream.
test/TestUtilities/ExclusionsHelper.cs Refactors helper into TestUtilities, makes it public, adds required logs directory parameter, adjusts comment parsing rules.
test/TestUtilities/BaselineHelper.cs New shared baseline comparison utilities (including diff via git diff --no-index).
test/Microsoft.DotNet.UnifiedBuild.Tests/Utilities.cs Switches tar enumeration to shared TarHelper.
test/Microsoft.DotNet.Tests/assets/SourceTarballContentTests/MissingFromArchiveExclusions.txt Adds exclusion patterns for known/expected git archive omissions.
test/Microsoft.DotNet.Tests/assets/SourceTarballContentTests/MissingFromArchive.txt Adds baseline file for repo-vs-archive comparison output.
test/Microsoft.DotNet.Tests/SourceTarballContentTests.cs New test comparing git repo contents vs git archive tar output.
test/Microsoft.DotNet.Tests/Microsoft.DotNet.Tests.csproj Adds RepoRoot runtime config option and makes VSTestCLIRunSettings conditional.
test/Microsoft.DotNet.Tests/Config.cs Adds accessors for LogsDirectory and RepoRoot.
test/Microsoft.DotNet.SourceBuild.Tests/assets/SdkContentTests/SdkFileDiffExclusions.txt Updates comments/format to align with “full-line comments only” exclusion parsing.
test/Microsoft.DotNet.SourceBuild.Tests/assets/ArtifactsSizeTests/ZeroSizeExclusions.txt Updates comments/format to align with “full-line comments only” exclusion parsing.
test/Microsoft.DotNet.SourceBuild.Tests/Utilities.cs Uses shared TarHelper for tar listing (materialized to avoid disposed stream).
test/Microsoft.DotNet.SourceBuild.Tests/SdkContentTests.cs Updates ExclusionsHelper construction to pass logs directory.
test/Microsoft.DotNet.SourceBuild.Tests/LicenseScanTests.cs Updates ExclusionsHelper construction to pass logs directory.
test/Microsoft.DotNet.SourceBuild.Tests/BaselineHelper.cs Converts baseline operations to wrappers over TestUtilities.BaselineHelper.
test/Microsoft.DotNet.SourceBuild.Tests/ArtifactsSizeTests.cs Updates ExclusionsHelper construction to pass logs directory.
Comments suppressed due to low confidence (1)

test/TestUtilities/ExclusionsHelper.cs:42

  • ExclusionsHelper now requires logsDirectory, but the constructor only null-checks exclusionsFileName. Since logsDirectory is used for Path.Combine/writing files, add argument validation (null/empty/whitespace) and consider ensuring the directory exists (or throw a clear exception) to avoid late failures when generating updated baselines.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Switch SourceTarballContentTests to read the .tar.gz produced by
CreateSourceArtifact instead of invoking git archive in the test.
The tarball path is resolved via a glob on ArtifactsAssetsDir. The
test is skipped when no tarball is present.
@mthalman mthalman force-pushed the dev/mthalman/sb5472-git-archive-comparison branch from 40176cb to bcaff5b Compare February 11, 2026 19:19
@mthalman mthalman enabled auto-merge (squash) February 11, 2026 20:59
@mthalman mthalman merged commit e1560f6 into dotnet:main Feb 12, 2026
11 checks passed
@mthalman mthalman deleted the dev/mthalman/sb5472-git-archive-comparison branch February 12, 2026 01:49
tmds pushed a commit to tmds/dotnet that referenced this pull request Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Confirm that files and contents of the release tarballs match the git repository

3 participants