Skip to content

Commit

Permalink
Add an argument for device OS version (#2558)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattleibow committed Aug 17, 2023
1 parent 0f4f103 commit 02145c5
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
]
},
"microsoft.dotnet.xharness.cli": {
"version": "8.0.0-prerelease.23307.1",
"version": "8.0.0-prerelease.23407.2",
"commands": [
"xharness"
]
Expand Down
68 changes: 41 additions & 27 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,14 @@ Task ("tests-netfx")
if (SUPPORT_VULKAN)
testAssemblies.Add ("SkiaSharp.Vulkan.Tests.Console");
foreach (var testAssembly in testAssemblies) {
// build
var csproj = $"./tests/{testAssembly}/{testAssembly}.csproj";
RunDotNetBuild (csproj, platform: arch, properties: new Dictionary<string, string> {
{ "TargetFramework", tfm }
});
// build
if (!SKIP_BUILD) {
RunDotNetBuild (csproj, platform: arch, properties: new Dictionary<string, string> {
{ "TargetFramework", tfm }
});
}
// test
DirectoryPath results = $"./output/logs/testlogs/{testAssembly}/{DATE_TIME_STR}/{tfm}-{arch}";
Expand Down Expand Up @@ -251,11 +254,14 @@ Task ("tests-netcore")
if (SUPPORT_VULKAN)
testAssemblies.Add ("SkiaSharp.Vulkan.Tests.Console");
foreach (var testAssembly in testAssemblies) {
// build
var csproj = $"./tests/{testAssembly}/{testAssembly}.csproj";
RunDotNetBuild (csproj, properties: new Dictionary<string, string> {
{ "TargetFramework", tfm }
});
// build
if (!SKIP_BUILD) {
RunDotNetBuild (csproj, properties: new Dictionary<string, string> {
{ "TargetFramework", tfm }
});
}
// test
var results = $"./output/logs/testlogs/{testAssembly}/{DATE_TIME_STR}/{tfm}";
Expand Down Expand Up @@ -294,12 +300,14 @@ Task ("tests-android")
FilePath app = $"./tests/SkiaSharp.Tests.Devices/bin/{configuration}/{tfm}/{rid}/com.companyname.SkiaSharpTests-Signed.apk";
// build the app
RunDotNetBuild (csproj,
configuration: configuration,
properties: new Dictionary<string, string> {
{ "TargetFramework", tfm },
{ "RuntimeIdentifier", rid },
});
if (!SKIP_BUILD) {
RunDotNetBuild (csproj,
configuration: configuration,
properties: new Dictionary<string, string> {
{ "TargetFramework", tfm },
{ "RuntimeIdentifier", rid },
});
}
// run the tests
DirectoryPath results = $"./output/logs/testlogs/SkiaSharp.Tests.Devices.Android/{DATE_TIME_STR}";
Expand All @@ -324,12 +332,14 @@ Task ("tests-ios")
FilePath app = $"./tests/SkiaSharp.Tests.Devices/bin/{configuration}/{tfm}/{rid}/SkiaSharp.Tests.Devices.app";
// package the app
RunDotNetBuild (csproj,
configuration: configuration,
properties: new Dictionary<string, string> {
{ "TargetFramework", tfm },
{ "RuntimeIdentifier", rid },
});
if (!SKIP_BUILD) {
RunDotNetBuild (csproj,
configuration: configuration,
properties: new Dictionary<string, string> {
{ "TargetFramework", tfm },
{ "RuntimeIdentifier", rid },
});
}
// run the tests
DirectoryPath results = $"./output/logs/testlogs/SkiaSharp.Tests.Devices.iOS/{DATE_TIME_STR}";
Expand All @@ -354,12 +364,14 @@ Task ("tests-maccatalyst")
FilePath app = $"./tests/SkiaSharp.Tests.Devices/bin/{configuration}/{tfm}/{rid}/SkiaSharp.Tests.Devices.app";
// package the app
RunDotNetBuild (csproj,
configuration: configuration,
properties: new Dictionary<string, string> {
{ "TargetFramework", tfm },
{ "RuntimeIdentifier", rid },
});
if (!SKIP_BUILD) {
RunDotNetBuild (csproj,
configuration: configuration,
properties: new Dictionary<string, string> {
{ "TargetFramework", tfm },
{ "RuntimeIdentifier", rid },
});
}
// run the tests
DirectoryPath results = $"./output/logs/testlogs/SkiaSharp.Tests.Devices.MacCatalyst/{DATE_TIME_STR}";
Expand All @@ -375,7 +387,9 @@ Task ("tests-wasm")
.IsDependentOn ("externals-wasm")
.Does (() =>
{
RunDotNetBuild ("./tests/SkiaSharp.Tests.Wasm.sln");
if (!SKIP_BUILD) {
RunDotNetBuild ("./tests/SkiaSharp.Tests.Wasm.sln");
}
IProcess serverProc = null;
try {
Expand Down
2 changes: 2 additions & 0 deletions scripts/azure-pipelines-variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ variables:
ENABLE_CODE_COVERAGE: true
EMSCRIPTEN_VERSION: 3.1.12
Codeql.Enabled: true
IOS_TEST_DEVICE_VERSION: 16.4
ANDROID_TEST_DEVICE_VERSION: 34
5 changes: 5 additions & 0 deletions scripts/azure-templates-bootstrapper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,11 @@ jobs:
- ${{ if eq(parameters.docker, '') }}:
- ${{ if endsWith(parameters.name, '_windows') }}:
- pwsh: |
Get-Content $PSCommandPath
dotnet tool restore
${{ parameters.initScript }}
dotnet cake --target=${{ parameters.target }} --verbosity=${{ parameters.verbosity }} --configuration=${{ coalesce(parameters.configuration, 'Release') }} ${{ parameters.additionalArgs }}
env:
JavaSdkDirectory: $(JAVA_HOME)
LLVM_HOME: $(LLVM_HOME)
Expand All @@ -288,9 +290,11 @@ jobs:
condition: and(succeeded(), eq(variables['DOWNLOAD_EXTERNALS'], ''))
- ${{ if not(endsWith(parameters.name, '_windows')) }}:
- bash: |
cat ${BASH_SOURCE[0]}
dotnet tool restore
${{ parameters.initScript }}
dotnet cake --target=${{ parameters.target }} --verbosity=${{ parameters.verbosity }} --configuration=${{ coalesce(parameters.configuration, 'Release') }} ${{ parameters.additionalArgs }}
env:
JavaSdkDirectory: $(JAVA_HOME)
displayName: Run the bootstrapper for ${{ parameters.target }}
Expand All @@ -309,6 +313,7 @@ jobs:
echo dotnet tool restore > cmd.sh
echo dotnet cake --target=${{ parameters.target }} --verbosity=${{ parameters.verbosity }} --configuration=${{ coalesce(parameters.configuration, 'Release') }} ${{ parameters.additionalArgs }} >> cmd.sh
sed -i 's/--gnArgs=\" \"//' cmd.sh
cat cmd.sh
displayName: Generate the script for the Docker image
condition: and(succeeded(), eq(variables['DOWNLOAD_EXTERNALS'], ''))
- bash: |
Expand Down
16 changes: 8 additions & 8 deletions scripts/azure-templates-stages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ stages:
buildPipelineType: ${{ parameters.buildPipelineType }}
vmImage: ${{ parameters.VM_IMAGE_MAC }}
target: tests-android
additionalArgs: --device=android-emulator-64_34 --skipExternals="all" --coverage=$(ENABLE_CODE_COVERAGE)
additionalArgs: --device=android-emulator-64 --deviceVersion=$(ANDROID_TEST_DEVICE_VERSION) --skipExternals="all" --coverage=$(ENABLE_CODE_COVERAGE)
shouldPublish: false
requiredArtifacts:
- name: native_android_x86_macos
Expand All @@ -623,21 +623,21 @@ stages:
preBuildSteps:
- pwsh: .\scripts\install-android-package.ps1 -Package "emulator"
displayName: Install the Android emulator
- pwsh: .\scripts\install-android-package.ps1 -Package "system-images;android-34;google_apis;x86_64"
displayName: Install the Android API 34 emulator image
- pwsh: .\scripts\install-android-package.ps1 -Package "system-images;android-$(ANDROID_TEST_DEVICE_VERSION);google_apis;x86_64"
displayName: Install the Android API $(ANDROID_TEST_DEVICE_VERSION) emulator image
postBuildSteps:
- task: PublishTestResults@2
displayName: Publish the Android test results
condition: always()
inputs:
testResultsFormat: xUnit
testResultsFiles: 'output/logs/testlogs/**/TestResults.xml'
testRunTitle: 'Android Tests'
testRunTitle: 'Android Tests (API $(ANDROID_TEST_DEVICE_VERSION))'
- task: PublishBuildArtifacts@1
displayName: Publish the test logs
condition: always()
inputs:
artifactName: testlogs_android
artifactName: testlogs_android_$(ANDROID_TEST_DEVICE_VERSION)
pathToPublish: 'output/logs/testlogs'
- template: azure-templates-bootstrapper.yml # Tests|ios (macOS)
parameters:
Expand All @@ -646,7 +646,7 @@ stages:
buildPipelineType: ${{ parameters.buildPipelineType }}
vmImage: ${{ parameters.VM_IMAGE_MAC }}
target: tests-ios
additionalArgs: --device=ios-simulator-64 --skipExternals="all" --coverage=$(ENABLE_CODE_COVERAGE)
additionalArgs: --device=ios-simulator-64 --deviceVersion=$(IOS_TEST_DEVICE_VERSION) --skipExternals="all" --coverage=$(ENABLE_CODE_COVERAGE)
shouldPublish: false
requiredArtifacts:
- name: native_ios_macos
Expand All @@ -659,12 +659,12 @@ stages:
inputs:
testResultsFormat: xUnit
testResultsFiles: 'output/logs/testlogs/**/TestResults.xml'
testRunTitle: 'iOS Tests'
testRunTitle: 'iOS Tests (v$(IOS_TEST_DEVICE_VERSION))'
- task: PublishBuildArtifacts@1
displayName: Publish the test logs
condition: always()
inputs:
artifactName: testlogs_ios
artifactName: testlogs_ios_$(IOS_TEST_DEVICE_VERSION)
pathToPublish: 'output/logs/testlogs'
- template: azure-templates-bootstrapper.yml # Tests|maccatalyst (macOS)
parameters:
Expand Down
8 changes: 7 additions & 1 deletion scripts/cake/xharness-android.cake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ DirectoryPath ROOT_PATH = MakeAbsolute(Directory("../.."));

var TEST_APP = Argument("app", EnvironmentVariable("ANDROID_TEST_APP") ?? "");
var TEST_RESULTS = Argument("results", EnvironmentVariable("ANDROID_TEST_RESULTS") ?? "");
var TEST_DEVICE = Argument("device", EnvironmentVariable("ANDROID_TEST_DEVICE") ?? "android-emulator-64_34");
var TEST_DEVICE = Argument("device", EnvironmentVariable("ANDROID_TEST_DEVICE") ?? "android-emulator-64");
var TEST_VERSION = Argument("deviceVersion", EnvironmentVariable("ANDROID_TEST_DEVICE_VERSION") ?? "34");
var TEST_APP_PACKAGE_NAME = Argument("package", EnvironmentVariable("ANDROID_TEST_APP_PACKAGE_NAME") ?? "");
var TEST_APP_INSTRUMENTATION = Argument("instrumentation", EnvironmentVariable("ANDROID_TEST_APP_INSTRUMENTATION") ?? "devicerunners.xharness.maui.XHarnessInstrumentation");

Expand Down Expand Up @@ -52,7 +53,12 @@ AndroidEmulatorProcess emulatorProcess = null;

Setup(context =>
{
if (!string.IsNullOrEmpty(TEST_VERSION) && TEST_VERSION != "latest")
TEST_DEVICE = $"{TEST_DEVICE}_{TEST_VERSION}";
Information("Test App: {0}", TEST_APP);
Information("Test Device: {0}", TEST_DEVICE);
Information("Test Results Directory: {0}", TEST_RESULTS);
// determine the device characteristics
{
Expand Down
4 changes: 4 additions & 0 deletions scripts/cake/xharness-apple.cake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ DirectoryPath ROOT_PATH = MakeAbsolute(Directory("../.."));
var TEST_APP = Argument("app", EnvironmentVariable("IOS_TEST_APP"));
var TEST_RESULTS = Argument("results", EnvironmentVariable("IOS_TEST_RESULTS") ?? "");
var TEST_DEVICE = Argument("device", EnvironmentVariable("IOS_TEST_DEVICE") ?? "ios-simulator-64");
var TEST_VERSION = Argument("deviceVersion", EnvironmentVariable("IOS_TEST_DEVICE_VERSION") ?? "latest");

Task("Default")
.Does(() =>
Expand All @@ -16,6 +17,9 @@ Task("Default")
TEST_RESULTS = TEST_APP + "-results";
}
if (!string.IsNullOrEmpty(TEST_VERSION) && TEST_VERSION.ToLower() != "latest")
TEST_DEVICE = $"{TEST_DEVICE}_{TEST_VERSION}";
Information("Test App: {0}", TEST_APP);
Information("Test Device: {0}", TEST_DEVICE);
Information("Test Results Directory: {0}", TEST_RESULTS);
Expand Down

0 comments on commit 02145c5

Please sign in to comment.