Skip to content

Harden Windows E2E app install flow #480

Harden Windows E2E app install flow

Harden Windows E2E app install flow #480

name: Build and Run Windows End to End Tests
on:
pull_request:
branches:
- main
jobs:
end_to_end_tests:
runs-on: windows-2022
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1.1
with:
vs-prerelease: true
- name: Install MAUI workloads
run: |
dotnet workload install maui
- name: Install Appium and Drivers
run: |
npm install -g appium --unsafe-perm=true --allow-root
appium driver install --source=npm appium-windows-driver
- name: Start Appium Server
run: |
nohup appium --log appium.log &
- name: Restore MAUI App for Windows
run: dotnet restore TransactionProcessor.Mobile.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }} --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json
- name: Build Code
run: dotnet build TransactionProcessor.Mobile/TransactionProcessor.Mobile.csproj -f net10.0-android -c Release --no-restore
- name: Decrypt PFX File
run: |
echo "${{ secrets.WINDOWSSIGNINGCERT }}" > cert.pfx.asc
certutil -decode cert.pfx.asc cert.pfx
- name: Add Cert to Store
run: certutil -user -q -p ${{ secrets.WINDOWSSIGNINGCERTPWD }} -importpfx cert.pfx NoRoot
- name: Publish App
run: |
dotnet publish TransactionProcessor.Mobile/TransactionProcessor.Mobile.csproj -c Release -f net10.0-windows10.0.19041.0 /p:AppxPackageSigningEnabled=true /p:PackageCertificateThumbprint="${{ secrets.WINDOWSSIGNINGCERTTHUMBPRINT }}"
- name: Install App
shell: powershell
run: |
Import-Module Appx
$candidatePaths = @(
(Join-Path $env:GITHUB_WORKSPACE "TransactionProcessor.Mobile\AppPackages"),
(Join-Path $env:GITHUB_WORKSPACE "TransactionProcessor.Mobile\bin\Release\net10.0-windows10.0.19041.0\win-x64\AppPackages")
)
$appPackagesPath = $candidatePaths | Where-Object { Test-Path $_ } | Select-Object -First 1
if ($null -eq $appPackagesPath) {
throw "Unable to find AppPackages under: $($candidatePaths -join ', ')"
}
$installScript = Get-ChildItem -Path $appPackagesPath -Recurse -Filter Install.ps1 | Select-Object -First 1
if ($null -ne $installScript) {
& $installScript.FullName -Force
} else {
$msixPackage = Get-ChildItem -Path $appPackagesPath -Recurse -Filter *.msix | Select-Object -First 1
if ($null -eq $msixPackage) {
throw "Unable to find Install.ps1 or .msix package under $appPackagesPath."
}
Add-AppxPackage -Path $msixPackage.FullName -ForceApplicationShutdown
}
- name: Run Windows End To End Tests
run: dotnet test TransactionProcessor.Mobile.UiTests/TransactionProcessor.Mobile.UiTests.csproj --filter "Category=PRTest&Category=Windows" --no-restore
#run: dotnet test TransactionProcessor.Mobile.UiTests/TransactionProcessor.Mobile.UiTests.csproj --list-tests -v:d
- name: Upload Logs on Failure
if: always()
uses: actions/upload-artifact@v4
with:
name: windows-e2e_tests
path: C:\\Users\\runneradmin\\runner
- name: Upload Appium Logs on Failure
if: always()
uses: actions/upload-artifact@v4
with:
name: windows-e2e_tests_appium
path: appium.log