Merge pull request #8868 from Icinga/feature/gha-windows-211

GitHub actions: build Windows
This commit is contained in:
Alexander Aleksandrovič Klimov 2021-07-06 10:26:43 +02:00 committed by GitHub
commit 9512e7b30b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 172 additions and 69 deletions

View File

@ -308,3 +308,41 @@ jobs:
# -e ICINGA_BUILD_DEB_DEFAULT_ARCH=armhf \
# registry.icinga.com/build-docker/raspbian/${{ matrix.codename }} \
# icinga-build-test
windows:
name: Windows
strategy:
fail-fast: false
matrix:
bits: [32, 64]
runs-on: windows-latest
env:
BITS: '${{ matrix.bits }}'
ICINGA_BUILD_TYPE: snapshot
UPSTREAM_GIT_URL: file://D:/a/icinga2/icinga2/.git
steps:
- name: Checkout HEAD
uses: actions/checkout@v1
- name: windows-icinga2
run: |
git clone https://git.icinga.com/packaging/windows-icinga2.git
- name: Build tools
run: |
& .\doc\win-dev.ps1
- name: Source
run: |
git checkout -B master
cd windows-icinga2
& .\source.ps1
- name: Binary
working-directory: windows-icinga2
run: |
New-Item -ItemType Directory -Path 'C:\Program Files\Icinga2\WillBeRemoved' -ErrorAction SilentlyContinue
& .\build.ps1

View File

@ -1,63 +0,0 @@
---
version: 2.11.0.dev.{build}
os: Visual Studio 2017
platform: x64
environment:
BITS: 64
CMAKE_BUILD_TYPE: Debug
CMAKE_GENERATOR: "Visual Studio 15 2017 Win64"
# https://www.appveyor.com/docs/windows-images-software/#boost
BOOST_ROOT: 'C:\Libraries\boost_1_67_0'
BOOST_LIBRARYDIR: 'C:\Libraries\boost_1_67_0\lib64-msvc-14.1'
# https://www.appveyor.com/docs/windows-images-software/#tools
OPENSSL_ROOT_DIR: 'C:\OpenSSL-v111-Win64'
BISON_BINARY: 'C:\ProgramData\chocolatey\lib\winflexbison3\tools\win_bison.exe'
FLEX_BINARY: 'C:\ProgramData\chocolatey\lib\winflexbison3\tools\win_flex.exe'
branches:
only:
- master
cache:
- build -> appveyor.yml
- C:\ProgramData\chocolatey\lib\winflexbison3
install:
- ps: |
if (-not (Test-Path "C:\ProgramData\chocolatey\lib\winflexbison3")) {
& choco install winflexbison3
if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
}
# why that env handling, see
# https://help.appveyor.com/discussions/questions/18777-how-to-use-vcvars64bat-from-powershell#comment_44999171
before_build:
- ps: |
& .\tools\win32\load-vsenv.ps1
& powershell.exe .\tools\win32\configure.ps1
if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
del build\Icinga*.msi
build_script:
- ps: |
& powershell.exe .\tools\win32\build.ps1
if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
test_script:
- ps: |
& powershell.exe .\tools\win32\test.ps1
if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
# Disable until we really need them
# https://github.com/Icinga/icinga2/issues/6106
# https://help.appveyor.com/discussions/problems/10253-maximum-allowed-artifact-storage-size-of-1000-mb-will-be-exceeded
#artifacts:
#- path: build/Icinga*.msi
#- path: build/choco/*.nupkg
#- path: build/Test.xml
deploy: off

View File

