Skip to content

Commit

Permalink
Avoid rebuilding libs on CLR-only changes
Browse files Browse the repository at this point in the history
  • Loading branch information
MihaZupan committed Nov 30, 2024
1 parent 8b40947 commit 45ff81a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/run-script.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Setup .NET 8.0
- name: Setup .NET 9.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0'
dotnet-version: '9.0'

- name: Run script
shell: pwsh
Expand Down
15 changes: 15 additions & 0 deletions Runner/Helpers/GitHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,19 @@ private static bool ShouldSkipLine(string line)
span.StartsWith("@@", StringComparison.Ordinal) ||
span.StartsWith("\\ No newline at end of file", StringComparison.Ordinal);
}

public static async Task<List<string>> GetChangedFilesAsync(JobBase job, string baselineRef, string workDir)
{
List<string> lines = [];

await job.RunProcessAsync("git",
$"diff --name-only {baselineRef}",
lines,
workDir: workDir,
checkExitCode: false,
suppressOutputLogs: true,
suppressStartingLog: true);

return lines;
}
}
18 changes: 17 additions & 1 deletion Runner/Jobs/JitDiffJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ public static async Task BuildAndCopyRuntimeBranchBitsAsync(JobBase job, string
{
string arch = IsArm ? "arm64" : "x64";

await job.RunProcessAsync("bash", $"build.sh clr+libs -c Release {RuntimeHelpers.LibrariesExtraBuildArgs}", logPrefix: $"{branch} release", workDir: "runtime");
string targets = await ShouldBuildsLibsAsync() ? "clr+libs" : "clr";

await job.RunProcessAsync("bash", $"build.sh {targets} -c Release {RuntimeHelpers.LibrariesExtraBuildArgs}", logPrefix: $"{branch} release", workDir: "runtime");

Task copyReleaseBitsTask = RuntimeHelpers.CopyReleaseArtifactsAsync(job, branch, $"artifacts-{branch}");

Expand All @@ -94,6 +96,20 @@ public static async Task BuildAndCopyRuntimeBranchBitsAsync(JobBase job, string
}

await copyReleaseBitsTask;

async Task<bool> ShouldBuildsLibsAsync()
{
if (branch == "pr")
{
List<string> changedFiles = await GitHelper.GetChangedFilesAsync(job, "main", "runtime");

return changedFiles.Any(f =>
!f.StartsWith("src/coreclr/", StringComparison.OrdinalIgnoreCase) ||
f.Contains("/System.Private.CoreLib/", StringComparison.OrdinalIgnoreCase));
}

return true;
}
}

private async Task<string> CollectFrameworksDiffsAsync()
Expand Down
2 changes: 1 addition & 1 deletion Runner/Runner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<NoWarn>${NoWarn};IDE0305</NoWarn>
</PropertyGroup>
Expand Down

0 comments on commit 45ff81a

Please sign in to comment.