Skip to content

feat: Add Android+Skia+NativeAOT startup instrumentation test to CI#1244

Closed
Copilot wants to merge 8 commits intomasterfrom
copilot/update-ci-test-android-native-aot
Closed

feat: Add Android+Skia+NativeAOT startup instrumentation test to CI#1244
Copilot wants to merge 8 commits intomasterfrom
copilot/update-ci-test-android-native-aot

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 25, 2026

  • Understand existing CI structure and build scripts
  • Add Uno.Gallery/Platforms/Android/MainInstrumentation.Android.cs
  • Fix build/scripts/android-uitest-build.sh to not use UseNativeRendering=true in NAOT mode (uses Skia rendering instead)
  • Create build/scripts/android-naot-instrumentation-run.sh for instrumentation testing (installs APK, runs instrumentation, checks INSTRUMENTATION_CODE: -1)
  • Extract duplicated install_android_sdk function and SDK setup into build/scripts/android-emulator-common.sh; source it from both android-uitest-run.sh and android-naot-instrumentation-run.sh
  • Merge set -x into set -euox pipefail in android-naot-instrumentation-run.sh
  • Quote all environment variable path usages in android-naot-instrumentation-run.sh
  • Revert build/stage-uitests-android.yml to its original state (no changes)
  • Rename build/stage-uitests-android-naot.ymlbuild/stage-tests-android.yml (not "UI" tests; on-device tests)
  • Add new Android_NativeAOT_Instrumentation_Tests stage in azure-pipelines.yml referencing the new template
  • Make USE_NATIVE_RENDERING overridable via environment (USE_NATIVE_RENDERING=${USE_NATIVE_RENDERING:-true}) and pass USE_NATIVE_RENDERING=false from stage-tests-android.yml
  • Quote all environment variable usages in android-emulator-common.sh
Original prompt

This section details on the original issue you should resolve

<issue_title>Update CI to test Android+Skia+NativeAOT</issue_title>
<issue_description>PR unoplatform/uno#22676 broke Android+Native AOT startup, and the "easiest" way to detect this would be for something downstream of unoplatform/uno to run the test.

For an integration test, we need something which uses NuGet packages.

Update the Uno.Gallery to contain a new file: Uno.Gallery/Platforms/Android/MainInstrumentation.Android.cs

with the contents:

using Android.App;
using Android.OS;
using Android.Runtime;
using Android.Views;

namespace Uno.Gallery
{
	[Instrumentation(Name = "my.MainInstrumentation")]
	public class MainInstrumentation : Android.App.Instrumentation
	{
		public MainInstrumentation(IntPtr handle, JniHandleOwnership ownership)
		    : base(handle, ownership)
		{
		}

		public override void OnCreate(Bundle? savedInstanceState)
		{
			base.OnCreate(savedInstanceState);
			Finish(Result.Ok, null);
		}
	}
}

