dependabot-nuget 0.351.0 → 0.353.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DiscoveryWorker.cs +17 -43
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs +102 -46
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/ExperimentsManager.cs +0 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/DependencyGroup.cs +19 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/Job.cs +23 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/JobErrorBase.cs +4 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/OutOfDisk.cs +9 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/IApiHandler.cs +11 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/RunWorker.cs +25 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/CreateSecurityUpdatePullRequestHandler.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/GroupUpdateAllVersionsHandler.cs +48 -35
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/RefreshGroupUpdatePullRequestHandler.cs +3 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/RefreshSecurityUpdatePullRequestHandler.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/RefreshVersionUpdatePullRequestHandler.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackageReferenceUpdater.cs +20 -23
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +41 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/PathHelper.cs +93 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.PackagesConfig.cs +2 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Project.cs +21 -9
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.cs +51 -96
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/SdkProjectDiscoveryTests.cs +1 -66
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/ApiModel/JobTests.cs +39 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/EndToEndTests.cs +142 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/HttpApiHandlerTests.cs +1 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/JobErrorBaseTests.cs +7 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/MessageReportTests.cs +11 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/MiscellaneousTests.cs +76 -7
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/SerializationTests.cs +8 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdateHandlers/GroupUpdateAllVersionsHandlerTests.cs +242 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/PackageReferenceUpdaterTests.cs +30 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +25 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/PathHelperTests.cs +250 -0
- metadata +5 -4
|
@@ -129,14 +129,15 @@ public class MiscellaneousTests
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
[Fact]
|
|
132
|
-
public void
|
|
132
|
+
public void DeserializeDependencyGroup_SpecificValues()
|
|
133
133
|
{
|
|
134
134
|
var json = """
|
|
135
135
|
{
|
|
136
136
|
"name": "test-group",
|
|
137
137
|
"rules": {
|
|
138
138
|
"patterns": ["Test.*"],
|
|
139
|
-
"exclude-patterns": ["Dependency.*"]
|
|
139
|
+
"exclude-patterns": ["Dependency.*"],
|
|
140
|
+
"update-types": ["minor", "patch"]
|
|
140
141
|
}
|
|
141
142
|
}
|
|
142
143
|
""";
|
|
@@ -146,6 +147,24 @@ public class MiscellaneousTests
|
|
|
146
147
|
var matcher = group.GetGroupMatcher();
|
|
147
148
|
Assert.Equal(["Test.*"], matcher.Patterns);
|
|
148
149
|
Assert.Equal(["Dependency.*"], matcher.ExcludePatterns);
|
|
150
|
+
Assert.Equal([GroupUpdateType.Minor, GroupUpdateType.Patch], matcher.UpdateTypes);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
[Fact]
|
|
154
|
+
public void DeserializeDependencyGroup_DefaultValues()
|
|
155
|
+
{
|
|
156
|
+
var json = """
|
|
157
|
+
{
|
|
158
|
+
"name": "test-group"
|
|
159
|
+
}
|
|
160
|
+
""";
|
|
161
|
+
var group = JsonSerializer.Deserialize<DependencyGroup>(json, RunWorker.SerializerOptions);
|
|
162
|
+
Assert.NotNull(group);
|
|
163
|
+
Assert.Equal("test-group", group.Name);
|
|
164
|
+
var matcher = group.GetGroupMatcher();
|
|
165
|
+
Assert.Equal(["*"], matcher.Patterns);
|
|
166
|
+
Assert.Equal([], matcher.ExcludePatterns);
|
|
167
|
+
Assert.Equal([GroupUpdateType.Major, GroupUpdateType.Minor, GroupUpdateType.Patch], matcher.UpdateTypes);
|
|
149
168
|
}
|
|
150
169
|
|
|
151
170
|
[Fact]
|
|
@@ -156,7 +175,8 @@ public class MiscellaneousTests
|
|
|
156
175
|
"name": "test-group",
|
|
157
176
|
"rules": {
|
|
158
177
|
"patterns": { "unexpected": 1 },
|
|
159
|
-
"exclude-patterns": { "unexpected": 2 }
|
|
178
|
+
"exclude-patterns": { "unexpected": 2 },
|
|
179
|
+
"update-types": { "unexpected": 3 }
|
|
160
180
|
}
|
|
161
181
|
}
|
|
162
182
|
""";
|
|
@@ -166,6 +186,7 @@ public class MiscellaneousTests
|
|
|
166
186
|
var matcher = group.GetGroupMatcher();
|
|
167
187
|
Assert.Equal([], matcher.Patterns);
|
|
168
188
|
Assert.Equal([], matcher.ExcludePatterns);
|
|
189
|
+
Assert.Equal([], matcher.UpdateTypes);
|
|
169
190
|
}
|
|
170
191
|
|
|
171
192
|
[Theory]
|
|
@@ -515,9 +536,9 @@ public class MiscellaneousTests
|
|
|
515
536
|
|
|
516
537
|
[Theory]
|
|
517
538
|
[MemberData(nameof(DependencyInfoFromJobData))]
|
|
518
|
-
public void DependencyInfoFromJob(Job job, Dependency dependency, DependencyInfo expectedDependencyInfo)
|
|
539
|
+
public void DependencyInfoFromJob(Job job, Dependency dependency, GroupMatcher? groupMatcher, DependencyInfo expectedDependencyInfo)
|
|
519
540
|
{
|
|
520
|
-
var actualDependencyInfo = RunWorker.GetDependencyInfo(job, dependency, allowCooldown: true);
|
|
541
|
+
var actualDependencyInfo = RunWorker.GetDependencyInfo(job, dependency, groupMatcher is null ? [] : [groupMatcher], allowCooldown: true);
|
|
521
542
|
var expectedString = JsonSerializer.Serialize(expectedDependencyInfo, AnalyzeWorker.SerializerOptions);
|
|
522
543
|
var actualString = JsonSerializer.Serialize(actualDependencyInfo, AnalyzeWorker.SerializerOptions);
|
|
523
544
|
Assert.Equal(expectedString, actualString);
|
|
@@ -604,7 +625,7 @@ public class MiscellaneousTests
|
|
|
604
625
|
];
|
|
605
626
|
}
|
|
606
627
|
|
|
607
|
-
public static IEnumerable<object[]> DependencyInfoFromJobData()
|
|
628
|
+
public static IEnumerable<object?[]> DependencyInfoFromJobData()
|
|
608
629
|
{
|
|
609
630
|
// with security advisory
|
|
610
631
|
yield return
|
|
@@ -634,6 +655,8 @@ public class MiscellaneousTests
|
|
|
634
655
|
},
|
|
635
656
|
// dependency
|
|
636
657
|
new Dependency("Some.Dependency", "1.0.0", DependencyType.PackageReference),
|
|
658
|
+
// groupMatcher
|
|
659
|
+
null,
|
|
637
660
|
// expectedDependencyInfo
|
|
638
661
|
new DependencyInfo()
|
|
639
662
|
{
|
|
@@ -679,6 +702,8 @@ public class MiscellaneousTests
|
|
|
679
702
|
},
|
|
680
703
|
// dependency
|
|
681
704
|
new Dependency("Some.Dependency", "1.0.0", DependencyType.PackageReference),
|
|
705
|
+
// groupMatcher
|
|
706
|
+
null,
|
|
682
707
|
// expectedDependencyInfo
|
|
683
708
|
new DependencyInfo()
|
|
684
709
|
{
|
|
@@ -712,6 +737,8 @@ public class MiscellaneousTests
|
|
|
712
737
|
},
|
|
713
738
|
// dependency
|
|
714
739
|
new Dependency("Some.Dependency", "1.0.0", DependencyType.PackageReference),
|
|
740
|
+
// groupMatcher
|
|
741
|
+
null,
|
|
715
742
|
// expectedDependencyInfo
|
|
716
743
|
new DependencyInfo()
|
|
717
744
|
{
|
|
@@ -753,6 +780,8 @@ public class MiscellaneousTests
|
|
|
753
780
|
},
|
|
754
781
|
// dependency
|
|
755
782
|
new Dependency("Some.Dependency", "1.0.0", DependencyType.PackageReference),
|
|
783
|
+
// groupMatcher
|
|
784
|
+
null,
|
|
756
785
|
// expectedDependencyInfo
|
|
757
786
|
new DependencyInfo()
|
|
758
787
|
{
|
|
@@ -795,6 +824,8 @@ public class MiscellaneousTests
|
|
|
795
824
|
},
|
|
796
825
|
// dependency
|
|
797
826
|
new Dependency("Some.Dependency", "1.0.0", DependencyType.PackageReference),
|
|
827
|
+
// groupMatcher
|
|
828
|
+
null,
|
|
798
829
|
// expectedDependencyInfo
|
|
799
830
|
new DependencyInfo()
|
|
800
831
|
{
|
|
@@ -808,6 +839,44 @@ public class MiscellaneousTests
|
|
|
808
839
|
},
|
|
809
840
|
];
|
|
810
841
|
|
|
811
|
-
|
|
842
|
+
// with limited group update types; major is explicitly ignored, only patch is explicitly allowed => major and minor are ignored
|
|
843
|
+
yield return
|
|
844
|
+
[
|
|
845
|
+
// job
|
|
846
|
+
new Job()
|
|
847
|
+
{
|
|
848
|
+
Source = new()
|
|
849
|
+
{
|
|
850
|
+
Provider = "github",
|
|
851
|
+
Repo = "some/repo"
|
|
852
|
+
},
|
|
853
|
+
IgnoreConditions = [
|
|
854
|
+
new Condition()
|
|
855
|
+
{
|
|
856
|
+
DependencyName = "Some.*",
|
|
857
|
+
UpdateTypes = [ConditionUpdateType.SemVerMajor],
|
|
858
|
+
},
|
|
859
|
+
],
|
|
860
|
+
},
|
|
861
|
+
// dependency
|
|
862
|
+
new Dependency("Some.Dependency", "1.0.0", DependencyType.PackageReference),
|
|
863
|
+
// groupMatcher
|
|
864
|
+
new GroupMatcher()
|
|
865
|
+
{
|
|
866
|
+
Patterns = ["Some.*"],
|
|
867
|
+
ExcludePatterns = [],
|
|
868
|
+
UpdateTypes = [GroupUpdateType.Patch],
|
|
869
|
+
},
|
|
870
|
+
// expectedDependencyInfo
|
|
871
|
+
new DependencyInfo()
|
|
872
|
+
{
|
|
873
|
+
Name = "Some.Dependency",
|
|
874
|
+
Version = "1.0.0",
|
|
875
|
+
IsVulnerable = false,
|
|
876
|
+
IgnoredVersions = [],
|
|
877
|
+
Vulnerabilities = [],
|
|
878
|
+
IgnoredUpdateTypes = [ConditionUpdateType.SemVerMajor, ConditionUpdateType.SemVerMinor],
|
|
879
|
+
},
|
|
880
|
+
];
|
|
812
881
|
}
|
|
813
882
|
}
|
|
@@ -791,6 +791,14 @@ public class SerializationTests : TestBase
|
|
|
791
791
|
"""
|
|
792
792
|
];
|
|
793
793
|
|
|
794
|
+
yield return
|
|
795
|
+
[
|
|
796
|
+
new OutOfDisk(),
|
|
797
|
+
"""
|
|
798
|
+
{"data":{"error-type":"out_of_disk","error-details":{}}}
|
|
799
|
+
"""
|
|
800
|
+
];
|
|
801
|
+
|
|
794
802
|
yield return
|
|
795
803
|
[
|
|
796
804
|
new PrivateSourceAuthenticationFailure(["url1", "url2"]),
|
|
@@ -995,6 +995,28 @@ public class GroupUpdateAllVersionsHandlerTests : UpdateHandlersTestsBase
|
|
|
995
995
|
],
|
|
996
996
|
DependencyFiles = ["/src/project.csproj"],
|
|
997
997
|
},
|
|
998
|
+
new UpdatedDependencyList()
|
|
999
|
+
{
|
|
1000
|
+
Dependencies = [
|
|
1001
|
+
new()
|
|
1002
|
+
{
|
|
1003
|
+
Name = "Package.For.Group.One",
|
|
1004
|
+
Version = "1.0.0",
|
|
1005
|
+
Requirements = [
|
|
1006
|
+
new() { Requirement = "1.0.0", File = "/src/project.csproj", Groups = ["dependencies"] },
|
|
1007
|
+
],
|
|
1008
|
+
},
|
|
1009
|
+
new()
|
|
1010
|
+
{
|
|
1011
|
+
Name = "Package.For.Group.Two",
|
|
1012
|
+
Version = "2.0.0",
|
|
1013
|
+
Requirements = [
|
|
1014
|
+
new() { Requirement = "2.0.0", File = "/src/project.csproj", Groups = ["dependencies"] },
|
|
1015
|
+
],
|
|
1016
|
+
},
|
|
1017
|
+
],
|
|
1018
|
+
DependencyFiles = ["/src/project.csproj"],
|
|
1019
|
+
},
|
|
998
1020
|
new MarkAsProcessed("TEST-COMMIT-SHA"),
|
|
999
1021
|
]
|
|
1000
1022
|
);
|
|
@@ -1128,4 +1150,224 @@ public class GroupUpdateAllVersionsHandlerTests : UpdateHandlersTestsBase
|
|
|
1128
1150
|
]
|
|
1129
1151
|
);
|
|
1130
1152
|
}
|
|
1153
|
+
|
|
1154
|
+
[Fact]
|
|
1155
|
+
public async Task NoPullRequestCreatedForExisting_NoGroup()
|
|
1156
|
+
{
|
|
1157
|
+
await TestAsync(
|
|
1158
|
+
job: new Job()
|
|
1159
|
+
{
|
|
1160
|
+
Source = CreateJobSource("/src"),
|
|
1161
|
+
ExistingPullRequests = [
|
|
1162
|
+
new()
|
|
1163
|
+
{
|
|
1164
|
+
Dependencies = [
|
|
1165
|
+
new()
|
|
1166
|
+
{
|
|
1167
|
+
DependencyName = "Some.Dependency",
|
|
1168
|
+
DependencyVersion = NuGetVersion.Parse("2.0.0"),
|
|
1169
|
+
}
|
|
1170
|
+
]
|
|
1171
|
+
}
|
|
1172
|
+
]
|
|
1173
|
+
},
|
|
1174
|
+
files: [
|
|
1175
|
+
("src/project.csproj", "initial contents"),
|
|
1176
|
+
],
|
|
1177
|
+
discoveryWorker: TestDiscoveryWorker.FromResults(
|
|
1178
|
+
("/src", new WorkspaceDiscoveryResult()
|
|
1179
|
+
{
|
|
1180
|
+
Path = "/src",
|
|
1181
|
+
Projects = [
|
|
1182
|
+
new()
|
|
1183
|
+
{
|
|
1184
|
+
FilePath = "project.csproj",
|
|
1185
|
+
Dependencies = [
|
|
1186
|
+
new("Some.Dependency", "1.0.0", DependencyType.PackageReference, TargetFrameworks: ["net9.0"]),
|
|
1187
|
+
],
|
|
1188
|
+
ImportedFiles = [],
|
|
1189
|
+
AdditionalFiles = [],
|
|
1190
|
+
}
|
|
1191
|
+
],
|
|
1192
|
+
})
|
|
1193
|
+
),
|
|
1194
|
+
analyzeWorker: new TestAnalyzeWorker(input =>
|
|
1195
|
+
{
|
|
1196
|
+
var repoRoot = input.Item1;
|
|
1197
|
+
var discovery = input.Item2;
|
|
1198
|
+
var dependencyInfo = input.Item3;
|
|
1199
|
+
var newVersion = dependencyInfo.Name switch
|
|
1200
|
+
{
|
|
1201
|
+
"Some.Dependency" => "2.0.0",
|
|
1202
|
+
_ => throw new NotImplementedException($"Test didn't expect to update dependency {dependencyInfo.Name}"),
|
|
1203
|
+
};
|
|
1204
|
+
return Task.FromResult(new AnalysisResult()
|
|
1205
|
+
{
|
|
1206
|
+
CanUpdate = true,
|
|
1207
|
+
UpdatedVersion = newVersion,
|
|
1208
|
+
UpdatedDependencies = [],
|
|
1209
|
+
});
|
|
1210
|
+
}),
|
|
1211
|
+
updaterWorker: new TestUpdaterWorker(async input =>
|
|
1212
|
+
{
|
|
1213
|
+
var repoRoot = input.Item1;
|
|
1214
|
+
var workspacePath = input.Item2;
|
|
1215
|
+
var dependencyName = input.Item3;
|
|
1216
|
+
var previousVersion = input.Item4;
|
|
1217
|
+
var newVersion = input.Item5;
|
|
1218
|
+
var isTransitive = input.Item6;
|
|
1219
|
+
|
|
1220
|
+
await File.WriteAllTextAsync(Path.Join(repoRoot, workspacePath), "updated contents");
|
|
1221
|
+
|
|
1222
|
+
return new UpdateOperationResult()
|
|
1223
|
+
{
|
|
1224
|
+
UpdateOperations = [new DirectUpdate() { DependencyName = dependencyName, NewVersion = NuGetVersion.Parse(newVersion), UpdatedFiles = [workspacePath] }],
|
|
1225
|
+
};
|
|
1226
|
+
}),
|
|
1227
|
+
expectedUpdateHandler: GroupUpdateAllVersionsHandler.Instance,
|
|
1228
|
+
expectedApiMessages: [
|
|
1229
|
+
new IncrementMetric()
|
|
1230
|
+
{
|
|
1231
|
+
Metric = "updater.started",
|
|
1232
|
+
Tags = new()
|
|
1233
|
+
{
|
|
1234
|
+
["operation"] = "group_update_all_versions",
|
|
1235
|
+
}
|
|
1236
|
+
},
|
|
1237
|
+
new UpdatedDependencyList()
|
|
1238
|
+
{
|
|
1239
|
+
Dependencies = [
|
|
1240
|
+
new()
|
|
1241
|
+
{
|
|
1242
|
+
Name = "Some.Dependency",
|
|
1243
|
+
Version = "1.0.0",
|
|
1244
|
+
Requirements = [
|
|
1245
|
+
new() { Requirement = "1.0.0", File = "/src/project.csproj", Groups = ["dependencies"] },
|
|
1246
|
+
],
|
|
1247
|
+
},
|
|
1248
|
+
],
|
|
1249
|
+
DependencyFiles = ["/src/project.csproj"],
|
|
1250
|
+
},
|
|
1251
|
+
new MarkAsProcessed("TEST-COMMIT-SHA"),
|
|
1252
|
+
]
|
|
1253
|
+
);
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
[Fact]
|
|
1257
|
+
public async Task NoPullRequestCreatedForExisting_Group()
|
|
1258
|
+
{
|
|
1259
|
+
await TestAsync(
|
|
1260
|
+
job: new Job()
|
|
1261
|
+
{
|
|
1262
|
+
Source = CreateJobSource("/src"),
|
|
1263
|
+
DependencyGroups = [new() { Name = "test-group" }],
|
|
1264
|
+
ExistingGroupPullRequests = [
|
|
1265
|
+
new()
|
|
1266
|
+
{
|
|
1267
|
+
DependencyGroupName = "test-group",
|
|
1268
|
+
Dependencies = [
|
|
1269
|
+
new()
|
|
1270
|
+
{
|
|
1271
|
+
DependencyName = "Some.Dependency",
|
|
1272
|
+
DependencyVersion = NuGetVersion.Parse("2.0.0"),
|
|
1273
|
+
}
|
|
1274
|
+
]
|
|
1275
|
+
}
|
|
1276
|
+
]
|
|
1277
|
+
},
|
|
1278
|
+
files: [
|
|
1279
|
+
("src/project.csproj", "initial contents"),
|
|
1280
|
+
],
|
|
1281
|
+
discoveryWorker: TestDiscoveryWorker.FromResults(
|
|
1282
|
+
("/src", new WorkspaceDiscoveryResult()
|
|
1283
|
+
{
|
|
1284
|
+
Path = "/src",
|
|
1285
|
+
Projects = [
|
|
1286
|
+
new()
|
|
1287
|
+
{
|
|
1288
|
+
FilePath = "project.csproj",
|
|
1289
|
+
Dependencies = [
|
|
1290
|
+
new("Some.Dependency", "1.0.0", DependencyType.PackageReference, TargetFrameworks: ["net9.0"]),
|
|
1291
|
+
],
|
|
1292
|
+
ImportedFiles = [],
|
|
1293
|
+
AdditionalFiles = [],
|
|
1294
|
+
}
|
|
1295
|
+
],
|
|
1296
|
+
})
|
|
1297
|
+
),
|
|
1298
|
+
analyzeWorker: new TestAnalyzeWorker(input =>
|
|
1299
|
+
{
|
|
1300
|
+
var repoRoot = input.Item1;
|
|
1301
|
+
var discovery = input.Item2;
|
|
1302
|
+
var dependencyInfo = input.Item3;
|
|
1303
|
+
var newVersion = dependencyInfo.Name switch
|
|
1304
|
+
{
|
|
1305
|
+
"Some.Dependency" => "2.0.0",
|
|
1306
|
+
_ => throw new NotImplementedException($"Test didn't expect to update dependency {dependencyInfo.Name}"),
|
|
1307
|
+
};
|
|
1308
|
+
return Task.FromResult(new AnalysisResult()
|
|
1309
|
+
{
|
|
1310
|
+
CanUpdate = true,
|
|
1311
|
+
UpdatedVersion = newVersion,
|
|
1312
|
+
UpdatedDependencies = [],
|
|
1313
|
+
});
|
|
1314
|
+
}),
|
|
1315
|
+
updaterWorker: new TestUpdaterWorker(async input =>
|
|
1316
|
+
{
|
|
1317
|
+
var repoRoot = input.Item1;
|
|
1318
|
+
var workspacePath = input.Item2;
|
|
1319
|
+
var dependencyName = input.Item3;
|
|
1320
|
+
var previousVersion = input.Item4;
|
|
1321
|
+
var newVersion = input.Item5;
|
|
1322
|
+
var isTransitive = input.Item6;
|
|
1323
|
+
|
|
1324
|
+
await File.WriteAllTextAsync(Path.Join(repoRoot, workspacePath), "updated contents");
|
|
1325
|
+
|
|
1326
|
+
return new UpdateOperationResult()
|
|
1327
|
+
{
|
|
1328
|
+
UpdateOperations = [new DirectUpdate() { DependencyName = dependencyName, NewVersion = NuGetVersion.Parse(newVersion), UpdatedFiles = [workspacePath] }],
|
|
1329
|
+
};
|
|
1330
|
+
}),
|
|
1331
|
+
expectedUpdateHandler: GroupUpdateAllVersionsHandler.Instance,
|
|
1332
|
+
expectedApiMessages: [
|
|
1333
|
+
new IncrementMetric()
|
|
1334
|
+
{
|
|
1335
|
+
Metric = "updater.started",
|
|
1336
|
+
Tags = new()
|
|
1337
|
+
{
|
|
1338
|
+
["operation"] = "group_update_all_versions",
|
|
1339
|
+
}
|
|
1340
|
+
},
|
|
1341
|
+
new UpdatedDependencyList()
|
|
1342
|
+
{
|
|
1343
|
+
Dependencies = [
|
|
1344
|
+
new()
|
|
1345
|
+
{
|
|
1346
|
+
Name = "Some.Dependency",
|
|
1347
|
+
Version = "1.0.0",
|
|
1348
|
+
Requirements = [
|
|
1349
|
+
new() { Requirement = "1.0.0", File = "/src/project.csproj", Groups = ["dependencies"] },
|
|
1350
|
+
],
|
|
1351
|
+
},
|
|
1352
|
+
],
|
|
1353
|
+
DependencyFiles = ["/src/project.csproj"],
|
|
1354
|
+
},
|
|
1355
|
+
new UpdatedDependencyList()
|
|
1356
|
+
{
|
|
1357
|
+
Dependencies = [
|
|
1358
|
+
new()
|
|
1359
|
+
{
|
|
1360
|
+
Name = "Some.Dependency",
|
|
1361
|
+
Version = "1.0.0",
|
|
1362
|
+
Requirements = [
|
|
1363
|
+
new() { Requirement = "1.0.0", File = "/src/project.csproj", Groups = ["dependencies"] },
|
|
1364
|
+
],
|
|
1365
|
+
},
|
|
1366
|
+
],
|
|
1367
|
+
DependencyFiles = ["/src/project.csproj"],
|
|
1368
|
+
},
|
|
1369
|
+
new MarkAsProcessed("TEST-COMMIT-SHA"),
|
|
1370
|
+
]
|
|
1371
|
+
);
|
|
1372
|
+
}
|
|
1131
1373
|
}
|
|
@@ -11,6 +11,36 @@ namespace NuGetUpdater.Core.Test.Update;
|
|
|
11
11
|
|
|
12
12
|
public class PackageReferenceUpdaterTests
|
|
13
13
|
{
|
|
14
|
+
[Theory]
|
|
15
|
+
[InlineData("net9.0", "net9.0")]
|
|
16
|
+
[InlineData("net9.0-android", "net9.0")]
|
|
17
|
+
[InlineData("net9.0-android", "net9.0-android")]
|
|
18
|
+
public async Task GetPackageGraphForDependencies_DifferentTargetFrameworks(string projectTfm, string packageTfm)
|
|
19
|
+
{
|
|
20
|
+
// arrange
|
|
21
|
+
using var repoRoot = await TemporaryDirectory.CreateWithContentsAsync(("project.csproj", "<Project Sdk=\"Microsoft.NET.Sdk\" />"));
|
|
22
|
+
var projectPath = Path.Combine(repoRoot.DirectoryPath, "project.csproj");
|
|
23
|
+
await UpdateWorkerTestBase.MockNuGetPackagesInDirectory([
|
|
24
|
+
MockNuGetPackage.CreateSimplePackage("Parent.Package", "1.0.0", packageTfm, [(null, [("Transitive.Package", "2.0.0")])]),
|
|
25
|
+
MockNuGetPackage.CreateSimplePackage("Transitive.Package", "2.0.0", packageTfm, [(null, [("Super.Transitive.Package", "3.0.0")])]),
|
|
26
|
+
MockNuGetPackage.CreateSimplePackage("Super.Transitive.Package", "3.0.0", "net8.0"), // explicitly a different but compatible tfm
|
|
27
|
+
], repoRoot.DirectoryPath);
|
|
28
|
+
var topLevelDependencies = new[]
|
|
29
|
+
{
|
|
30
|
+
new Dependency("Parent.Package", "1.0.0", DependencyType.PackageReference),
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// act
|
|
34
|
+
var packageGraph = await PackageReferenceUpdater.GetPackageGraphForDependencies(repoRoot.DirectoryPath, projectPath, projectTfm, [.. topLevelDependencies], new TestLogger());
|
|
35
|
+
|
|
36
|
+
// assert
|
|
37
|
+
Assert.Equal("1.0.0", packageGraph.PackageVersions["Parent.Package"].ToString());
|
|
38
|
+
Assert.Equal("2.0.0", packageGraph.PackageVersions["Transitive.Package"].ToString());
|
|
39
|
+
Assert.Equal("3.0.0", packageGraph.PackageVersions["Super.Transitive.Package"].ToString());
|
|
40
|
+
Assert.Equal("Parent.Package", packageGraph.PackageParents["Transitive.Package"].Single());
|
|
41
|
+
Assert.Equal("Transitive.Package", packageGraph.PackageParents["Super.Transitive.Package"].Single());
|
|
42
|
+
}
|
|
43
|
+
|
|
14
44
|
[Theory]
|
|
15
45
|
[MemberData(nameof(ComputeUpdateOperationsTestData))]
|
|
16
46
|
public async Task ComputeUpdateOperations
|
|
@@ -414,6 +414,19 @@ public class MSBuildHelperTests : TestBase
|
|
|
414
414
|
// normalize default message for the test
|
|
415
415
|
actualError = new DependencyFileNotFound(notFound.Details["file-path"].ToString()!, "test message");
|
|
416
416
|
}
|
|
417
|
+
if (actualError is DependencyFileNotParseable notParseable)
|
|
418
|
+
{
|
|
419
|
+
// normalize the path for the test
|
|
420
|
+
actualError = new DependencyFileNotParseable("/" + notParseable.Details["file-path"].ToString()!.TrimStart('.', '/'), notParseable.Details["message"]?.ToString());
|
|
421
|
+
}
|
|
422
|
+
if (actualError is UnknownError unknownError)
|
|
423
|
+
{
|
|
424
|
+
// remove callstack from unknown error to make testing easier
|
|
425
|
+
var originalMessage = unknownError.Exception.Message;
|
|
426
|
+
var newlineIndex = originalMessage.IndexOf('\n');
|
|
427
|
+
var trimmedMessage = newlineIndex >= 0 ? originalMessage[..newlineIndex] : originalMessage;
|
|
428
|
+
actualError = new UnknownError(new Exception(trimmedMessage.Trim()), "TEST-JOB-ID");
|
|
429
|
+
}
|
|
417
430
|
|
|
418
431
|
var actualErrorJson = JsonSerializer.Serialize(actualError, RunWorker.SerializerOptions);
|
|
419
432
|
var expectedErrorJson = JsonSerializer.Serialize(expectedError, RunWorker.SerializerOptions);
|
|
@@ -609,5 +622,17 @@ public class MSBuildHelperTests : TestBase
|
|
|
609
622
|
// expectedError
|
|
610
623
|
new DependencyFileNotParseable("/path/to/NuGet.Config", "Some error message."),
|
|
611
624
|
];
|
|
625
|
+
|
|
626
|
+
yield return
|
|
627
|
+
[
|
|
628
|
+
// output
|
|
629
|
+
"""
|
|
630
|
+
Output:
|
|
631
|
+
Using Msbuild from '/usr/local/dotnet/current/sdk/9.0.307'.
|
|
632
|
+
Found multiple project files for '/home/dependabot/dependabot-updater/repo/path/to/packages.config'.
|
|
633
|
+
""",
|
|
634
|
+
// expectedError
|
|
635
|
+
new UnknownError(new Exception("Multiple project files found for single packages.config"), "TEST-JOB-ID"),
|
|
636
|
+
];
|
|
612
637
|
}
|
|
613
638
|
}
|