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

feat: Embed symbols and enable continuous integration builds (deterministic source paths) #1129

Merged
merged 3 commits into from
Feb 26, 2024

Conversation

tom-englert
Copy link
Contributor

@tom-englert tom-englert commented Feb 24, 2024

What does this PR do?

Use embedded symbols instead of separate symbol package

Why is it important?

Works better across all IDEs

Related issues

Copy link

netlify bot commented Feb 24, 2024

Deploy Preview for testcontainers-dotnet ready!

Name Link
🔨 Latest commit e6f2fea
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-dotnet/deploys/65dc366f5a1c5f00080aa5e8
😎 Deploy Preview https://deploy-preview-1129--testcontainers-dotnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Collaborator

@HofmeisterAn HofmeisterAn left a comment

Choose a reason for hiding this comment

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

According to this comment and this section, Source Link is now included in the SDK. The added properties, among others, are set in our Cake build file. According to the Source Link docs, they are not necessary anymore, either. Probably, we can even remove them.

Is something not working? I haven't had issues in the past debugging the library. The NuGet Package Explorer looks Ok too (although, we need to move ContinuousIntegrationBuild to Cake's build task).

image

@tom-englert
Copy link
Contributor Author

It should look like this:

  • no symbol server
  • deterministic, including repo ulr & commit
    image

I'll have a look whats wrong with this...

@HofmeisterAn
Copy link
Collaborator

It should look like this:

I see, thanks! Maybe we just need to move the properties (args) to the Cake build task (the pack task does not rebuild the projects):

diff --git a/build.cake b/build.cake
index 1d2e4ae..0843d4e 100644
--- a/build.cake
+++ b/build.cake
@@ -67,6 +67,8 @@ Task("Build")
     Verbosity = param.Verbosity,
     NoRestore = true,
     ArgumentCustomization = args => args
+      .Append("/p:ContinuousIntegrationBuild=true")
+      .Append("/p:EmbedUntrackedSources=true")
   });
 });
 
@@ -134,8 +136,6 @@ Task("Create-NuGet-Packages")
     SymbolPackageFormat = "snupkg",
     OutputDirectory = param.Paths.Directories.NuGetDirectoryPath,
     ArgumentCustomization = args => args
-      .Append("/p:ContinuousIntegrationBuild=true")
-      .Append("/p:EmbedUntrackedSources=true")
       .Append($"/p:Version={param.Version}")
   });
 });

@tom-englert
Copy link
Contributor Author

Probably yes, and the symbols should be embedded rather than having a separate symbol package, from my experience the latter never works without friction.

@tom-englert
Copy link
Contributor Author

tom-englert commented Feb 24, 2024

Also maybe .Append("/p:ContinuousIntegrationBuild=true") should not really be needed, SourceLink should determine this automatically

@tom-englert
Copy link
Contributor Author

This is what I got with the current version of TestContainers:

  • listed in the "External Sources", but seems not to match the symbols found on the symbol server.
    image

Copy link
Collaborator

@HofmeisterAn HofmeisterAn left a comment

Choose a reason for hiding this comment

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

This is what I got with the current version of TestContainers:

This is strange. Sorry, I do not have access to Visual Studio. Rider seems to be able to download the symbols, etc. I can debug into the sources without any issues. However, we can merge the suggestions. The NuGet Package Explorer looks even better with them. Thanks.

Directory.Build.props Outdated Show resolved Hide resolved
build.cake Outdated Show resolved Hide resolved
build.cake Outdated Show resolved Hide resolved
@tom-englert tom-englert changed the title Provide deterministic builds with SourceLink support Use embedded symbols, since they are more reliable than symbol packages Feb 24, 2024
@HofmeisterAn
Copy link
Collaborator

I published the pipeline artifacts (NuGets) to ensure that the NuGets are built and configured properly, and everything is set up correctly for the next release. It appears that ContinuousIntegrationBuild is somehow not automatically applied to the build. We need to set it explicitly (before and after).

image

@tom-englert
Copy link
Contributor Author

Strange, I never had to set this - however I never used Cake, maybe that's special about this.

@HofmeisterAn
Copy link
Collaborator

Probably, we cannot enable ContinuousIntegrationBuild that easily 😐. It obviously breaks our CommonDirectoryPathTest tests. Not sure how (or if) we can solve this, because we are using the CallerFilePath attribute to resolve common directory paths:

[PublicAPI]
public static CommonDirectoryPath GetGitDirectory([CallerFilePath, NotNull] string filePath = "")
{
return new CommonDirectoryPath(GetDirectoryPath(Path.GetDirectoryName(filePath), ".git"));
}

@tom-englert
Copy link
Contributor Author

It obviously breaks our CommonDirectoryPathTest tests

That's strange, how can this have such a side effect? And why only on linux?

@tom-englert tom-englert marked this pull request as draft February 25, 2024 08:19
@HofmeisterAn
Copy link
Collaborator

It obviously breaks our CommonDirectoryPathTest tests

That's strange, how can this have such a side effect? And why only on linux?

I think I found the "reason" and have a potential working configuration, which also explains why you never had to set ContinuousIntegrationBuild explicitly. I need a few more minutes to validate my changes.

@HofmeisterAn
Copy link
Collaborator

If we set ContinuousIntegrationBuild to true during the build, it will break the tests because CallerFilePath now returns a deterministic root path. We can simply disable ContinuousIntegrationBuild for the test projects.

My assumption was, if we allow Cake to rebuild the packages on Pack (if the packages are already built, we likely need to force a rebuild), the ContinuousIntegrationBuild is applied automatically, and it won't interfere with the tests. Unfortunately, the configuration is not applied automatically...

@HofmeisterAn
Copy link
Collaborator

HofmeisterAn commented Feb 25, 2024

I do not think we need that many changes. The following changes work fine (incl. Sonar). We just need to make sure the pack target rebuilds the NuGets. I am still wondering why we need to set ContinuousIntegrationBuild explicitly, but maybe Source Link behaves differently if the source control provider is added explicitly.

image

@tom-englert tom-englert marked this pull request as ready for review February 25, 2024 13:18
@tom-englert
Copy link
Contributor Author

Just needed to turn off deterministic for the tests, they don't get deployed anyhow.

Copy link
Collaborator

@HofmeisterAn HofmeisterAn left a comment

Choose a reason for hiding this comment

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

Thank you for the efforts, and apologies for the back and forth.

@HofmeisterAn HofmeisterAn added the enhancement New feature or request label Feb 26, 2024
@HofmeisterAn HofmeisterAn changed the title Use embedded symbols, since they are more reliable than symbol packages feat: Embed symbols and enable continuous integration builds (deterministic source paths) Feb 26, 2024
@HofmeisterAn HofmeisterAn merged commit c0932f2 into testcontainers:develop Feb 26, 2024
11 checks passed
@tom-englert
Copy link
Contributor Author

Happy to contribute to such a great tool! Thanks for all YOUR efforts 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Enhancement]: Use deterministic builds with SourceLink support
2 participants