diff --git a/.github/workflows/qa-azure.yaml b/.github/workflows/qa-azure.yaml index 8b12fdb54..248f9af90 100644 --- a/.github/workflows/qa-azure.yaml +++ b/.github/workflows/qa-azure.yaml @@ -67,26 +67,29 @@ jobs: $pwd = ConvertTo-SecureString '${{ secrets.CERTIFICATE_PASSWORD }}' -AsPlainText -Force Import-PfxCertificate -Password $pwd -CertStoreLocation Cert:LocalMachine\Trust -FilePath certificate\certificate.pfx Import-PfxCertificate -Password $pwd -CertStoreLocation Cert:CurrentUser\My -FilePath certificate\certificate.pfx + - name: Build Appx + shell: powershell + run: | + New-Item -ItemType Directory "ci-build/windows-agent" + Get-AppxPackage -Name "CanonicalGroupLimited.UbuntuProForWindows" | Remove-AppxPackage + .\tools\build\build-appx.ps1 -OutputDir "ci-build/windows-agent" -SkipInstall + - name: Build WSL-Pro-Service + shell: powershell + run: | + New-Item -ItemType Directory "ci-build/wsl-pro-service" + .\tools\build\build-deb.ps1 -OutputDir "ci-build/wsl-pro-service" - name: Test - id: run-tests shell: powershell - env: - UP4W_TEST_OVERRIDE_DESTRUCTIVE_CHECKS: "1" - GIT_TERMINAL_PROMPT: "0" - UP4W_TEST_PRO_TOKEN: "${{ secrets.UBUNTU_PRO_TOKEN }}" + env: + GIT_TERMINAL_PROMPT: "0" + UP4W_TEST_OVERRIDE_DESTRUCTIVE_CHECKS: "1" + UP4W_TEST_BUILD_PATH: "ci-build" + UP4W_TEST_PRO_TOKEN: "${{ secrets.UBUNTU_PRO_TOKEN }}" run: | go env -w "GOPRIVATE=github.com/${{ github.repository }}" go test .\end-to-end -shuffle=on -timeout 20m if ( "$LastExitCode" -ne "0" ) { Exit(1) } - - name: Display WSL-Pro-Service build log - if: failure() && steps.run-tests.outcome == 'failure' - shell: powershell - run: Get-Content ".\end-to-end\BuildWslProService.log" - - name: Display Appx build log - if: failure() && steps.run-tests.outcome == 'failure' - shell: powershell - run: Get-Content ".\end-to-end\BuildWindowsAgent.log" - name: Clean up if: always() shell: powershell diff --git a/tools/build/build-appx.ps1 b/tools/build/build-appx.ps1 index 87cd5c415..c69c95e0d 100644 --- a/tools/build/build-appx.ps1 +++ b/tools/build/build-appx.ps1 @@ -3,20 +3,27 @@ Build the Ubuntu Pro For Windows Appx package for local use. #> +param( + [Parameter(Mandatory = $False, HelpMessage = "If set, the resulting Appx will not be installed")] + [bool]$SkipInstall, + [Parameter(Mandatory = $False, HelpMessage = "If set, the directory where to store the artifacts")] + [string]$OutputDir +) + function Start-VsDevShell { # Looking for a path like # ${env:ProgramFiles}\Microsoft Visual Studio\$VERSION\$RELEASE\Common7\Tools\Launch-VsDevShell.ps1 # where VERSION is a four-digit number and RELEASE is one of Enterprise, Professional, or Community. - + $vsRoot = "${env:ProgramFiles}\Microsoft Visual Studio" if (! (Test-Path "${vsRoot}")) { Write-Error "Visual Studio could not be found in ${vsRoot}" - exit 1 + exit 1 } $versions = Get-ChildItem "${vsRoot}" | ForEach-Object { $_.Name } | Sort-Object if ( "$versions" -eq "" ) { - Write-Error "No version of Visual Studio found" + Write-Error "No version of Visual Studio found" exit 1 } @@ -25,7 +32,7 @@ function Start-VsDevShell { continue } - foreach ( $release in "Enterprise","Professional","Community") { + foreach ( $release in "Enterprise", "Professional", "Community") { $devShell = "${vsRoot}\${version}\${release}\Common7\Tools\Launch-VsDevShell.ps1" if (! (Test-Path "${devShell}") ) { continue @@ -33,7 +40,7 @@ function Start-VsDevShell { & "${devShell}" -SkipAutomaticLocation return - } + } } Write-Error "Visual Studio developer powershell could not be found" @@ -47,8 +54,8 @@ function Update-Certificate { Write-Warning "You need a certificate to build and install the Appx. ` Create and install a certificate, and write its thumbprint in ${certificate_path}.` See https://learn.microsoft.com/en-us/windows/win32/appxpkg/how-to-create-a-package-signing-certificate for more details" - - Write-Output "Continuing with default certificate" + + Write-Output "Continuing with default certificate" return } @@ -71,7 +78,20 @@ function Install-Appx { | Sort-Object LastWriteTime ` | Select-Object -last 1 ` ) - + + if ( "${OutputDir}" -ne "" ) { + Copy-Item -Path "${artifacts}" -Destination "${OutputDir}" + if (! $? ) { + Write-Output "could not move artifacts to output dir" + exit 1 + } + $artifacts = "${OutputDir}" + } + + if ( ${SkipInstall} ) { + return + } + & "${artifacts}\Install.ps1" -Force if ( "${LastExitCode}" -ne "0" ) {