@ -1700,6 +1700,42 @@ The required steps are described in [this script](https://github.com/dnsmichi/do
The following sections explain how to setup the required build tools
and how to run and debug the code.
#### TL;DR
If you're going to setup a dev environment on a fresh Windows machine
and don't care for the details,
1. ensure there are 35 GB free space on C:
2. run the following in an administrative Powershell:
1. `Enable-WindowsOptionalFeature -FeatureName "NetFx3" -Online`
(reboot when asked!)
2. `powershell -NoProfile -ExecutionPolicy Bypass -Command "Invoke-Expression (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/Icinga/icinga2/master/doc/win-dev.ps1')"`
(will take some time)
This installs everything needed for cloning and building Icinga 2
on the command line (Powershell) as follows:
(Don't forget to open a new Powershell window
to be able to use the newly installed Git.)
```
git clone https://github.com/Icinga/icinga2.git
cd .\icinga2\
mkdir build
cd .\build\
& "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" `
-DBoost_INCLUDE_DIR=C:\local\boost_1_71_0-Win64 `
-DBISON_EXECUTABLE=C:\ProgramData\chocolatey\lib\winflexbison3\tools\win_bison.exe `
-DFLEX_EXECUTABLE=C:\ProgramData\chocolatey\lib\winflexbison3\tools\win_flex.exe `
-DICINGA2_WITH_MYSQL=OFF -DICINGA2_WITH_PGSQL=OFF ..
& "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe" .\icinga2.sln
```
Building icinga2.sln via Visual Studio itself seems to require a reboot
after installing the build tools and building once via command line.
#### Chocolatey
Open an administrative command prompt (Win key, type “cmd”, right-click and “run as administrator”) and paste the following instructions:

89
doc/win-dev.ps1 Normal file
View File

@ -0,0 +1,89 @@
Set-PSDebug -Trace 1
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$PSDefaultParameterValues['*:ErrorAction'] = 'Stop'
function ThrowOnNativeFailure {
if (-not $?) {
throw 'Native failure'
}
}
$VsVersion = 2019
$MsvcVersion = '14.2'
$BoostVersion = @(1, 71, 0)
$OpensslVersion = '1_1_1h'
switch ($Env:BITS) {
32 { }
64 { }
default {
$Env:BITS = 64
}
}
function Install-Exe {
param (
[string]$Url,
[string]$Dir
)
$TempDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.Guid]::NewGuid().Guid)
$ExeFile = Join-Path $TempDir inst.exe
New-Item -ItemType Directory -Path $TempDir
for ($trial = 1;; ++$trial) {
try {
Invoke-WebRequest -Uri $Url -OutFile $ExeFile -UseBasicParsing
} catch {
if ($trial -ge 2) {
throw
}
continue
}
break
}
Start-Process -Wait -FilePath $ExeFile -ArgumentList @('/VERYSILENT', '/INSTALL', '/PASSIVE', '/NORESTART', "/DIR=${Dir}")
Remove-Item -Recurse -Path $TempDir
}
try {
Get-Command choco
} catch {
Invoke-Expression (New-Object Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')
$RegEnv = 'Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment'
$ChocoPath = ";$(Join-Path $Env:AllUsersProfile chocolatey\bin)"
Set-ItemProperty -Path $RegEnv -Name Path -Value ((Get-ItemProperty -Path $RegEnv -Name Path).Path + $ChocoPath)
$Env:Path += $ChocoPath
}
choco install -y "visualstudio${VsVersion}community"
choco install -y "visualstudio${VsVersion}-workload-netcoretools"
choco install -y "visualstudio${VsVersion}-workload-vctools"
choco install -y "visualstudio${VsVersion}-workload-manageddesktop"
choco install -y "visualstudio${VsVersion}-workload-nativedesktop"
choco install -y "visualstudio${VsVersion}-workload-universal"
choco install -y "visualstudio${VsVersion}buildtools"
choco install -y git
choco install -y cmake
choco install -y winflexbison3
choco install -y windows-sdk-8.1
choco install -y wixtoolset
Install-Exe -Url "https://packages.icinga.com/windows/dependencies/boost_$($BoostVersion -join '_')-msvc-${MsvcVersion}-${Env:BITS}.exe" -Dir "C:\local\boost_$($BoostVersion -join '_')-Win${Env:BITS}"
Install-Exe -Url "https://packages.icinga.com/windows/dependencies/Win${Env:BITS}OpenSSL-${OpensslVersion}.exe" -Dir "C:\local\OpenSSL_${OpensslVersion}-Win${Env:BITS}"

View File

@ -17,16 +17,19 @@ if (-not ($env:PATH -contains $env:CMAKE_PATH)) {
$env:PATH = $env:CMAKE_PATH + ';' + $env:PATH
}
if (-not (Test-Path env:CMAKE_GENERATOR)) {
$env:CMAKE_GENERATOR = 'Visual Studio 15 2017 Win64'
$env:CMAKE_GENERATOR = 'Visual Studio 16 2019'
}
if (-not (Test-Path env:CMAKE_GENERATOR_PLATFORM)) {
$env:CMAKE_GENERATOR_PLATFORM = 'x64'
}
if (-not (Test-Path env:OPENSSL_ROOT_DIR)) {
$env:OPENSSL_ROOT_DIR = 'c:\local\OpenSSL_1_1_1b-Win64'
$env:OPENSSL_ROOT_DIR = 'c:\local\OpenSSL_1_1_1h-Win64'
}
if (-not (Test-Path env:BOOST_ROOT)) {
$env:BOOST_ROOT = 'c:\local\boost_1_69_0-Win64'
$env:BOOST_ROOT = 'c:\local\boost_1_71_0-Win64'
}
if (-not (Test-Path env:BOOST_LIBRARYDIR)) {
$env:BOOST_LIBRARYDIR = 'c:\local\boost_1_69_0-Win64\lib64-msvc-14.1'
$env:BOOST_LIBRARYDIR = 'c:\local\boost_1_71_0-Win64\lib64-msvc-14.2'
}
if (-not (Test-Path env:FLEX_BINARY)) {
$env:FLEX_BINARY = 'C:\ProgramData\chocolatey\bin\win_flex.exe'
@ -48,7 +51,7 @@ if (Test-Path CMakeCache.txt) {
& cmake.exe "$sourcePath" `
-DCMAKE_BUILD_TYPE="$env:CMAKE_BUILD_TYPE" `
-G "$env:CMAKE_GENERATOR" -DCPACK_GENERATOR=WIX `
-G "$env:CMAKE_GENERATOR" -A "$env:CMAKE_GENERATOR_PLATFORM" -DCPACK_GENERATOR=WIX `
-DICINGA2_WITH_MYSQL=OFF -DICINGA2_WITH_PGSQL=OFF `
-DICINGA2_WITH_LIVESTATUS=OFF -DICINGA2_WITH_COMPAT=OFF `
-DOPENSSL_ROOT_DIR="$env:OPENSSL_ROOT_DIR" `

View File

@ -18,7 +18,7 @@ if (-not (Test-Path $BUILD)) {
if (Test-Path env:VS_INSTALL_PATH) {
$VSBASE = $env:VS_INSTALL_PATH
} else {
$VSBASE = "C:\Program Files (x86)\Microsoft Visual Studio\2017"
$VSBASE = "C:\Program Files (x86)\Microsoft Visual Studio\2019"
}
if (Test-Path env:BITS) {