-
Notifications
You must be signed in to change notification settings - Fork 897
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
(#3461,#3487) Prevent dependency resolution from downgrading packages #3486
base: develop
Are you sure you want to change the base?
Conversation
This PR is in draft as I still need to run more tests as well as add more tests. And apparently bring the branch in line with the develop branch. |
64f2ded
to
1731d3e
Compare
37574fb
to
7e225aa
Compare
a4cf193
to
8b82e88
Compare
@corbob I am going to rebase this PR onto the head of develop, since my PR has now been merged, which will make reviewing this PR easier. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have left a few comments for review.
@@ -0,0 +1,6 @@ | |||
These packages can be used to test the installation or upgrading of packages that have require an existing package to downgrade. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sentence doesn't make much sense to me. Can you re-word?
} | ||
} | ||
|
||
Context 'Installing a package with argument (<Argument>) should (<AllowsDowngrade>) downgrade an existing package dependency.' -Tag Downgrade, StopOnFirstPackageFailure -ForEach @( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this test name mention that it includes usage of the StopOnFirstPackageFailure feature?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It definitely should. I copied it from the other tests, and didn't update the name of it apparently.
Naming is hard, I've tried to encompass what the test is doing...
<summary>__REPLACE__</summary> | ||
<description>__REPLACE__MarkDown_Okay </description> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be words in here to say what this package is for?
<summary>__REPLACE__</summary> | ||
<description>__REPLACE__MarkDown_Okay </description> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be words here to say what this package is for?
<description>__REPLACE__</description> | ||
<summary>__REPLACE__</summary> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question again.
<description>__REPLACE__</description> | ||
<summary>__REPLACE__</summary> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here
@gep13 I'll add it here instead of in the conversations... The var nullResult = packageResultsToReturn.GetOrAdd(packageName, new PackageResult(installedPackage.PackageMetadata, pathResolver.GetInstallPath(installedPackage.PackageMetadata.Id)));
nullResult.Messages.Add(new ResultMessage(ResultType.Error, logMessage)); I think, I did the The |
When a package dependency fails to install, we will now fail the package as well.
Some of these package already existed on our internal repository, while some of them have been added for the tests being added.
695754d
to
950ce5d
Compare
We have added some tests for the install all command. This adds a new package source to the testing environment so that we can run the tests locally and in Test Kitchen.
Add a number of tests for dependency scenarios where we did not have tests before.
In the NugetService we were using a nullResult variable to allow us to add messages to the result. We do not need this variable if we're only adding a single message. This commit removes the unnecessary variables.
This updates the `test-chocolateypath` package to have a description and removes the unneeded comments. This is related to a GitLab MR that noted these things when bringing this package into the internal repository. This reverts commit ffd9aab4b40dc8b47b84de5f3ce91ea22fda7a6d.
e1a6373
to
8841937
Compare
<description>__REPLACE__</description> | ||
<summary>__REPLACE__</summary> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this was missed to be updated with information about what this package is about.
Can we get the description and summary updated to say what the package is for?
packageResultsToReturn | ||
.GetOrAdd( | ||
packageDependencyInfo.Id, | ||
new PackageResult(packageDependencyInfo.Id, packageDependencyInfo.Version.ToStringSafe(), string.Empty) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason you are using ToStringSafe
instead of ToNormalizedVersionChecked
here?
Or is that method not available here?
@@ -793,6 +800,26 @@ Version was specified as '{0}'. It is possible that version | |||
|
|||
foreach (SourcePackageDependencyInfo packageDependencyInfo in resolvedPackages) | |||
{ | |||
// Don't attempt to action this package if dependencies failed. | |||
if (packageDependencyInfo != null && packageResultsToReturn.Any(r => r.Value.Success != true && packageDependencyInfo.Dependencies.Any(d => d.Id == r.Value.Identity.Id))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this dependency any check be case-insensitive?
Just using ==
here makes it case-sensitive.
@@ -1559,6 +1608,25 @@ public virtual ConcurrentDictionary<string, PackageResult> Upgrade(ChocolateyCon | |||
break; | |||
} | |||
|
|||
// Don't attempt to action this package if dependencies failed. | |||
if (packageResultsToReturn.Any(r => r.Value.Success != true && packageDependencyInfo.Dependencies.Any(d => d.Id == r.Value.Identity.Id))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as earlier, can we make this dependency any check case-insensitive?
var logMessage = StringResources.ErrorMessages.DependencyFailedToInstall.FormatWith(packageDependencyInfo.Id, packageDependencyInfo.Version); | ||
packageResultsToReturn.GetOrAdd( | ||
packageDependencyInfo.Id, | ||
new PackageResult(packageDependencyInfo.Id, packageDependencyInfo.Version.ToStringSafe(), string.Empty) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use ToNormalizedVersionChecked
?
Description Of Changes
--allow-downgrade
is not specified.Motivation and Context
Testing
./build.bat --testExecutionType=all --shouldRunOpenCover=false
Operating Systems Testing
Change Types Made
Change Checklist
Related Issue