From 2db1e31227420b950cdd98c847de5bb860c308d4 Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Tue, 8 Apr 2025 07:04:53 +0100 Subject: [PATCH 1/4] Add Windows E2E Tests workflow to GitHub Actions This commit introduces a new GitHub Actions workflow named "Build and Run Windows End to End Tests." It is triggered on pull requests to the `main` branch and automates the process of building, testing, and publishing a .NET MAUI application in a Windows environment. The workflow includes steps for checking out the repository, building a Windows SQL Server Docker image, setting up MSBuild and .NET, installing MAUI workloads, installing Appium and its drivers, starting the Appium server, restoring the MAUI app for Android, building the code, decrypting a PFX file, adding the certificate to the store, publishing the app, installing the app, and running Windows navigation tests. --- .github/workflows/windows_e2e_tests.yml | 70 +++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 .github/workflows/windows_e2e_tests.yml diff --git a/.github/workflows/windows_e2e_tests.yml b/.github/workflows/windows_e2e_tests.yml new file mode 100644 index 000000000..f77702cd6 --- /dev/null +++ b/.github/workflows/windows_e2e_tests.yml @@ -0,0 +1,70 @@ +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: Build Windows SQL Server + run: | + cd SQLDocker + docker build -t mssqlserver:2022-ltsc2022 --build-arg SQL_VERSION=2022 --build-arg WIN_VERSION=ltsc2022 . + + - name: Setup MSBuild + uses: microsoft/setup-msbuild@v1.1 + with: + vs-prerelease: true + + - name: Set up .NET + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '8.0.x' + + - 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 Android + run: dotnet restore TransactionMobile.Maui.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 TransactionMobile.Maui/TransactionMobile.Maui.csproj -f net8.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 TransactionMobile.Maui/TransactionMobile.Maui.csproj -c Release -f net8.0-windows10.0.19041.0 /p:AppxPackageSigningEnabled=true /p:PackageCertificateThumbprint="${{ secrets.WINDOWSSIGNINGCERTTHUMBPRINT }}" + + - name: Install App + shell: powershell + run: | + Import-Module Appx + .\TransactionMobile.Maui/bin/Release/net8.0-windows10.0.19041.0/win10-x64/AppPackages/TransactionMobile.Maui_1.0.0.0_Test/Install.ps1 -Force + + - name: Run Windows Navigation Tests + run: dotnet test TransactionMobile.Maui.UiTests/TransactionMobile.Maui.UiTests.csproj --filter "(Category=PRTest)&(Category=Windows)" --no-restore + + \ No newline at end of file From 9061ab841464f68eaf2544a02181d12f7bbb8f3a Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Tue, 8 Apr 2025 08:03:59 +0100 Subject: [PATCH 2/4] missing env variable --- .github/workflows/windows_e2e_tests.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows_e2e_tests.yml b/.github/workflows/windows_e2e_tests.yml index f77702cd6..cd49e69df 100644 --- a/.github/workflows/windows_e2e_tests.yml +++ b/.github/workflows/windows_e2e_tests.yml @@ -64,7 +64,9 @@ jobs: Import-Module Appx .\TransactionMobile.Maui/bin/Release/net8.0-windows10.0.19041.0/win10-x64/AppPackages/TransactionMobile.Maui_1.0.0.0_Test/Install.ps1 -Force - - name: Run Windows Navigation Tests + - name: Run Windows End To End Tests + env: + IsCI: true run: dotnet test TransactionMobile.Maui.UiTests/TransactionMobile.Maui.UiTests.csproj --filter "(Category=PRTest)&(Category=Windows)" --no-restore \ No newline at end of file From be5445aa2f7b57b83b1929d8fe0403378c3e1b4e Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Tue, 8 Apr 2025 09:57:14 +0100 Subject: [PATCH 3/4] add log capture to workflows --- .github/workflows/android_e2e_tests.yml | 11 +++++++++-- .github/workflows/android_navigation_tests.yml | 14 ++++++++++++++ .github/workflows/windows_e2e_tests.yml | 14 +++++++++++++- .github/workflows/windows_navigation_tests.yml | 7 +++++++ 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/.github/workflows/android_e2e_tests.yml b/.github/workflows/android_e2e_tests.yml index 979f7d9b9..6b37ca648 100644 --- a/.github/workflows/android_e2e_tests.yml +++ b/.github/workflows/android_e2e_tests.yml @@ -166,5 +166,12 @@ jobs: if: failure() # Runs only if a previous step fails uses: actions/upload-artifact@v4 with: - name: android-test-logs - path: /home/txnproc/trace/ \ No newline at end of file + name: android-e2e_tests + path: /home/txnproc/trace/ + + - name: Upload Appium Logs on Failure + if: failure() + uses: actions/upload-artifact@v4 + with: + name: android-e2e_tests_appium + path: appium.log \ No newline at end of file diff --git a/.github/workflows/android_navigation_tests.yml b/.github/workflows/android_navigation_tests.yml index 345bcae4e..15879cd05 100644 --- a/.github/workflows/android_navigation_tests.yml +++ b/.github/workflows/android_navigation_tests.yml @@ -149,6 +149,13 @@ jobs: - name: Run Android Navigation Tests run: dotnet test TransactionMobile.Maui.UiTests/TransactionMobile.Maui.UiTests.csproj --filter "(Category=PRNavTest)&(Category=Android)" --no-restore + - name: Upload Appium Logs on Failure + if: failure() + uses: actions/upload-artifact@v4 + with: + name: android-software_navigation_tests_appium + path: appium.log + hardware_navigation_tests: runs-on: ubuntu-latest steps: @@ -291,3 +298,10 @@ jobs: - name: Run Android Navigation Tests run: dotnet test TransactionMobile.Maui.UiTests/TransactionMobile.Maui.UiTests.csproj --filter "(Category=PRHWNavTest)&(Category=Android)" --no-restore + + - name: Upload Appium Logs on Failure + if: failure() + uses: actions/upload-artifact@v4 + with: + name: android-hardware_navigation_tests_appium + path: appium.log \ No newline at end of file diff --git a/.github/workflows/windows_e2e_tests.yml b/.github/workflows/windows_e2e_tests.yml index cd49e69df..40b993468 100644 --- a/.github/workflows/windows_e2e_tests.yml +++ b/.github/workflows/windows_e2e_tests.yml @@ -69,4 +69,16 @@ jobs: IsCI: true run: dotnet test TransactionMobile.Maui.UiTests/TransactionMobile.Maui.UiTests.csproj --filter "(Category=PRTest)&(Category=Windows)" --no-restore - \ No newline at end of file + - name: Upload Logs on Failure + if: failure() # Runs only if a previous step fails + uses: actions/upload-artifact@v4 + with: + name: windows-e2e_tests + path: C:\\Users\\runneradmin\\txnproc + + - name: Upload Appium Logs on Failure + if: failure() + uses: actions/upload-artifact@v4 + with: + name: windows-e2e_tests_appium + path: appium.log \ No newline at end of file diff --git a/.github/workflows/windows_navigation_tests.yml b/.github/workflows/windows_navigation_tests.yml index de3da7f07..90f804306 100644 --- a/.github/workflows/windows_navigation_tests.yml +++ b/.github/workflows/windows_navigation_tests.yml @@ -62,4 +62,11 @@ jobs: - name: Run Windows Navigation Tests run: dotnet test TransactionMobile.Maui.UiTests/TransactionMobile.Maui.UiTests.csproj --filter "(Category=PRNavTest)&(Category=Windows)" --no-restore + - name: Upload Appium Logs on Failure + if: failure() + uses: actions/upload-artifact@v4 + with: + name: windows-software_navigation_tests_appium + path: appium.log + \ No newline at end of file From eca2e885cd73f6ead84bee9d5b18052710af0869 Mon Sep 17 00:00:00 2001 From: StuartFerguson Date: Tue, 8 Apr 2025 10:09:50 +0100 Subject: [PATCH 4/4] Update windows_e2e_tests.yml --- .github/workflows/windows_e2e_tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows_e2e_tests.yml b/.github/workflows/windows_e2e_tests.yml index 40b993468..d4c192b8c 100644 --- a/.github/workflows/windows_e2e_tests.yml +++ b/.github/workflows/windows_e2e_tests.yml @@ -69,7 +69,7 @@ jobs: IsCI: true run: dotnet test TransactionMobile.Maui.UiTests/TransactionMobile.Maui.UiTests.csproj --filter "(Category=PRTest)&(Category=Windows)" --no-restore - - name: Upload Logs on Failure + - name: Upload Logs on Failure if: failure() # Runs only if a previous step fails uses: actions/upload-artifact@v4 with: @@ -81,4 +81,4 @@ jobs: uses: actions/upload-artifact@v4 with: name: windows-e2e_tests_appium - path: appium.log \ No newline at end of file + path: appium.log