Skip to content

Commit d71a3e8

Browse files
Update integration tests build logic to account for multiple package versions (#2731)
* Update integration tests build logic to account for multiple package versions * Throw exception if a package cannot be found for the required major version.
1 parent ee3a040 commit d71a3e8

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

build/BuildSteps.cs

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public static void UpdatePackageVersionForIntegrationTests()
6565

6666
foreach (var package in packagesToUpdate)
6767
{
68-
string packageInfo = Shell.GetOutput("NuGet", $"list {package} -Source {AzureFunctionsPreReleaseFeedName} -prerelease").Split(Environment.NewLine)[0];
68+
var packageInfo = GetLatestPackageInfo(name: package.Name, majorVersion: package.MajorVersion, source: AzureFunctionsPreReleaseFeedName);
6969

7070
if (string.IsNullOrEmpty(packageInfo))
7171
{
@@ -624,9 +624,9 @@ public static void CreateIntegrationTestsBuildManifest()
624624
}
625625
}
626626

627-
private static List<string> GetV3PackageList()
627+
private static List<Package> GetV3PackageList()
628628
{
629-
const string CoreToolsBuildPackageList = "https://raw.githubusercontent.com/Azure/azure-functions-integration-tests/dev/integrationTestsBuild/V3/CoreToolsBuild.json";
629+
const string CoreToolsBuildPackageList = "https://raw.githubusercontent.com/Azure/azure-functions-integration-tests/dev/integrationTestsBuild/V3/CoreToolsBuild2.json";
630630
Uri address = new Uri(CoreToolsBuildPackageList);
631631

632632
string content = null;
@@ -640,7 +640,7 @@ private static List<string> GetV3PackageList()
640640
throw new Exception($"Failed to download package list from {CoreToolsBuildPackageList}");
641641
}
642642

643-
var packageList = JsonConvert.DeserializeObject<List<string>>(content);
643+
var packageList = JsonConvert.DeserializeObject<List<Package>>(content);
644644

645645
return packageList;
646646
}
@@ -656,5 +656,32 @@ private static void RemoveLanguageWorkers(string outputPath)
656656
}
657657
}
658658
}
659+
660+
private static string GetLatestPackageInfo(string name, string majorVersion, string source)
661+
{
662+
string includeAllVersion = !string.IsNullOrWhiteSpace(majorVersion) ? "-AllVersions" : string.Empty;
663+
string packageInfo = Shell.GetOutput("NuGet", $"list {name} -Source {source} -prerelease {includeAllVersion}");
664+
665+
if (string.IsNullOrEmpty(packageInfo))
666+
{
667+
throw new Exception($"Failed to get {name} package information from {source}.");
668+
}
669+
670+
if (!string.IsNullOrWhiteSpace(majorVersion))
671+
{
672+
foreach (var package in packageInfo.Split(Environment.NewLine))
673+
{
674+
var version = package.Split(" ")[1];
675+
if (version.StartsWith(majorVersion))
676+
{
677+
return package;
678+
}
679+
}
680+
681+
throw new Exception($"Failed to find {name} package for major version {majorVersion}.");
682+
}
683+
684+
return packageInfo;
685+
}
659686
}
660687
}

build/Package.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace Build
6+
{
7+
internal class Package
8+
{
9+
public string Name { get; set; }
10+
public string MajorVersion { get; set; }
11+
}
12+
}

0 commit comments

Comments
 (0)