Skip to content

Commit

Permalink
Merge pull request #313 from unoplatform/dev/jela/telemetry-adjust
Browse files Browse the repository at this point in the history
Adjust for updated macOS agents, fix android emulator install
  • Loading branch information
jeromelaban authored Dec 9, 2024
2 parents bea5977 + 3f39c22 commit 94fa359
Show file tree
Hide file tree
Showing 11 changed files with 206 additions and 56 deletions.
46 changes: 15 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,63 +189,52 @@ jobs:
include:
- manifest: 'manifests/uno.ui.manifest.json'
manifest_name: Stable
os: macos-12
os: macos-14
dotnet_version: 8.0.300

- manifest: 'manifests/uno.ui-preview.manifest.json'
manifest_name: Preview
previous_tool_version: ''
previous_tool_params: ''
os: macos-12
os: macos-14
dotnet_version: 8.0.300

# - manifest: 'manifests/uno.ui-preview-major.manifest.json'
# manifest_name: Preview net9
# previous_tool_version: ''
# previous_tool_params: ''
# os: macos-12
# dotnet_version: 8.0.100

- manifest: 'manifests/uno.ui.manifest.json'
manifest_name: Stable Upgrade
previous_tool_version: 1.17.0
previous_tool_params: ''
os: macos-12
os: macos-14
dotnet_version: 8.0.300

- manifest: 'manifests/uno.ui-preview.manifest.json'
manifest_name: Preview Upgrade
previous_tool_version: 1.17.0
previous_tool_params: '--pre'
os: macos-12
os: macos-14
dotnet_version: 8.0.300

- manifest: 'manifests/uno.ui.manifest.json'
manifest_name: Test default Uno template TFM's
os: macos-12
os: macos-14
dotnet_version: 8.0.300
tool_params: '--tfm net8.0-android --tfm net8.0-ios --tfm net8.0-maccatalyst --tfm net8.0-windows10.0.19041 --tfm net8.0-browserwasm --tfm net8.0-desktop'

- manifest: 'manifests/uno.ui.manifest.json'
manifest_name: Test net8.0-android\ios TFM's
os: macos-12
os: macos-14
dotnet_version: 8.0.300
tool_params: '--tfm net8.0-android --tfm net8.0-ios'

- manifest: 'manifests/uno.ui.manifest.json'
manifest_name: Test net8.0-browserwasm TFM
os: macos-12
os: macos-14
dotnet_version: 8.0.300
tool_params: '--tfm net8.0-browserwasm'
# - manifest: 'manifests/uno.ui-preview-major.manifest.json'
# manifest_name: Preview Upgrade net8
# previous_tool_version: 1.4.2
# previous_tool_params: '--pre'
# os: macos-12
# dotnet_version: 8.0.100

# Disabled for android emulator setup issues
# - manifest: 'manifests/uno.ui.manifest.json'
# manifest_name: Stable
# os: macos-13
# dotnet_version: 8.0.300

- manifest: 'manifests/uno.ui.manifest.json'
manifest_name: Stable
os: macos-15
dotnet_version: 8.0.300

runs-on: ${{ matrix.os }}

Expand All @@ -261,11 +250,6 @@ jobs:
name: NuGet
path: ${{ github.workspace }}/NuGet

- name: Setup .NET SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.x'

# Preinstall .NET as it may fail on some build agents
- name: Setup .NET Core ${{ matrix.dotnet_version }}
uses: actions/setup-dotnet@v1
Expand Down
42 changes: 27 additions & 15 deletions UnoCheck/AndroidSdk/AvdManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public override FileInfo FindToolPath(DirectoryInfo androidSdkHome)
}


