Skip to content

Commit

Permalink
Add summary to GenCatalog
Browse files Browse the repository at this point in the history
  • Loading branch information
terrajobst committed Apr 29, 2024
1 parent 5694e89 commit 2c1f203
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
22 changes: 17 additions & 5 deletions src/GenCatalog/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ internal sealed class Main : IConsoleMain
private readonly ApisOfDotNetStore _store;
private readonly ApisOfDotNetWebHook _webHook;
private readonly GitHubActionsEnvironment _gitHubActionsEnvironment;
private readonly GitHubActionsSummaryTable _summaryTable;

public Main(ApisOfDotNetPathProvider pathProvider,
ApisOfDotNetStore store,
ApisOfDotNetWebHook webHook,
GitHubActionsEnvironment gitHubActionsEnvironment)
GitHubActionsEnvironment gitHubActionsEnvironment,
GitHubActionsSummaryTable summaryTable)
{
ThrowIfNull(pathProvider);
ThrowIfNull(store);
Expand All @@ -27,6 +29,7 @@ internal sealed class Main : IConsoleMain
_store = store;
_webHook = webHook;
_gitHubActionsEnvironment = gitHubActionsEnvironment;
_summaryTable = summaryTable;
}

public async Task RunAsync(string[] args, CancellationToken cancellationToken)
Expand Down Expand Up @@ -57,6 +60,11 @@ public async Task RunAsync(string[] args, CancellationToken cancellationToken)
await _store.UploadApiCatalogAsync(catalogModelPath);
await _store.UploadSuffixTreeAsync(suffixTreePath);

var catalogSize = new FileInfo(catalogModelPath).Length;
var suffixTreeSize = new FileInfo(suffixTreePath).Length;
_summaryTable.AppendBytes("Catalog Size", catalogSize);
_summaryTable.AppendBytes("Suffix Tree Size", suffixTreeSize);

Console.WriteLine($"Completed in {stopwatch.Elapsed}");
Console.WriteLine($"Peak working set: {Process.GetCurrentProcess().PeakWorkingSet64 / (1024 * 1024):N2} MB");
}
Expand Down Expand Up @@ -87,22 +95,26 @@ private async Task DownloadArchivedPlatformsAsync(string archivePath)
archive.ExtractToDirectory(localDirectory);
}
}
_summaryTable.AppendNumber("#Archived Frameworks", Directory.GetDirectories(archivePath).Length);

}

private static async Task DownloadPackagedPlatformsAsync(string archivePath, string packsPath)
private async Task DownloadPackagedPlatformsAsync(string archivePath, string packsPath)
{
await FrameworkDownloader.DownloadAsync(archivePath, packsPath);
var frameworkCount = await FrameworkDownloader.DownloadAsync(archivePath, packsPath);
_summaryTable.AppendNumber("#Packaged Frameworks", frameworkCount);
}

private static async Task DownloadDotnetPackageListAsync(string packageListPath)
private async Task DownloadDotnetPackageListAsync(string packageListPath)
{
if (File.Exists(packageListPath))
{
Console.WriteLine($"Skipping download of {Path.GetFileName(packageListPath)}.");
return;
}

await DotnetPackageIndex.CreateAsync(packageListPath);
var packageCount = await DotnetPackageIndex.CreateAsync(packageListPath);
_summaryTable.AppendNumber("#Packages", packageCount);
}

private static Task GeneratePlatformIndexAsync(string frameworksPath, string indexFrameworksPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Terrajobst.ApiCatalog;

public static class FrameworkDownloader
{
public static async Task DownloadAsync(string frameworksPath, string packsPath)
public static async Task<int> DownloadAsync(string frameworksPath, string packsPath)
{
Validate();

Expand Down Expand Up @@ -144,6 +144,8 @@ public static async Task DownloadAsync(string frameworksPath, string packsPath)
var manifestPath = Path.Join(frameworksPath, FrameworkManifest.FileName);
var manifest = new FrameworkManifest(entries);
manifest.Save(manifestPath);

return entries.Count;
}

private static IEnumerable<NuGetFramework> GetFrameworkNames(FrameworkDefinition framework, PackReference pack)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static class DotnetPackageIndex
"aspire"
};

public static async Task CreateAsync(string packageListPath)
public static async Task<int> CreateAsync(string packageListPath)
{
var packages = await GetPackagesAsync(NuGetFeeds.NuGetOrg, NuGetFeeds.NightlyLatest);

Expand All @@ -41,6 +41,8 @@ public static async Task CreateAsync(string packageListPath)

Directory.CreateDirectory(Path.GetDirectoryName(packageListPath)!);
packageDocument.Save(packageListPath);

return packages.Count;
}

private static async Task<IReadOnlyList<PackageIdentity>> GetPackagesAsync(params string[] feedUrls)
Expand Down

0 comments on commit 2c1f203

Please sign in to comment.