Skip to content

Commit

Permalink
Build before testing
Browse files Browse the repository at this point in the history
  • Loading branch information
EduardGomezEscandell committed Sep 20, 2023
1 parent d077b8d commit 63c11ba
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 21 deletions.
30 changes: 17 additions & 13 deletions .github/workflows/qa-azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,30 @@ 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: |
Copy-Item -Path "${HOME}/.gitconfig" -Destination "\\wsl$\Ubuntu-Preview\etc\gitconfig"
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
Expand Down
36 changes: 28 additions & 8 deletions tools/build/build-appx.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
[switch]$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
}

Expand All @@ -25,15 +32,15 @@ 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
}

& "${devShell}" -SkipAutomaticLocation
return
}
}
}

Write-Error "Visual Studio developer powershell could not be found"
Expand All @@ -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
}

Expand All @@ -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" ) {
Expand Down

0 comments on commit 63c11ba

Please sign in to comment.