Update CI YAML scripts to:

  1. Build Uno.Gallery for Skia + NativeAOT, by using:

    dotnet publish -f net10.0-android -r android-x64 -p:TargetFrameworkOverride=net10.0-android -p:SkiaPublishAot=true '-p:ApplicationTitleVendorSuffix= (NAOT)' -p:ApplicationIdVendorSuffix=.naot -p:AndroidPackageFormat=apk -bl Uno.Gallery/*.csproj
    
  2. Deploy the .apk from (1) to an Android emulator:

    adb install Uno.Gallery/bin/Release/net10.0-android/android-x64/publish/com.nventive.uno.ui.demo.naot-Signed.apk
  3. Launch the added instrumentation:

    adb shell am instrument -w com.nventive.uno.ui.demo.naot/my.MainInstrumentation
  4. Check the output of (3) contains:

    INSTRUMENTATION_CODE: -1
    

What would you like to be added:

Why is this needed:

For which Platform:

  • iOS
  • Android
  • WebAssembly
  • WebAssembly renders for Xamarin.Forms
  • Windows
  • Build tasks

Anything else we need to know?

</issue_description>

Comments on the Issue (you are @copilot in this section)


⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.

Copilot AI changed the title [WIP] Update CI to test Android+Skia+NativeAOT feat: Add Android+Skia+NativeAOT startup instrumentation test to CI Mar 25, 2026
Copilot AI requested a review from jonpryor March 25, 2026 16:45
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.


mkdir -p $BUILD_ARTIFACTSTAGINGDIRECTORY

install_android_sdk() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot: this function is also defined in android-uitest-run.sh. You should split out this function into a common script, then source that script from both android-naot-instrumentation-run.sh and android-uitest-run.sh.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in d49f7d3. Extracted the SDK setup variables, cmdline-tools download, and install_android_sdk function into a new build/scripts/android-emulator-common.sh script. Both android-uitest-run.sh and android-naot-instrumentation-run.sh now source it before their respective emulator setup.

# Wait for the emulator to finish booting
source $BUILD_SOURCESDIRECTORY/build/scripts/android-uitest-wait-systemui.sh 500

$ANDROID_HOME/platform-tools/adb devices
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot: everything involving environment variables should be always be quoted: "$ANDROID_HOME/platform-tools/adb"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in c0d1090 — all $ANDROID_HOME, $LATEST_CMDLINE_TOOLS_PATH, $BUILD_SOURCESDIRECTORY, $BUILD_ARTIFACTSTAGINGDIRECTORY, and other env-var-based paths are now quoted throughout the script.

IFS=$'\n\t'

# echo commands
set -x
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot: this set -x can be merged with the previous set command, as set -euox pipefail.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in c0d1090 — merged into set -euox pipefail and removed the separate set -x line and its comment.

Comment thread build/stage-uitests-android.yml Outdated

- job: Android_Tests_NativeAOT
displayName: 'Run Android+NativeAOT UI Tests'
displayName: 'Run Android+Skia+NativeAOT Instrumentation Test'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot: stage-uitests-android.yml SHOULD NOT BE CHANGED.

New Instrumentation-related tests should be done in either a new .yml file or within azure-pipelines.yml.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 81b7b5a. Reverted stage-uitests-android.yml to its original state. Created a new build/stage-uitests-android-naot.yml with the instrumentation build and run jobs, and added an Android_NativeAOT_Instrumentation_Tests stage in azure-pipelines.yml that references it.

…naot.yml and azure-pipelines.yml stage

Co-authored-by: jonpryor <155958+jonpryor@users.noreply.github.com>
Agent-Logs-Url: https://github.com/unoplatform/Uno.Gallery/sessions/d8bfa5f9-fb10-4120-b280-1e9ae6400392
@unodevops
Copy link
Copy Markdown

⚠️⚠️ The build 203748 has failed on Uno.Gallery - CI.

@jonpryor
Copy link
Copy Markdown
Contributor

@copilot: rename build/stage-uitests-android-naot.yml to build/stage-tests-android.yml. They are not "UI" tests; they are on-device tests.

Copy link
Copy Markdown
Author

Copilot AI commented Mar 26, 2026

@copilot: rename build/stage-uitests-android-naot.yml to build/stage-tests-android.yml. They are not "UI" tests; they are on-device tests.

Done in dec9239 — renamed to build/stage-tests-android.yml and updated the reference in azure-pipelines.yml.

@unodevops
Copy link
Copy Markdown

⚠️⚠️ The build 203946 has failed on Uno.Gallery - CI.

Comment thread build/scripts/android-uitest-build.sh Outdated
# Build the sample with Skia+NativeAOT enabled (no native rendering)
publish_extra+=("-m:1" "-p:SkiaPublishAot=true" "-p:ApplicationTitleVendorSuffix= (NAOT)" "-p:ApplicationIdVendorSuffix=.naot")
BINLOG_SUFFIX="-naot"
USE_NATIVE_RENDERING=false
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot: USE_NATIVE_RENDERING cannot be within this if [ "${NAOT:-0}" = "1" ] block, because we require Android native to do UI tests, and commit f31954e tests Android+Native+NativeAOT for UI tests.

Instead, the USE_NATIVE_RENDERING initialize, above, should instead provide an overridable default:

USE_NATIVE_RENDERING=${USE_NATIVE_RENDERING:-true}

Then build/stage-tests-android.yml can do:

NAOT=1 USE_NATIVE_RENDERING=false $(build.sourcesdirectory)/build/scripts/android-uitest-build.sh

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 7543269USE_NATIVE_RENDERING is now initialized with ${USE_NATIVE_RENDERING:-true} before the if block, and build/stage-tests-android.yml passes USE_NATIVE_RENDERING=false alongside NAOT=1.

Copilot AI requested a review from jonpryor March 26, 2026 20:35
# Requires BUILD_SOURCESDIRECTORY to be set by the caller.

# Override Android SDK tooling
export ANDROID_HOME=$BUILD_SOURCESDIRECTORY/build/android-sdk
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot: as mentioned before, all use of environment variables must be quoted. This is so that if the environment variable value contains a space , it doesn't blow everything up.

export ANDROID_HOME="$BUILD_SOURCESDIRECTORY/build/android-sdk"
export ANDROID_SDK_ROOT="$BUILD_SOURCESDIRECTORY/build/android-sdk"
export LATEST_CMDLINE_TOOLS_PATH="$ANDROID_SDK_ROOT/cmdline-tools/latest"
export CMDLINETOOLS=commandlinetools-mac-8512546_latest.zip
mkdir -p "$ANDROID_HOME"

ALL ENVIRONMENT VARIABLE USAGE MUST BE QUOTED.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8d18e85 — all environment variable usages in android-emulator-common.sh are now quoted, including the export assignments, mkdir, wget, unzip, rm, mv, conditionals, touch, and sdkmanager invocations.

Copilot AI requested a review from jonpryor March 26, 2026 20:51
@jonpryor
Copy link
Copy Markdown
Contributor

jonpryor commented Apr 1, 2026

Superseded by #1245.

@jonpryor jonpryor closed this Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update CI to test Android+Skia+NativeAOT

4 participants