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

move nuget update analysis to native code #10025

Merged
merged 17 commits into from
Jul 4, 2024

Conversation

brettfo
Copy link
Contributor

@brettfo brettfo commented Jun 17, 2024

The accompanying smoke test PR is:


This PR adds a new native command analyze that takes the place of the update_checker in Ruby. The purpose of this code is to query the available NuGet package sources to see what updates are available. With this change we now no longer manually poke any NuGet APIs; we're using "real" NuGet bits for all of it which means we shouldn't have any more issues around not-quite-compliant NuGet feeds.

There is also a test change in Ruby to stub the calls into the native C# tool to instead simply dump a pre-baked JSON response. This takes several minutes off of the CI time.


Experiments

There is a lot of churn in this PR, so to mitigate some of that, a large bulk of work was placed behind the nuget_native_analysis flag, but not all.

Changes that this PR incorporates whether or not the experiment is enabled:

  • Workspace discovery (i.e., through file_parser.rb) has been updated to always report the full path of dependency files (e.g., /src/Directory.Build.props instead of just Directory.Build.props. This is required to avoid confusion during a multi-directory update, because it's possible for two directories to be given, src/ and test/, and if both have a Directory.Build.props file, later update stages don't know which file is being referenced. This change is reflected in the smoke tests.
  • Metadata finder has been scaled back to barebones behavior. Workspace discovery, mentioned above, now reports the package info URL directly, instead of leaving it up to the metadata finder to manually poke the NuGet APIs to find a .nuspec file and then extract the repo. This change is reflected in the smoke tests.

Changes placed behind the experiments flag:

  • The file update_checker.rb has been modified to check for the experiment flag and dispatch to the new update checker in native_update_checker/native_update_checker.rb when appropriate. If the experiment flag is not set, the old behavior remains. To disambiguate files and types with similar names, I've prepended native_ or Native to the new ones.

I have tried to keep the changes that check the experiments flag, move the new update checker, and apply the prefix Native... to a single commit so that when the experiment is over, that single commit can essentially be reverted (modulo some minor cleanup) to enable the new behavior.

I have verified the old and new behavior is invoked as appropriate by running an update job both with and without the experiments flag in the job.yml file.


I timed some update operations and the new behavior appears to be within a few seconds of the old/existing behavior with quite an overlap, so the end result is probably a wash.

Existing updater, 2 runs: 5:23 and 6:16
New updater, 2 runs: 5:51, 6:29

@github-actions github-actions bot added the L: dotnet:nuget NuGet packages via nuget or dotnet label Jun 17, 2024
@brettfo brettfo force-pushed the dev/brettfo/nuget-analyze-command branch 2 times, most recently from 9152693 to 5d19672 Compare July 1, 2024 16:58
@brettfo brettfo force-pushed the dev/brettfo/nuget-analyze-command branch 6 times, most recently from 6895a94 to a3226ea Compare July 3, 2024 15:07
@brettfo brettfo marked this pull request as ready for review July 3, 2024 15:08
@brettfo brettfo requested review from a team as code owners July 3, 2024 15:08
@raj-meka raj-meka force-pushed the dev/brettfo/nuget-analyze-command branch from a3226ea to 919e1d1 Compare July 3, 2024 21:54
@jeffwidman jeffwidman force-pushed the dev/brettfo/nuget-analyze-command branch from 919e1d1 to c839998 Compare July 4, 2024 19:51
Copy link
Member

@jeffwidman jeffwidman left a comment

Choose a reason for hiding this comment

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

I mostly skimmed it, and trusting your team to own this section of code. What parts I did poke at deeper looked good to me.

I have tried to keep the changes that check the experiments flag, move the new update checker, and apply the prefix Native... to a single commit so that when the experiment is over, that single commit can essentially be reverted (modulo some minor cleanup) to enable the new behavior.

😍

@@ -16,6 +16,7 @@ concurrency:

env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SMOKE_TEST_BRANCH: main
Copy link
Member

Choose a reason for hiding this comment

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

nice! Making life simple down the road.

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've had to re-figure this out too many times.

@jeffwidman
Copy link
Member

Merging via a merge commit to preserve history... I find the "fix lint" commits ugly, but I don't want to squash down and lose the niceness where you'd put most of the feature-flag changes behind a single commit.

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