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

use unique directory for temp nuget packages #10243

Merged
merged 2 commits into from
Jul 18, 2024

Conversation

brettfo
Copy link
Contributor

@brettfo brettfo commented Jul 18, 2024

Some CI runs fail due to a corrupted temporary NuGet package. I can't get this to fail locally, but it seems to have a~30% failure rate in CI. The temp directory is re-used between tests and I'm exploring a theory that one test writes a corrupt package and the next test reads that. This PR uses a unique directory each time. I'll be running CI repeatedly to see if I can get it to fail.

I've run the NuGet leg of the CI 10 times with no failures. I'm good to call this ready.

@github-actions github-actions bot added the L: dotnet:nuget NuGet packages via nuget or dotnet label Jul 18, 2024
@brettfo brettfo force-pushed the dev/brettfo/nuget-test-package-dir branch from ec13581 to 6849322 Compare July 18, 2024 17:19
@brettfo brettfo marked this pull request as ready for review July 18, 2024 22:02
@brettfo brettfo requested a review from a team as a code owner July 18, 2024 22:02
@@ -37,12 +37,23 @@ public NuGetContext(string? currentDirectory = null, ILogger? logger = null)
.Where(p => p.IsEnabled)
.ToImmutableArray();
Logger = logger ?? NullLogger.Instance;
TempPackageDirectory = Path.Combine(Path.GetTempPath(), ".dependabot", "packages");
TempPackageDirectory = Path.Combine(Path.GetTempPath(), $"dependabot-packages_{Guid.NewGuid():d}");
Copy link
Contributor

Choose a reason for hiding this comment

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

Since most of the other files generated during a run are under {temp}/.dependabot, why move these out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was seeing cases of flaky tests. With the re-used directory and a lot of test packages being named "Some.Package/1.0.0" there could be some overlap if a previous test left a package in this directory that didn't match what the next test exepcted (e.g., different target framework, etc.), especially with the lazy downloading behavior.

Copy link
Member

Choose a reason for hiding this comment

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

☝️ might indicate a code comment would be useful to say "here's why we're doing this"

@abdulapopoola abdulapopoola merged commit fbcf548 into main Jul 18, 2024
67 checks passed
@abdulapopoola abdulapopoola deleted the dev/brettfo/nuget-test-package-dir branch July 18, 2024 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L: dotnet:nuget NuGet packages via nuget or dotnet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants