|
| 1 | +name: Windows Calculator Continuous Integration Pipeline |
| 2 | +run-name: WinCalc-CI-0.${{ github.run_number }} |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, release/**, feature/**] |
| 6 | + pull_request: |
| 7 | + branches: [main, release/**, feature/**] |
| 8 | + workflow_dispatch: |
| 9 | +jobs: |
| 10 | + defineBuilds: |
| 11 | + name: Define builds |
| 12 | + runs-on: windows-latest |
| 13 | + env: |
| 14 | + isPR: ${{ github.event_name == 'pull_request' }} |
| 15 | + outputs: |
| 16 | + version: ${{ steps.version.outputs.version }} |
| 17 | + platformList: ${{ steps.platformList.outputs.platformList }} |
| 18 | + unitTestPlatformList: ${{ steps.unitTestPlatformList.outputs.unitTestPlatformList }} |
| 19 | + steps: |
| 20 | + - name: Generate version number |
| 21 | + id: version |
| 22 | + run: | |
| 23 | + $version = "0.${{ github.run_number }}.${{ github.run_attempt }}.0" |
| 24 | + "version=`"$version`"" | Out-File $env:GITHUB_OUTPUT -Append |
| 25 | + shell: pwsh |
| 26 | + - name: Choose platforms to build |
| 27 | + id: platformList |
| 28 | + run: | |
| 29 | + if ($env:isPR -eq $false) { |
| 30 | + 'platformList=["x64", "x86", "ARM64", "ARM"]' | Out-File $env:GITHUB_OUTPUT -Append |
| 31 | + echo 'Build all platforms.' |
| 32 | + } |
| 33 | + else { |
| 34 | + 'platformList=["x64"]' | Out-File $env:GITHUB_OUTPUT -Append |
| 35 | + echo 'Build x64 only.' |
| 36 | + } |
| 37 | + shell: pwsh |
| 38 | + - name: Choose platforms for unit test |
| 39 | + id: unitTestPlatformList |
| 40 | + run: | |
| 41 | + if ($env:isPR -eq $false){ |
| 42 | + 'unitTestPlatformList=["x64", "x86"]' | Out-File $env:GITHUB_OUTPUT -Append |
| 43 | + echo 'Test x64, x86' |
| 44 | + } |
| 45 | + else{ |
| 46 | + 'unitTestPlatformList=["x64"]' | Out-File $env:GITHUB_OUTPUT -Append |
| 47 | + echo 'Test x64' |
| 48 | + } |
| 49 | + shell: pwsh |
| 50 | + |
| 51 | + build: |
| 52 | + needs: defineBuilds |
| 53 | + name: Build |
| 54 | + runs-on: windows-latest |
| 55 | + strategy: |
| 56 | + matrix: |
| 57 | + platform: ${{ fromJSON(needs.defineBuilds.outputs.platformList) }} |
| 58 | + env: |
| 59 | + buildVersion: ${{ fromJSON(needs.defineBuilds.outputs.version) }} |
| 60 | + steps: |
| 61 | + - uses: actions/checkout@v4 |
| 62 | + - uses: microsoft/setup-msbuild@v2 |
| 63 | + name: Setup msbuild |
| 64 | + - uses: nuget/setup-nuget@v2 |
| 65 | + name: Use nuget 6.x |
| 66 | + with: |
| 67 | + nuget-version: '6.x' |
| 68 | + - run: nuget restore ./src/Calculator.sln |
| 69 | + name: Restore nuget dependencies |
| 70 | + - run: | |
| 71 | + ./build/scripts/UpdateAppxManifestVersion.ps1 ` |
| 72 | + -AppxManifest ./src/Calculator/Package.appxmanifest ` |
| 73 | + -Version ${{ env.buildVersion }} |
| 74 | + shell: pwsh |
| 75 | + name: Set version number in AppxManifest |
| 76 | + - run: | |
| 77 | + msbuild ./src/Calculator.sln ` |
| 78 | + -bl:${{ github.workspace }}/output/Calculator.binlog ` |
| 79 | + -p:OutDir=${{ github.workspace }}\output\ ` |
| 80 | + -p:Platform=${{ matrix.platform }} ` |
| 81 | + -p:Configuration=Release ` |
| 82 | + -p:GenerateProjectSpecificOutputFolder=true ` |
| 83 | + -p:Version=${{ env.buildVersion }} ` |
| 84 | + -maxCpuCount ` |
| 85 | + -t:Publish ` |
| 86 | + -p:PublishDir=${{ github.workspace }}\output\publish\ |
| 87 | + shell: pwsh |
| 88 | + name: Build calculator.sln |
| 89 | + - uses: actions/upload-artifact@v4 |
| 90 | + name: Upload build outputs |
| 91 | + with: |
| 92 | + name: Build-${{ matrix.platform }} |
| 93 | + path: ${{ github.workspace }}/output |
| 94 | + |
| 95 | + unitTests: |
| 96 | + needs: [defineBuilds, build] |
| 97 | + runs-on: windows-latest |
| 98 | + name: Run unit tests |
| 99 | + strategy: |
| 100 | + matrix: |
| 101 | + platform: ${{ fromJSON(needs.defineBuilds.outputs.unitTestPlatformList) }} |
| 102 | + env: |
| 103 | + testDir: ${{ github.workspace }}/download/CalculatorUnitTests/AppPackages/CalculatorUnitTests_Test |
| 104 | + steps: |
| 105 | + - uses: actions/download-artifact@v4 |
| 106 | + name: Download build outputs |
| 107 | + with: |
| 108 | + name: Build-${{ matrix.platform }} |
| 109 | + path: ${{ github.workspace }}/download |
| 110 | + - run: | |
| 111 | + ${{ env.testDir }}/Add-AppDevPackage.ps1 ` |
| 112 | + -CertificatePath ${{ env.testDir }}/CalculatorUnitTests.cer ` |
| 113 | + -Force |
| 114 | + shell: pwsh |
| 115 | + name: Install test certificate |
| 116 | + - uses: ilammy/msvc-dev-cmd@v1 # this is a workaround because microsoft/vstest-action is broken. |
| 117 | + name: Setup dev tools |
| 118 | + - run: vstest.console.exe ${{ env.testDir }}/CalculatorUnitTests.msix /Platform:${{ matrix.platform }} |
| 119 | + name: Run unit tests |
| 120 | + |
| 121 | + uiTests: |
| 122 | + needs: build |
| 123 | + runs-on: windows-latest |
| 124 | + name: Run UI tests (x64) |
| 125 | + env: |
| 126 | + appDir: ${{ github.workspace }}/download/Calculator/AppPackages/Calculator*_Test |
| 127 | + pubDir: ${{ github.workspace }}/download/publish |
| 128 | + steps: |
| 129 | + - uses: actions/download-artifact@v4 |
| 130 | + name: Download build outputs |
| 131 | + with: |
| 132 | + name: Build-x64 |
| 133 | + path: ${{ github.workspace }}/download |
| 134 | + - run: | |
| 135 | + Set-DisplayResolution -Width 1920 -Height 1080 -Force |
| 136 | + shell: pwsh |
| 137 | + name: Set screen resolution |
| 138 | + - run: | |
| 139 | + ${{ env.appDir }}/Add-AppDevPackage.ps1 ` |
| 140 | + -CertificatePath ${{ env.appDir }}/Calculator*.cer ` |
| 141 | + -Force |
| 142 | + ${{ env.appDir }}/Add-AppDevPackage.ps1 ` |
| 143 | + -Force |
| 144 | + shell: powershell |
| 145 | + name: Install app |
| 146 | + - run: | |
| 147 | + Invoke-WebRequest 'https://github.com/microsoft/WinAppDriver/releases/download/v1.2.1/WindowsApplicationDriver_1.2.1.msi' ` |
| 148 | + -OutFile (New-Item -Path '${{ github.workspace }}/download2/wad.msi' -Force) |
| 149 | + cd ${{ github.workspace }}/download2 |
| 150 | + msiexec.exe /i wad.msi /quiet /passive |
| 151 | + shell: powershell |
| 152 | + name: Install WindowsApplicationDriver |
| 153 | + - uses: ilammy/msvc-dev-cmd@v1 # this is a workaround because microsoft/vstest-action is broken. |
| 154 | + name: Setup dev tools |
| 155 | + - run: | |
| 156 | + vstest.console.exe ${{ github.workspace }}\download\publish\CalculatorUITests.dll ` |
| 157 | + /Platform:x64 ` |
| 158 | + /Settings:${{ github.workspace }}\download\publish\CalculatorUITests.ci.runsettings |
| 159 | + shell: pwsh |
| 160 | + name: Run UI tests |
0 commit comments