public void Create(string name, string sdkId, string device = null, string path = null, string tag = null, bool force = false, bool interactive = false)
public (bool success, string[] output) Create(string name, string sdkId, string device = null, string path = null, string tag = null, bool force = false, bool interactive = false)
{
var args = new List<string> {
"create", "avd", "--name", name, "--package", $"\"{sdkId}\""
Expand All @@ -81,13 +81,13 @@ public void Create(string name, string sdkId, string device = null, string path
args.Add($"\"{device}\"");
}

if (!string.IsNullOrEmpty(path))
{
args.Add("-c");
args.Add($"\"{path}\"");
}
if (!string.IsNullOrEmpty(path))
{
args.Add("-c");
args.Add($"\"{path}\"");
}

if (force)
if (force)
args.Add("--force");

if (!string.IsNullOrEmpty(path))
Expand All @@ -96,15 +96,15 @@ public void Create(string name, string sdkId, string device = null, string path
args.Add($"\"{path}\"");
}

AvdManagerRun(args.ToArray());
return AvdManagerRun("no", args.ToArray());
}

public void Delete(string name)
public (bool success, string[] output) Delete(string name)
{
AvdManagerRun("delete", "avd", "-n", name);
return AvdManagerRun("delete", "avd", "-n", name);
}

public void Move(string name, string path = null, string newName = null)
public (bool success, string[] output) Move(string name, string path = null, string newName = null)
{
var args = new List<string> {
"move", "avd", "-n", name
Expand All @@ -122,7 +122,7 @@ public void Move(string name, string path = null, string newName = null)
args.Add(newName);
}

AvdManagerRun(args.ToArray());
return AvdManagerRun(null, args.ToArray());
}

static Regex rxListTargets = new Regex(@"id:\s+(?<id>[^\n]+)\s+Name:\s+(?<name>[^\n]+)\s+Type\s?:\s+(?<type>[^\n]+)\s+API level\s?:\s+(?<api>[^\n]+)\s+Revision\s?:\s+(?<revision>[^\n]+)", RegexOptions.Multiline | RegexOptions.Compiled);
Expand Down Expand Up @@ -278,7 +278,7 @@ public IEnumerable<AvdDevice> ListDevices()
}


