Skip to content

Commit

Permalink
Use PowerShell Build Scripts in Azure Pipelines (#64)
Browse files Browse the repository at this point in the history
This PR has a bunch of refactoring for the Azure Pipelines build process. The primary change is to call build.ps1 instead of cmake directly. This removes the dependency on some of the old script files (which are now deleted).
  • Loading branch information
nibanks authored Jan 28, 2020
1 parent e8a1cc2 commit 16d76f8
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 114 deletions.
16 changes: 0 additions & 16 deletions .azure/get_procdump.ps1

This file was deleted.

10 changes: 0 additions & 10 deletions .azure/prepare_linux.sh

This file was deleted.

9 changes: 0 additions & 9 deletions .azure/prepare_windows.cmd

This file was deleted.

12 changes: 4 additions & 8 deletions .azure/spin_windows.cmd
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@

:: Start ProcDump.
mkdir artifacts\dumps
start bld\procdump\procdump64.exe -ma -e -b -accepteula -w spinquic.exe artifacts\dumps

:: Run spinquic for a while.
artifacts\windows\bin\debug\spinquic.exe both -timeout:300000

:: Print any dump files that might be generated.
dir artifacts\dumps
mkdir artifacts\dumps
bld\windows\procdump\procdump64.exe ^
-ma -e -b -l -accepteula -x artifacts\dumps ^
artifacts\windows\bin\debug\spinquic.exe both -timeout:300000
16 changes: 6 additions & 10 deletions .azure/test_windows.cmd
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@

:: Start ProcDump
mkdir artifacts\dumps
start bld\procdump\procdump64.exe -ma -e -b -accepteula -w msquictest.exe artifacts\dumps

:: Import our ETW manifest.
wevtutil im manifest\MsQuicEtw.man ^
/rf:%cd%\artifacts\windows\bin\debug\msquic.dll ^
Expand All @@ -16,12 +12,12 @@ netsh trace start sessionname=quic ^
provider=Microsoft-Quic level=0x5 keywords=0xE0000100

:: Run the tests.
artifacts\windows\bin\debug\msquictest.exe ^
--gtest_filter=%1 ^
--gtest_output=xml:artifacts\logs\windows-test-results.xml

:: Print any dump files that might be generated.
dir artifacts\dumps
mkdir artifacts\dumps
bld\windows\procdump\procdump64.exe ^
-ma -e -b -l -accepteula -x artifacts\dumps ^
artifacts\windows\bin\debug\msquictest.exe ^
--gtest_filter=%1 ^
--gtest_output=xml:artifacts\logs\windows-test-results.xml

:: Stop log collection.
netsh trace stop sessionname=quic
Expand Down
92 changes: 39 additions & 53 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,95 +1,81 @@
# Continuous integration for Linux and Windows.
# Continuous integration for cross-platform build and testing.
# https://aka.ms/yaml

trigger:
- master

strategy:
matrix:
linux-stub:
platform: 'Linux-Stub'
ubuntu-stub:
platform: 'ubuntu'
config: 'stub'
imageName: 'ubuntu-latest'
prepareCmd: 'bash ./.azure/prepare_linux.sh'
cmakeArgs: '-g ''Linux Makefiles'' -DQUIC_TLS=stub -DQUIC_ENABLE_LOGGING=off'
buildArgs: '-Tls stub -DisableLogs'
testCmd: 'bash ./.azure/test_linux.sh ''*'''
linux-stub-sanitize:
platform: 'Linux-Stub-Sanitize'
ubuntu-stub-sanitize:
platform: 'ubuntu'
config: 'stub-sanitize'
imageName: 'ubuntu-latest'
prepareCmd: 'bash ./.azure/prepare_linux.sh'
cmakeArgs: '-g ''Linux Makefiles'' -DQUIC_TLS=stub -DQUIC_SANITIZE_ADDRESS=on'
buildArgs: '-Tls stub -DisableLogs -SanitizeAddress'
testCmd: 'bash ./.azure/test_linux.sh AppData/WithSendArgs2.SendLarge/0'
linux-stub-spin:
platform: 'Linux-Stub-Spin'
imageName: 'ubuntu-latest'
prepareCmd: 'bash ./.azure/prepare_linux.sh'
cmakeArgs: '-g ''Linux Makefiles'' -DQUIC_TLS=stub -DQUIC_ENABLE_LOGGING=off -DQUIC_SANITIZE_ADDRESS=on'
ubuntu-stub-spin:
platform: 'ubuntu'
config: 'stub-spin'
buildArgs: '-Tls stub -DisableLogs -SanitizeAddress'
testCmd: 'bash ./.azure/spin_linux.sh'
linux-openssl:
platform: 'Linux-OpenSSL'
imageName: 'ubuntu-latest'
prepareCmd: 'bash ./.azure/prepare_linux.sh'
cmakeArgs: '-g ''Linux Makefiles'' -DQUIC_TLS=openssl -DQUIC_ENABLE_LOGGING=off'
ubuntu-openssl:
platform: 'ubuntu'
config: 'openssl'
buildArgs: '-Tls openssl -DisableLogs'
testCmd: 'bash ./.azure/test_linux.sh ''*'''
windows-x64-stub:
platform: 'Windows-x64-Stub'
imageName: 'windows-latest'
prepareCmd: '.\.azure\prepare_windows.cmd'
cmakeArgs: '-g ''Visual Studio 16 2019'' -A x64 -DQUIC_TLS=stub'
platform: 'windows'
config: 'stub'
buildArgs: '-Tls stub'
testCmd: '.\.azure\test_windows.cmd -*Unreachable/0'
windows-x64-stub-spin:
platform: 'Windows-x64-Stub-Spin'
imageName: 'windows-latest'
prepareCmd: '.\.azure\prepare_windows.cmd'
cmakeArgs: '-g ''Visual Studio 16 2019'' -A x64 -DQUIC_TLS=stub'
platform: 'windows'
config: 'stub-spin'
buildArgs: '-Tls stub'
testCmd: '.\.azure\spin_windows.cmd'
windows-x64-mitls:
platform: 'Windows-x64-miTLS'
imageName: 'windows-latest'
prepareCmd: '.\.azure\prepare_windows.cmd'
cmakeArgs: '-g ''Visual Studio 16 2019'' -A x64 -DQUIC_TLS=mitls'
platform: 'windows'
config: 'mitls'
buildArgs: '-Tls mitls'
testCmd: '.\.azure\test_windows.cmd -*Unreachable/0'
windows-x64-schannel:
platform: 'Windows-x64-Schannel'
imageName: 'windows-latest'
prepareCmd: '.\.azure\prepare_windows.cmd'
cmakeArgs: '-g ''Visual Studio 16 2019'' -A x64 -DQUIC_TLS=schannel'
platform: 'windows'
config: 'schannel'
buildArgs: '-Tls schannel'
testCmd: '.\.azure\test_windows.cmd ParameterValidation.*'

pool:
vmImage: $(imageName)
vmImage: '$(platform)-latest'

steps:
- checkout: self
submodules: recursive
persistCredentials: true

- task: CmdLine@2
displayName: 'Prepare Image'
inputs:
script: '$(prepareCmd)'

- task: CMake@1
displayName: 'CMake Generator'
inputs:
cmakeArgs: '$(cmakeArgs) ..'

- task: CMake@1
displayName: 'CMake Build'
- task: PowerShell@2
displayName: 'Build'
inputs:
cmakeArgs: '--build . --config DEBUG'
pwsh: true
filePath: './build.ps1'
arguments: '-InstallAzureDependencies $(buildArgs)'

- task: CmdLine@2
displayName: 'Run Tests'
timeoutInMinutes: 10
continueOnError: true
inputs:
script: '$(testCmd)'

- task: PublishBuildArtifacts@1
- task: PublishPipelineArtifact@1
displayName: 'Publish Artifacts'
inputs:
PathtoPublish: 'artifacts'
ArtifactName: '$(platform)-Artifacts'
publishLocation: 'Container'
targetPath: 'artifacts'
artifactName: '$(platform)-$(config)'

- task: PublishTestResults@2
displayName: 'Publish Test Results'
Expand Down
52 changes: 46 additions & 6 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
This script provides helpers for building msquic.
.PARAMETER InstallDependencies
Installs any necessary build dependencies.
Installs any necessary dependencies.
.PARAMETER InstallAzureDependencies
Installs any necessary Azure Pipelines dependencies.
.PARAMETER Config
The debug or release build configuration to use.
Expand Down Expand Up @@ -42,6 +45,9 @@ param (
[Parameter(Mandatory = $false)]
[switch]$InstallDependencies = $false,

[Parameter(Mandatory = $false)]
[switch]$InstallAzureDependencies = $false,

[Parameter(Mandatory = $false)]
[ValidateSet("Debug", "Release")]
[string]$Config = "Debug",
Expand Down Expand Up @@ -97,16 +103,48 @@ function Log($msg) {
Write-Host "[$(Get-Date)] $msg"
}

# Installs the dependencies.
function Install-Dependencies {
# Installs procdump if not already. Windows specific.
function Install-ProcDump {
if (!(Test-Path bld)) { mkdir bld | Out-Null }
if (!(Test-Path bld\windows)) { mkdir bld\windows | Out-Null }
if (!(Test-Path .\bld\windows\procdump)) {
Log "Installing procdump..."
# Download the zip file.
Invoke-WebRequest -Uri https://download.sysinternals.com/files/Procdump.zip -OutFile bld\windows\procdump.zip
# Extract the zip file.
Expand-Archive -Path bld\windows\procdump.zip .\bld\windows\procdump
# Delete the zip file.
Remove-Item -Path bld\windows\procdump.zip
}
}

# Installs just the Azure Pipelines dependencies.
function Install-Azure-Dependencies {
if ($IsWindows) {
# Enable SChannel TLS 1.3 (client and server).
$TlsServerKeyPath = "HKLM\System\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Server"
reg.exe add $TlsServerKeyPath /v DisabledByDefault /t REG_DWORD /d 1 /f | Out-Null
reg.exe add $TlsServerKeyPath /v Enabled /t REG_DWORD /d 1 /f | Out-Null
$TlsClientKeyPath = "HKLM\System\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Client"
reg.exe add $TlsClientKeyPath /v DisabledByDefault /t REG_DWORD /d 1 /f | Out-Null
reg.exe add $TlsClientKeyPath /v Enabled /t REG_DWORD /d 1 /f | Out-Null
# Make sure procdump is installed
Install-ProcDump
} else {
sudo apt-get install liblttng-ust-dev
sudo apt-get install lttng-tools
}
}

# Installs all the dependencies.
function Install-Dependencies {
if ($IsWindows) {
# TODO - Anything else?
} else {
sudo apt-get install cmake
sudo apt-get install build-essentials
sudo apt-get install liblttng-ust-dev
sudo apt-get install lttng-tools
}
Install-Azure-Dependencies
}

# Executes msquictext with the given arguments.
Expand Down Expand Up @@ -170,7 +208,9 @@ function CMake-Build {
if ($InstallDependencies) {
Log "Installing dependencies..."
Install-Dependencies
exit
} elseif ($InstallAzureDependencies) {
Log "Installing Azure Pipelines dependencies..."
Install-Azure-Dependencies
}

# Generate the build files.
Expand Down
4 changes: 2 additions & 2 deletions test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ if (!$IsWindows) {
}

# Path for the procdump executable.
$ProcDumpExe = $CurrentDir + "\bld\windows\procdump\procdump.exe"
$ProcDumpExe = $CurrentDir + "\bld\windows\procdump\procdump64.exe"

# Folder for log files.
$LogBaseDir = Join-Path (Join-Path $CurrentDir "artifacts") "logs"
Expand Down Expand Up @@ -250,7 +250,7 @@ function StartTestCase([String]$Name) {
}

$ResultsPath = Join-Path $LocalLogDir "results.xml"
$Arguments = "--gtest_break_on_failure --gtest_filter=$($Name) --gtest_output=xml:$($ResultsPath)"
$Arguments = "--gtest_break_on_failure --gtest_catch_exceptions=0 --gtest_filter=$($Name) --gtest_output=xml:$($ResultsPath)"

# Start the test process and return some information about the test case.
[pscustomobject]@{
Expand Down

0 comments on commit 16d76f8

Please sign in to comment.