Skip to content

Commit

Permalink
Allow using custom dotnet/performance branches/forks
Browse files Browse the repository at this point in the history
  • Loading branch information
MihaZupan committed Jun 20, 2024
1 parent 32beb95 commit 5bb3103
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion Runner/BenchmarkLibrariesJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ private async Task CloneRuntimeAndPerformanceAndSetupToolsAsync()
{
Task cloneRuntimeTask = RuntimeHelpers.CloneRuntimeAsync(this);

Task clonePerformanceTask = RunProcessAsync("git", "clone --no-tags --depth=1 --progress https://github.com/dotnet/performance performance", logPrefix: "Clone performance");
Task clonePerformanceTask = Task.Run(async () =>
{
(string repo, string branch) = GetDotnetPerformanceRepoSource();

await RunProcessAsync("git", $"clone --no-tags --depth=1 -b {branch} --progress https://github.com/{repo} performance", logPrefix: "Clone performance");
});

Task setupZipAndWgetTask = RunProcessAsync("apt-get", "install -y zip wget", logPrefix: "Setup zip & wget");

Expand All @@ -36,6 +41,23 @@ private async Task CloneRuntimeAndPerformanceAndSetupToolsAsync()
await setupZipAndWgetTask;
await clonePerformanceTask;
await cloneRuntimeTask;

(string Repo, string Branch) GetDotnetPerformanceRepoSource()
{
foreach (string arg in CustomArguments.Split(' '))
{
if (Uri.TryCreate(arg, UriKind.Absolute, out Uri? uri) &&
uri.IsAbsoluteUri &&
uri.Scheme == Uri.UriSchemeHttps &&
GitHubBranchRegex().Match(arg) is { Success: true } match)
{
Group branch = match.Groups[2];
return (match.Groups[1].Value, branch.Success ? branch.Value : "main");
}
}

return ("dotnet/performance", "main");
}
}

private async Task BuildRuntimeAsync()
Expand Down Expand Up @@ -191,4 +213,11 @@ await RunProcessAsync("dotnet",
// 420 74.5 0h 40m
[GeneratedRegex(@"Remained (\d+) \((.*?) %\).*?\(([\dhms ]+) from", RegexOptions.IgnoreCase | RegexOptions.Singleline)]
private static partial Regex BdnProgressSummaryRegex();

// https://github.com/MihaZupan/performance
// https://github.com/MihaZupan/performance/tree/regex
// https://github.com/MihaZupan/performance/blob/regex/.gitignore#L5
// we want 'MihaZupan/performance' and optionally 'regex'
[GeneratedRegex(@"https://github\.com/([A-Za-z\d-_]+/[A-Za-z\d-_]+)(?:/(?:tree|blob)/([A-Za-z\d-_]+)(?:[\?#/].*)?)?", RegexOptions.IgnoreCase | RegexOptions.Singleline)]
private static partial Regex GitHubBranchRegex();
}

0 comments on commit 5bb3103

Please sign in to comment.