IEnumerable<string> AvdManagerRun(params string[] args)
(bool success, string[] output) AvdManagerRun(string forcedInput = null, params string[] args)
{
var adbManager = FindToolPath(AndroidSdkHome);
var java = Java;
Expand Down Expand Up @@ -308,8 +308,9 @@ IEnumerable<string> AvdManagerRun(params string[] args)
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.RedirectStandardInput = !string.IsNullOrWhiteSpace(forcedInput);

var output = new List<string>();
var output = new List<string>();

proc.OutputDataReceived += (s, e) =>
{
Expand All @@ -322,12 +323,23 @@ IEnumerable<string> AvdManagerRun(params string[] args)
output.Add(e.Data);
};

Util.Log($"Running {proc.StartInfo.FileName} {proc.StartInfo.Arguments} in {proc.StartInfo.WorkingDirectory}");

proc.Start();

if (!string.IsNullOrWhiteSpace(forcedInput))
{
proc.StandardInput.WriteLine(forcedInput);
proc.StandardInput.Flush();
proc.StandardInput.Close();
}

proc.BeginOutputReadLine();
proc.BeginErrorReadLine();
proc.WaitForExit();

return output;

return (proc.ExitCode == 0, output.ToArray());
}
}
}
10 changes: 9 additions & 1 deletion UnoCheck/CheckCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public class CheckCommand : AsyncCommand<CheckSettings>
{
public override async Task<int> ExecuteAsync(CommandContext context, CheckSettings settings)
{
var sw = Stopwatch.StartNew();
TelemetryClient.TrackStartCheck();

Util.Verbose = settings.Verbose;
Util.LogFile = settings.LogFile;
Util.CI = settings.CI;
Expand Down Expand Up @@ -281,6 +284,8 @@ public override async Task<int> ExecuteAsync(CommandContext context, CheckSettin

if (hasErrors)
{
TelemetryClient.TrackCheckFail(sw.Elapsed, string.Join(",", erroredChecks.Select(c => c.Checkup.Id)));

AnsiConsole.Console.WriteLine();

foreach (var ec in erroredChecks)
Expand All @@ -291,6 +296,8 @@ public override async Task<int> ExecuteAsync(CommandContext context, CheckSettin
}
else if (hasWarnings)
{
TelemetryClient.TrackCheckWarning(sw.Elapsed, string.Join(",", warningChecks.Select(c => c.Checkup.Id)));

AnsiConsole.Console.WriteLine();

foreach (var wc in warningChecks)
Expand All @@ -301,7 +308,8 @@ public override async Task<int> ExecuteAsync(CommandContext context, CheckSettin
}
else
{
AnsiConsole.MarkupLine($"[bold blue]{Icon.Success} Congratulations, everything looks great![/]");
TelemetryClient.TrackCheckSuccess(sw.Elapsed);
AnsiConsole.MarkupLine($"[bold blue]{Icon.Success} Congratulations, everything looks great![/]");
}

Console.Title = ToolInfo.ToolName;
Expand Down
33 changes: 29 additions & 4 deletions UnoCheck/Checkups/AndroidEmulatorCheckup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public override Task<DiagnosticResult> Examine(SharedState history)

AndroidSdk.AvdManager avdManager = null;

var javaHome = history.GetEnvironmentVariable("JAVA_HOME");
var javaHome = history.GetEnvironmentVariable("LATEST_JAVA_HOME") ?? history.GetEnvironmentVariable("JAVA_HOME");
string java = null;
if (!string.IsNullOrEmpty(javaHome) && Directory.Exists(javaHome))
java = Path.Combine(javaHome, "bin", "java" + (Util.IsWindows ? ".exe" : ""));
Expand Down Expand Up @@ -90,6 +90,12 @@ public override Task<DiagnosticResult> Examine(SharedState history)
{
var devices = avdManager.ListDevices();

Util.Log($"Listing devices:");
foreach (var device in devices)
{
Util.Log($"Device: {device.Name} ({device.Id})");
}

preferredDevice = devices.FirstOrDefault(d => d.Name.Contains("pixel", StringComparison.OrdinalIgnoreCase));
}
else
Expand Down Expand Up @@ -120,7 +126,7 @@ public override Task<DiagnosticResult> Examine(SharedState history)
var installer = new AndroidSDKInstaller(new Helper(), AndroidManifestType.GoogleV2);

var androidSdkPath = history.GetEnvironmentVariable("ANDROID_SDK_ROOT") ?? history.GetEnvironmentVariable("ANDROID_HOME");
installer.Discover(new List<string> { androidSdkPath});
installer.Discover(new List<string> { androidSdkPath });

var sdkInstance = installer.FindInstance(androidSdkPath);

Expand All @@ -145,8 +151,27 @@ public override Task<DiagnosticResult> Examine(SharedState history)

var sdkId = sdkPackage?.Path ?? me.SdkId;

avdManager.Create($"Android_Emulator_{me.ApiLevel}", sdkId, device: preferredDevice?.Id, tag: "google_apis", force: true, interactive: true);
return Task.CompletedTask;
var result = avdManager.Create(
$"Android_Emulator_{me.ApiLevel}",
sdkId,
device: preferredDevice?.Id,
tag: "google_apis",
force: true,
interactive: true);

foreach (var msg in result.output)
{
Util.Log(msg);
}

if (result.success)
{
return Task.CompletedTask;
}
else
{
throw new Exception($"Unable to create Emulator");
}
}
catch (Exception ex)
{
Expand Down
12 changes: 10 additions & 2 deletions UnoCheck/Checkups/OpenJdkCheckup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public override Task<DiagnosticResult> Examine(SharedState history)

var jdks = xamJdks.Concat(FindJdks())
.GroupBy(j => j.Directory.FullName)
.Select(g => g.First());
.Select(g => g.First())
.OrderBy(s => s.Version);

var ok = false;

Expand Down Expand Up @@ -96,7 +97,14 @@ public override Task<DiagnosticResult> Examine(SharedState history)
ReportStatus($"{jdk.Version} ({jdk.Directory.FullName})", null);
}

if (ok)
// Setup the latest LATEST_JAVA_HOME
if (jdks.Any())
{
var latest = jdks.Last();
history.SetEnvironmentVariable("LATEST_JAVA_HOME", latest.Directory.FullName);
}

if (ok)
return Task.FromResult(DiagnosticResult.Ok(this));

if (Util.IsLinux)
Expand Down
2 changes: 2 additions & 0 deletions UnoCheck/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ internal class Program
{
static Task<int> Main(string[] args)
{
TelemetryClient.Init();

// Need to register the code pages provider for code that parses
// and later needs ISO-8859-2
System.Text.Encoding.RegisterProvider(
Expand Down
Loading

0 comments on commit 94fa359

Please sign in to comment.