Add Windows Navigation tests#211
Conversation
This commit introduces a new workflow titled "Build and Run Windows Navigation Tests," which is triggered on pull requests to the `main` branch. The workflow runs on a Windows 2022 environment and includes steps for setting up the environment, installing dependencies, building a MAUI application, and executing navigation tests. It also manages the installation of Appium, starts the Appium server, restores the MAUI app, decrypts a signing certificate, and publishes the app. In case of test failures, it uploads the Appium logs as an artifact.
| runs-on: windows-2022 | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v2 | ||
|
|
||
| - name: Setup MSBuild | ||
| uses: microsoft/[email protected] | ||
| with: | ||
| vs-prerelease: true | ||
|
|
||
| - name: Set up .NET | ||
| uses: actions/setup-dotnet@v1 | ||
| with: | ||
| dotnet-version: '9.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 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 net9.0-windows10.0.19041.0 -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.UITests/TransactionProcessor.Mobile.UITests.csproj -c Release -f net9.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/net9.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=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 |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 11 months ago
To fix the issue, we need to add a permissions block to the workflow. This block should specify the minimal permissions required for the workflow to function correctly. Based on the operations performed, the workflow likely requires contents: read to access repository files and possibly secrets: read to use the secrets defined in the repository.
The permissions block can be added at the root level of the workflow to apply to all jobs, or it can be added specifically to the software_navigation_tests job. Adding it at the root level is more concise and ensures consistency across all jobs.
| @@ -7,2 +7,6 @@ | ||
|
|
||
| permissions: | ||
| contents: read | ||
| secrets: read | ||
|
|
||
| jobs: |
Closes #207