-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[mobile] Add Android NuGet BrowserStack test to NuGet packaging pipeline #23580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
e6abde0
Reapply "[Mobile] Add BrowserStack Android MAUI Test (#23383)" (#23474)
carzh 0dd42e9
maui csproj that builds into apk successfully
carzh 4011a10
attempt to fix nuget pipeline failure
carzh 0783bb1
target only ort for building c# bindings
carzh 5a5fe4b
removed test projects from sln and updated pipeline yml
carzh 70e3a23
format
carzh 773cbb6
Revert "format"
carzh 657c60d
format again..
carzh 7a51dd5
fixed format again
carzh ec57836
Merge remote-tracking branch 'msft/main' into carzh/browserstack-andr…
carzh 573e284
removed modifications from sln and commented out the ios and maccatyl…
carzh 15d86f5
added more detailed comment
carzh 2c17720
added test_android yml + added it to nuget pipeline
carzh fba5416
fixed indent
carzh a6c9823
Merge remote-tracking branch 'msft/main' into carzh/nuget-test-androi…
carzh 1815b96
fixed curly bracket / ascii processing issue
carzh e6cd1e8
disable aot compilation for inference sample to see if that resolves …
carzh d15c053
Merge remote-tracking branch 'msft/main' into carzh/nuget-test-androi…
carzh a77f4f1
added updated asserts
carzh 7e69c93
made InferenceTest diffs more clear hopefully + removed double feedba…
carzh 24f5b3f
applied formatting suggestions + added second assert method that will…
carzh 90411e9
updated the assertion check for the expected exception message. Added…
carzh f2e7854
added comment about ep checks, fixed typos, removed aotcompilation
carzh af28ea3
removed references to the preprocessor directives in the feedback mes…
carzh a5c7182
added coreml test back in and updated feedback message
carzh d222d90
updated comment explaining appending ep tests to session options
carzh 26b965e
amended comment
carzh c70ac90
amended comment
carzh e7afd4b
Update csharp/test/Microsoft.ML.OnnxRuntime.Tests.Common/InferenceTes…
carzh 1dbd060
Merge remote-tracking branch 'msft/main' into carzh/nuget-test-androi…
carzh 644d01c
resolve '
carzh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
csharp/test/Microsoft.ML.OnnxRuntime.Tests.Common/AssertUtils.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Text; | ||
| using Xunit; | ||
|
|
||
| namespace Microsoft.ML.OnnxRuntime.Tests | ||
| { | ||
| internal static class AssertUtils | ||
| { | ||
|
|
||
| /// <summary> | ||
| /// Check if the action throws the expected exception. If it doesn't, the method passes. If it does, check for | ||
| /// the exception type and the expected exception message. More detailed Assert method to be used for unit tests | ||
| /// written with XUnit. | ||
| /// </summary> | ||
| /// <typeparam name="T">Type of exception expected to be thrown.</typeparam> | ||
| /// <param name="action">Action to be executed or tested.</param> | ||
| /// <param name="feedbackMessage">Feedback message if an unexpected exception happens.</param> | ||
| /// <param name="expectedExceptionMessage">Expected exception message. If null, the exception message is not | ||
| // checked.</param> | ||
| public static void IfThrowsCheckException<T>(Action action, string feedbackMessage, string expectedExceptionMessage = null) where T : Exception | ||
| { | ||
| try | ||
| { | ||
| action(); | ||
| } | ||
| catch (T ex) | ||
| { | ||
| if (expectedExceptionMessage == null) | ||
| { | ||
| return; | ||
| } | ||
| else | ||
| { | ||
| Assert.True(ex.Message.Contains(expectedExceptionMessage), | ||
| $"{feedbackMessage}\nExpected exception message to contain '{expectedExceptionMessage}', but got '{ex.Message}'"); | ||
| } | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| Assert.Fail($"{feedbackMessage}\nExpected {typeof(T).Name} but got {ex.GetType().Name}. "); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| /// <summary> | ||
| /// Check if the action throws the expected exception. If it doesn't, the method fails with the feedbackMessage. | ||
| /// If it does, check for the exception type and the expected exception message. More detailed Assert method to be | ||
| /// used for unit tests written with XUnit. | ||
| /// </summary> | ||
| /// <typeparam name="T">Type of exception expected to be thrown.</typeparam> | ||
| /// <param name="action">Action to be executed or tested. It is expected that the action will throw.</param> | ||
| /// <param name="feedbackMessage">Feedback message if an unexpected exception happens.</param> | ||
| /// <param name="expectedExceptionMessage">Expected exception message. If null, the exception message is not | ||
| // checked.</param> | ||
| public static void AssertThrowsCheckException<T>(Action action, string feedbackMessage, string expectedExceptionMessage = null) where T : Exception | ||
| { | ||
| try | ||
| { | ||
| action(); | ||
| Assert.Fail($"{feedbackMessage}\nExpected {typeof(T).Name} but no exception was thrown."); | ||
| } | ||
| catch (T ex) | ||
| { | ||
| if (expectedExceptionMessage == null) | ||
| { | ||
| return; | ||
| } | ||
| else | ||
| { | ||
| Assert.True(ex.Message.Contains(expectedExceptionMessage), | ||
| $"{feedbackMessage}\nExpected exception message to contain '{expectedExceptionMessage}', but got '{ex.Message}'"); | ||
| } | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| Assert.Fail($"{feedbackMessage}\nExpected {typeof(T).Name} but got {ex.GetType().Name}. "); | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
tools/ci_build/github/azure-pipelines/nuget/templates/test_android.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| parameters: | ||
| AgentPool : 'Win-CPU' | ||
| ArtifactSuffix: '' | ||
| SpecificArtifact: false | ||
| BuildId: '' | ||
|
|
||
| stages: | ||
| - stage: NuGet_Test_Android | ||
| jobs: | ||
| - job: NuGet_Test_Android | ||
| workspace: | ||
| clean: all | ||
| pool: "${{ parameters.AgentPool }}" | ||
|
|
||
| variables: | ||
| - name: OnnxRuntimeBuildDirectory | ||
| value: '$(Build.BinariesDirectory)' | ||
|
|
||
| steps: | ||
| - task: NuGetToolInstaller@0 | ||
| displayName: Use Nuget 6.10.x | ||
| inputs: | ||
| versionSpec: 6.10.x | ||
|
|
||
| - template: ../../templates/flex-downloadPipelineArtifact.yml | ||
| parameters: | ||
| StepName: 'Download Pipeline Artifact' | ||
| ArtifactName: drop-signed-nuget-${{ parameters.ArtifactSuffix }} | ||
| TargetPath: '$(Build.BinariesDirectory)\nuget-artifact' | ||
| SpecificArtifact: ${{ parameters.SpecificArtifact }} | ||
| BuildId: ${{ parameters.BuildId }} | ||
|
|
||
| - template: get-nuget-package-version-as-variable.yml | ||
| parameters: | ||
| packageFolder: '$(Build.BinariesDirectory)\nuget-artifact' | ||
|
|
||
| - task: PowerShell@2 | ||
| displayName: Install MAUI workloads | ||
| inputs: | ||
| targetType: 'inline' | ||
| script: | | ||
| dotnet workload install maui maui-android android | ||
| workingDirectory: '$(Build.SourcesDirectory)\csharp' | ||
|
|
||
| - task: PowerShell@2 | ||
| displayName: Publish Android MAUI APK | ||
| inputs: | ||
| targetType: 'inline' | ||
| script: | | ||
| dotnet nuget add source $(Build.BinariesDirectory)\nuget-artifact --name local-nuget | ||
| dotnet publish -c Release --property:UsePrebuiltNativePackage=true --property:CurrentOnnxRuntimeVersion=$(NuGetPackageVersionNumber) -f net8.0-android | ||
| workingDirectory: '$(Build.SourcesDirectory)\csharp\test\Microsoft.ML.OnnxRuntime.Tests.MAUI' | ||
|
|
||
| - task: PowerShell@2 | ||
| displayName: Run BrowserStack test | ||
| inputs: | ||
| targetType: 'inline' | ||
| script: | | ||
| dotnet test | ||
| workingDirectory: '$(Build.SourcesDirectory)\csharp\test\Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android' | ||
| env: | ||
| BROWSERSTACK_USERNAME: $(browserstack_username) | ||
| BROWSERSTACK_ACCESS_KEY: $(browserstack_access_key) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.