Skip to content

Commit

Permalink
[ci] Enable CI for Maestro bot PRs (#5837)
Browse files Browse the repository at this point in the history
Context: #5830

We'd like to have our PR builds and tests run automatically against
dependency bump PRs created by the dotnet Maestro bot.  To do this, I've
overridden the CI triggers in the Xamarin.Android-PR pipeline to include
branches that begin with `darc-*`.

These branches will now trigger a build automatically, but it will be
building an individual commit and not a merge commit.  The xaprepare
tool has been updated to enable all test jobs in these cases.
  • Loading branch information
pjcollins authored Apr 13, 2021
1 parent bf4f4f4 commit 65bf398
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,32 @@ protected override async Task<bool> Execute (Context context)
{
Log.StatusLine ("Determining test jobs to run...");

var runAllTestsLoggingCommand = "##vso[task.setvariable variable=TestAreas;isOutput=true]MSBuild,MSBuildDevice,BCL,Designer";

string commitRevision = Environment.GetEnvironmentVariable ("BUILD_SOURCEVERSION");
string commitMessage = Environment.GetEnvironmentVariable ("BUILD_SOURCEVERSIONMESSAGE");
if (string.IsNullOrEmpty (commitRevision) || string.IsNullOrEmpty (commitMessage)) {
Log.ErrorLine ("One or more source version variable values were empty:");
Log.ErrorLine ($"BUILD_SOURCEVERSION='{commitRevision}' BUILD_SOURCEVERSIONMESSAGE='{commitMessage}'.");
return false;
Log.WarningLine ("One or more source version variable values were empty:");
Log.WarningLine ($"BUILD_SOURCEVERSION='{commitRevision}' BUILD_SOURCEVERSIONMESSAGE='{commitMessage}'.");
Log.MessageLine (runAllTestsLoggingCommand);
return true;
}

// Assume we're building a merge commit as part of an Azure Pipelines PR build. Otherwise, this step will fail.
// Assume we're building a merge commit as part of an Azure Pipelines PR build. Otherwise, run all tests.
// Example: Merge 0b66502c8b9f33cbb8d21b2dab7c100629aec081 into 0bef8aa5cd74d83d77c4e2b3f63975a0deb804b3
var commitMessagePieces = commitMessage.Split (new string [] { " " }, StringSplitOptions.RemoveEmptyEntries);
if (string.IsNullOrEmpty (commitMessagePieces [3])) {
Log.ErrorLine ($"Unable to parse merge commit message from: '{commitMessage}'.");
return false;
Log.WarningLine ($"Unable to parse merge commit message from: '{commitMessage}'.");
Log.MessageLine (runAllTestsLoggingCommand);
return true;
}

var git = new GitRunner (context);
var filesChanged = await git.RunCommandForOutputAsync (BuildPaths.XamarinAndroidSourceRoot, "diff", "--name-only", commitRevision, commitMessagePieces [3]);
if (filesChanged == null || filesChanged.Count < 1) {
Log.ErrorLine ($"Unable to determine if any files were changed in this PR.");
return false;
Log.WarningLine ($"Unable to determine if any files were changed in this PR.");
Log.MessageLine (runAllTestsLoggingCommand);
return true;
}

var testAreas = new HashSet<string> ();
Expand Down

0 comments on commit 65bf398

Please sign in to comment.