From fb22bed04ac44d3ccfa14b92c0bf6be09dab20c8 Mon Sep 17 00:00:00 2001 From: Davide Beatrici Date: Tue, 15 Jan 2019 02:14:05 +0100 Subject: [PATCH] Add Azure Pipelines for continuous integration (Windows) Azure Pipelines offers many advantages over AppVeyor, with the biggest one being a maximum of 10 parallel builds for open-source projects, drastically reducing the builds completion time. A pipeline takes about the same time to build on the two CI infrastructures, however the caching feature is currently only available on AppVeyor, meaning that on Azure Pipelines the compressed environment is downloaded for each build consuming about 10 minutes. This means that we'll save at least 10 minutes per pipeline compared to AppVeyor once the feature is added to Azure Pipelines: https://github.com/Microsoft/azure-pipelines-tasks/issues/9190 --- .azure-pipelines.yml | 22 +++++++ scripts/azure-pipelines/build.ps1 | 60 +++++++++++++++++++ .../azure-pipelines/install-environment.ps1 | 39 ++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 .azure-pipelines.yml create mode 100644 scripts/azure-pipelines/build.ps1 create mode 100644 scripts/azure-pipelines/install-environment.ps1 diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml new file mode 100644 index 00000000000..842919d168f --- /dev/null +++ b/.azure-pipelines.yml @@ -0,0 +1,22 @@ +jobs: + - job: Windows + strategy: + matrix: + MSVC_2015: + MUMBLE_QT: qt5 + MUMBLE_HOST: x86_64-pc-windows-msvc + MSVC_2015_NO_PCH: + MUMBLE_QT: qt5 + MUMBLE_HOST: x86_64-pc-windows-msvc + MUMBLE_NO_PCH: 1 + steps: + - script: git submodule --quiet update --init --recursive + displayName: 'Fetch submodules' + - powershell: | + Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) + choco install 7zip.install -y + displayName: 'Install 7-Zip via Chocolatey' + - powershell: scripts/azure-pipelines/install-environment.ps1 + displayName: 'Install build environment' + - powershell: scripts/azure-pipelines/build.ps1 + displayName: 'Build' diff --git a/scripts/azure-pipelines/build.ps1 b/scripts/azure-pipelines/build.ps1 new file mode 100644 index 00000000000..61968b61cca --- /dev/null +++ b/scripts/azure-pipelines/build.ps1 @@ -0,0 +1,60 @@ +# Builds Mumble using the specified build script. +# The path to the script is relative to the build environment's root. +# The configuration we build with is adjusted to be close to +# our release builds. +# +# Below is a list of configuration variables used from environment. +# +# Predefined variables: +# +# AGENT_BUILDDIRECTORY - Predefined variable. +# The local path on the agent where all folders +# for a given build pipeline are created +# (e.g. "D:\a\1") +# BUILD_SOURCESDIRECTORY - Predefined variable. +# The local path on the agent where the +# repository is downloaded. +# (e.g. "D:\a\1\s") +# +# Defined in the visual designer on Azure Pipelines: +# +# MUMBLE_ENVIRONMENT_DIR - The local path where the build environment +# is stored (e.g. "C:\MumbleBuild"). +# MUMBLE_ENVIRONMENT_VERSION - Full build environment version +# (e.g. win64-static-no-ltcg-1.3.x-2017-02-02-ec94ddb-790). +# Must match .7z and extracted folder name. +# MUMBLE_BUILDSCRIPT - Path to required build script cmd file. Relative to build +# environment's "mumble-releng\buildscripts" path. +# (e.g. "1.3.x/buildenv-win64-static.cmd") +# +# Defined in the YAML configuration: +# +# MUMBLE_NO_PCH - Indicates whether the build should not use PCH. +# + +$MUMBLE_BUILD_DIR = $env:AGENT_BUILDDIRECTORY +$MUMBLE_SOURCE_DIR = $env:BUILD_SOURCESDIRECTORY +$MUMBLE_BUILDENV_DIR = Join-Path $env:MUMBLE_ENVIRONMENT_DIR $env:MUMBLE_ENVIRONMENT_VERSION +$MUMBLE_BUILDSCRIPT = Join-Path $MUMBLE_BUILDENV_DIR "mumble-releng\buildscripts\$env:MUMBLE_BUILDSCRIPT" + +$env:MUMBLE_EXTRA_QMAKE_CONFIG_FLAGS = "" + +# We do not sign the Azure Pipelines CI builds, so we must disable +# uiaccess elevation. Also no intermediary signing is wanted. +$env:MUMBLE_EXTRA_QMAKE_CONFIG_FLAGS = $env:MUMBLE_EXTRA_QMAKE_CONFIG_FLAGS + " no-elevation" + +# If "MUMBLE_NO_PCH" is enabled, pass "no-pch". +if ($env:MUMBLE_NO_PCH -eq 1) { + $env:MUMBLE_EXTRA_QMAKE_CONFIG_FLAGS = $env:MUMBLE_EXTRA_QMAKE_CONFIG_FLAGS + " no-pch" +} + +# Use jom to take advantage of the multiple cores we get on the builder. +$env:MUMBLE_NMAKE = "jom" +$env:MUMBLE_SKIP_COLLECT_SYMBOLS = "1" +$env:MUMBLE_SKIP_INTERNAL_SIGNING = "1" +$env:MUMBLE_BUILDENV_DIR = $MUMBLE_BUILDENV_DIR + +Get-ChildItem -Path $MUMBLE_BUILD_DIR + +& $MUMBLE_BUILDSCRIPT +exit $lastexitcode diff --git a/scripts/azure-pipelines/install-environment.ps1 b/scripts/azure-pipelines/install-environment.ps1 new file mode 100644 index 00000000000..5b49dc4535e --- /dev/null +++ b/scripts/azure-pipelines/install-environment.ps1 @@ -0,0 +1,39 @@ +# Ensures we have downloaded and extracted a build environment +# into our Azure Pipelines VM before we attempt to build. If the +# environment was already cached and hence already present +# this script will detect that. +# +# Configuration variables (defined in the visual designer on Azure Pipelines) used from environment: +# +# MUMBLE_ENVIRONMENT_DIR - The local path where the build environment +# will be stored (e.g. "C:\MumbleBuild"). +# MUMBLE_ENVIRONMENT_SOURCE - Build environment web source folder URL +# (e.g. https://somehost/folder). +# MUMBLE_ENVIRONMENT_VERSION - Full build environment version +# (e.g. win64-static-no-ltcg-1.3.x-2017-02-02-ec94ddb-790). +# Must match .7z and extracted folder name. +# + +$MUMBLE_ENVIRONMENT_VERSION = $env:MUMBLE_ENVIRONMENT_VERSION +$MUMBLE_ENVIRONMENT_SOURCE = $env:MUMBLE_ENVIRONMENT_SOURCE +$MUMBLE_ENVIRONMENT_DIR = $env:MUMBLE_ENVIRONMENT_DIR +$MUMBLE_ENVIRONMENT_STORE = Join-Path $MUMBLE_ENVIRONMENT_DIR "\cache" + +if (-Not (Test-Path $MUMBLE_ENVIRONMENT_STORE)) { + New-Item $MUMBLE_ENVIRONMENT_STORE -ItemType Directory | Out-Null + } + +$env_7z = Join-Path $MUMBLE_ENVIRONMENT_STORE "$MUMBLE_ENVIRONMENT_VERSION.7z"; + +if (-Not (Test-Path $env_7z)) { + Write-Host "Environment not cached. Downloading..." + $env_url = "$MUMBLE_ENVIRONMENT_SOURCE/$MUMBLE_ENVIRONMENT_VERSION.7z" + Invoke-WebRequest -Uri $env_url -OutFile $env_7z +} + +if (-Not (Test-Path (Join-Path $MUMBLE_ENVIRONMENT_DIR $MUMBLE_ENVIRONMENT_VERSION))) { + Write-Host "Extracting build environment to $MUMBLE_ENVIRONMENT_DIR..." + & C:\ProgramData\chocolatey\bin\7z.exe x $env_7z -o"$MUMBLE_ENVIRONMENT_DIR" +} + +Get-ChildItem -Path $MUMBLE_ENVIRONMENT_DIR