Skip to content

Commit 7d96d71

Browse files
jonathanpeppersjonpryor
authored andcommitted
[build] archive APKs/AABs in yaml (#3886)
In 22de117, it did not actually archive *all* the `.apk` files. Throughout our build pipeline, we build projects with different MSBuild properties as input such as `/p:AotAssemblies=True`. This causes the `.apk` files to be overwritten, and we lose the previous versions of these files. Instead, we should copy each APK to a directory inside `$(Build.ArtifactStagingDirectory)` with a path identifying which MSBuild properties were set during the build. I propose modifying the template such as: - template: yaml-templates/apk-instrumentation.yaml parameters: configuration: $(ApkTestConfiguration) testName: Mono.Android_Tests-Aot project: src/Mono.Android/Test/Mono.Android-Tests.csproj testResultsFiles: TestResult-Mono.Android_Tests-$(ApkTestConfiguration)-Aot.xml extraBuildArgs: /p:AotAssemblies=True /p:EnableLlvm=True artifactName: Mono.Android_Tests-Signed.apk artifactFolder: AotLlvm Would yield an artifact at `AotLlvm/Mono.Android_Tests-Signed.apk` that we could download independently, and *won't* overwrite other "build versions" of the "same" App. ![AzDO Artifacts Image][0] [0]: https://user-images.githubusercontent.com/840039/68357624-8eb0a300-00db-11ea-9761-2f1b7ebf5b66.png
1 parent b6e8ba8 commit 7d96d71

File tree

3 files changed

+63
-38
lines changed

3 files changed

+63
-38
lines changed

build-tools/Xamarin.Android.Tools.BootstrapTasks/result-packaging.targets

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<_TestResultFiles Include="$(XamarinAndroidSourcePath)bin\Test$(Configuration)\compatibility\*" />
2727
<_TestResultFiles Include="$(XamarinAndroidSourcePath)bin\Test$(Configuration)\logcat*" />
2828
<_TestResultFiles Include="$(XamarinAndroidSourcePath)bin\Test$(Configuration)\*log" />
29-
<_TestResultFiles Include="$(XamarinAndroidSourcePath)bin\Test$(Configuration)\*-Signed.apk" />
3029
<_TestResultFiles Include="$(XamarinAndroidSourcePath)bin\Test$(Configuration)\temp\**\*" Exclude="$(XamarinAndroidSourcePath)bin\Test$(Configuration)\temp\packages\**">
3130
<SubDirectory>temp\</SubDirectory>
3231
</_TestResultFiles>

build-tools/automation/azure-pipelines.yaml

Lines changed: 51 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,8 @@ stages:
370370
testName: Mono.Android_Tests
371371
project: src/Mono.Android/Test/Mono.Android-Tests.csproj
372372
testResultsFiles: TestResult-Mono.Android_Tests-$(ApkTestConfiguration).xml
373+
artifactName: Mono.Android_Tests-Signed.apk
374+
artifactFolder: Default
373375

374376
- template: yaml-templates/apk-instrumentation.yaml
375377
parameters:
@@ -378,6 +380,8 @@ stages:
378380
project: src/Mono.Android/Test/Mono.Android-Tests.csproj
379381
testResultsFiles: TestResult-Mono.Android_Tests-$(ApkTestConfiguration)-Aot.xml
380382
extraBuildArgs: /p:AotAssemblies=True /p:EnableLlvm=True
383+
artifactName: Mono.Android_Tests-Signed.apk
384+
artifactFolder: AotLlvm
381385

382386
- template: yaml-templates/apk-instrumentation.yaml
383387
parameters:
@@ -386,6 +390,8 @@ stages:
386390
project: src/Mono.Android/Test/Mono.Android-Tests.csproj
387391
testResultsFiles: TestResult-Mono.Android_Tests-$(ApkTestConfiguration)-Profiled.xml
388392
extraBuildArgs: /p:AndroidEnableProfiledAot=true
393+
artifactName: Mono.Android_Tests-Signed.apk
394+
artifactFolder: Profiled
389395

390396
- template: yaml-templates/apk-instrumentation.yaml
391397
parameters:
@@ -394,6 +400,8 @@ stages:
394400
project: src/Mono.Android/Test/Mono.Android-Tests.csproj
395401
testResultsFiles: TestResult-Mono.Android_Tests-$(ApkTestConfiguration)-Bundle.xml
396402
extraBuildArgs: /p:BundleAssemblies=true
403+
artifactName: Mono.Android_Tests-Signed.apk
404+
artifactFolder: Bundle
397405

398406
- template: yaml-templates/apk-instrumentation.yaml
399407
parameters:
@@ -402,27 +410,35 @@ stages:
402410
project: tests/Runtime-AppBundle/Mono.Android-TestsAppBundle.csproj
403411
testResultsFiles: TestResult-Mono.Android_TestsAppBundle-$(ApkTestConfiguration).xml
404412
packageType: Aab
413+
artifactName: Mono.Android_TestsAppBundle-Signed.aab
414+
artifactFolder: Aab
405415

406416
- template: yaml-templates/apk-instrumentation.yaml
407417
parameters:
408418
configuration: $(ApkTestConfiguration)
409419
testName: Mono.Android_TestsMultiDex
410420
project: tests/Runtime-MultiDex/Mono.Android-TestsMultiDex.csproj
411421
testResultsFiles: TestResult-Mono.Android_TestsMultiDex-$(ApkTestConfiguration).xml
422+
artifactName: Mono.Android_Tests-Signed.apk
423+
artifactFolder: MultiDex
412424

413425
- template: yaml-templates/apk-instrumentation.yaml
414426
parameters:
415427
configuration: $(ApkTestConfiguration)
416428
testName: Xamarin.Android.JcwGen_Tests
417429
project: tests/CodeGen-Binding/Xamarin.Android.JcwGen-Tests/Xamarin.Android.JcwGen-Tests.csproj
418430
testResultsFiles: TestResult-Xamarin.Android.JcwGen_Tests-$(ApkTestConfiguration).xml
431+
artifactName: Xamarin.Android.JcwGen_Tests-Signed.apk
432+
artifactFolder: Default
419433

420434
- template: yaml-templates/apk-instrumentation.yaml
421435
parameters:
422436
configuration: $(ApkTestConfiguration)
423437
testName: Xamarin.Android.Locale_Tests
424438
project: tests/locales/Xamarin.Android.Locale-Tests/Xamarin.Android.Locale-Tests.csproj
425439
testResultsFiles: TestResult-Xamarin.Android.Locale_Tests-$(ApkTestConfiguration).xml
440+
artifactName: Xamarin.Android.Locale_Tests-Signed.apk
441+
artifactFolder: Default
426442

427443
- template: yaml-templates/apk-instrumentation.yaml
428444
parameters:
@@ -431,6 +447,8 @@ stages:
431447
project: tests/locales/Xamarin.Android.Locale-Tests/Xamarin.Android.Locale-Tests.csproj
432448
testResultsFiles: TestResult-Xamarin.Android.Locale_Tests-$(ApkTestConfiguration)-Aot.xml
433449
extraBuildArgs: /p:AotAssemblies=True
450+
artifactName: Xamarin.Android.Locale_Tests-Signed.apk
451+
artifactFolder: Aot
434452

435453
- template: yaml-templates/apk-instrumentation.yaml
436454
parameters:
@@ -439,56 +457,52 @@ stages:
439457
project: tests/locales/Xamarin.Android.Locale-Tests/Xamarin.Android.Locale-Tests.csproj
440458
testResultsFiles: TestResult-Xamarin.Android.Locale_Tests-$(ApkTestConfiguration)-Profiled.xml
441459
extraBuildArgs: /p:AndroidEnableProfiledAot=true
460+
artifactName: Xamarin.Android.Locale_Tests-Signed.apk
461+
artifactFolder: Profiled
442462

443463
- template: yaml-templates/apk-instrumentation.yaml
444464
parameters:
445465
configuration: $(ApkTestConfiguration)
446466
testName: Xamarin.Android.EmbeddedDSO_Test
447467
project: tests/EmbeddedDSOs/EmbeddedDSO/EmbeddedDSO.csproj
448468
testResultsFiles: TestResult-Xamarin.Android.EmbeddedDSO_Test.nunit-$(ApkTestConfiguration).xml
469+
artifactName: Xamarin.Android.EmbeddedDSO_Test-Signed.apk
470+
artifactFolder: Profiled
449471

450-
- task: MSBuild@1
451-
displayName: run Xamarin.Forms-Performance-Integration
452-
inputs:
453-
solution: tests/Xamarin.Forms-Performance-Integration/Droid/Xamarin.Forms.Performance.Integration.Droid.csproj
472+
- template: yaml-templates/apk-instrumentation.yaml
473+
parameters:
454474
configuration: $(ApkTestConfiguration)
455-
msbuildArguments: >
456-
/t:AcquireAndroidTarget,SignAndroidPackage,DeployTestApks,RunTestApks,UndeployTestApks,ReportComponentFailures
457-
/bl:$(System.DefaultWorkingDirectory)/bin/Test$(ApkTestConfiguration)/XamarinFormsPerf.binlog
458-
condition: succeededOrFailed()
475+
testName: Xamarin.Forms-Performance-Integration
476+
project: tests/Xamarin.Forms-Performance-Integration/Droid/Xamarin.Forms.Performance.Integration.Droid.csproj
477+
artifactName: Xamarin.Forms_Performance_Integration-Signed.apk
478+
artifactFolder: Default
459479

460-
- task: MSBuild@1
461-
displayName: run Xamarin.Forms-Performance-Integration-Aot
462-
inputs:
463-
solution: tests/Xamarin.Forms-Performance-Integration/Droid/Xamarin.Forms.Performance.Integration.Droid.csproj
480+
- template: yaml-templates/apk-instrumentation.yaml
481+
parameters:
464482
configuration: $(ApkTestConfiguration)
465-
msbuildArguments: >
466-
/t:AcquireAndroidTarget,SignAndroidPackage,DeployTestApks,RunTestApks,UndeployTestApks,ReportComponentFailures
467-
/bl:$(System.DefaultWorkingDirectory)/bin/Test$(ApkTestConfiguration)/XamarinFormsPerf-Aot.binlog
468-
/p:AotAssemblies=true
469-
condition: succeededOrFailed()
483+
testName: Xamarin.Forms-Performance-Integration-Aot
484+
project: tests/Xamarin.Forms-Performance-Integration/Droid/Xamarin.Forms.Performance.Integration.Droid.csproj
485+
extraBuildArgs: /p:AotAssemblies=true
486+
artifactName: Xamarin.Forms_Performance_Integration-Signed.apk
487+
artifactFolder: Aot
470488

471-
- task: MSBuild@1
472-
displayName: run Xamarin.Forms-Performance-Integration-Profiled
473-
inputs:
474-
solution: tests/Xamarin.Forms-Performance-Integration/Droid/Xamarin.Forms.Performance.Integration.Droid.csproj
489+
- template: yaml-templates/apk-instrumentation.yaml
490+
parameters:
475491
configuration: $(ApkTestConfiguration)
476-
msbuildArguments: >
477-
/t:AcquireAndroidTarget,SignAndroidPackage,DeployTestApks,RunTestApks,UndeployTestApks,ReportComponentFailures
478-
/bl:$(System.DefaultWorkingDirectory)/bin/Test$(ApkTestConfiguration)/XamarinFormsPerf-Profiled.binlog
479-
/p:AndroidEnableProfiledAot=true
480-
condition: succeededOrFailed()
492+
testName: Xamarin.Forms-Performance-Integration-Profiled
493+
project: tests/Xamarin.Forms-Performance-Integration/Droid/Xamarin.Forms.Performance.Integration.Droid.csproj
494+
extraBuildArgs: /p:AndroidEnableProfiledAot=true
495+
artifactName: Xamarin.Forms_Performance_Integration-Signed.apk
496+
artifactFolder: Profiled
481497

482-
- task: MSBuild@1
483-
displayName: run Xamarin.Forms-Performance-Integration-Bundle
484-
inputs:
485-
solution: tests/Xamarin.Forms-Performance-Integration/Droid/Xamarin.Forms.Performance.Integration.Droid.csproj
498+
- template: yaml-templates/apk-instrumentation.yaml
499+
parameters:
486500
configuration: $(ApkTestConfiguration)
487-
msbuildArguments: >
488-
/t:AcquireAndroidTarget,SignAndroidPackage,DeployTestApks,RunTestApks,UndeployTestApks,ReportComponentFailures
489-
/bl:$(System.DefaultWorkingDirectory)/bin/Test$(ApkTestConfiguration)/XamarinFormsPerf-Bundle.binlog
490-
/p:BundleAssemblies=true
491-
condition: succeededOrFailed()
501+
testName: Xamarin.Forms-Performance-Integration-Bundle
502+
project: tests/Xamarin.Forms-Performance-Integration/Droid/Xamarin.Forms.Performance.Integration.Droid.csproj
503+
extraBuildArgs: /p:BundleAssemblies=true
504+
artifactName: Xamarin.Forms_Performance_Integration-Signed.apk
505+
artifactFolder: Bundle
492506

493507
- task: MSBuild@1
494508
displayName: shut down emulator
@@ -531,6 +545,8 @@ stages:
531545
testName: Xamarin.Android.Bcl-Tests
532546
project: tests/BCL-Tests/Xamarin.Android.Bcl-Tests/Xamarin.Android.Bcl-Tests.csproj
533547
testResultsFiles: TestResult-Xamarin.Android.Bcl_Tests.nunit-$(XA.Build.Configuration).xml
548+
artifactName: Xamarin.Android.Bcl_Tests-Signed.apk
549+
artifactFolder: Default
534550

535551
- task: PublishTestResults@2
536552
displayName: publish Xamarin.Android.Bcl-Tests-XUnit results

build-tools/automation/yaml-templates/apk-instrumentation.yaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ parameters:
22
configuration: []
33
testName: []
44
project: []
5-
testResultsFiles: []
5+
testResultsFiles: ""
66
extraBuildArgs: ""
77
testResultsFormat: NUnit
88
packageType: Apk
9+
artifactName: []
10+
artifactFolder: []
911

1012
steps:
1113
- task: MSBuild@1
@@ -19,10 +21,18 @@ steps:
1921
${{ parameters.extraBuildArgs }}
2022
condition: succeededOrFailed()
2123

24+
- script: |
25+
SOURCE=$(System.DefaultWorkingDirectory)/bin/Test${{ parameters.configuration }}/${{ parameters.artifactName }}
26+
DEST=$(Build.ArtifactStagingDirectory)/${{ parameters.artifactFolder }}/
27+
mkdir "$DEST"
28+
cp "$SOURCE" "$DEST"
29+
displayName: copy apk/aab
30+
condition: succeededOrFailed()
31+
2232
- task: PublishTestResults@2
2333
displayName: publish ${{ parameters.testName }} results
2434
inputs:
2535
testResultsFormat: ${{ parameters.testResultsFormat }}
2636
testResultsFiles: ${{ parameters.testResultsFiles }}
2737
testRunTitle: ${{ parameters.testName }}
28-
condition: succeededOrFailed()
38+
condition: and(succeededOrFailed(), ne('${{ parameters.testResultsFiles }}', ''))

0 commit comments

Comments
 (0)