1
0
Fork 0

Create docker container for Windows build (#52)

* first steps towards windows builds #25

* added build scripts for windows

* moved from powershell to CMD

* script cleanup

* set up jenkins swarm plugin

* added deployment script for windows

* first draft of jenkins file for windows

* first shot at windows pods

* first draft for buildkite agent

* added call to run_cmake.bat

* added call to run_ninja.bat

* added new buildkite script

* added Dockerfile for buildkite agent

* fixed userprofile path

* added /IncludeOptional for VS

I hope that includes all required libraries

* moved work folder to W:

* added git config for long file names

* added more CMake flags

* setting x64 bit arch in a different way

* and yet another way to set 64bit

* merged buildkite changes to jenkins scripts

* hiding license in batch script runs

* running release build

* added test xml log

* compilation is working, but not all tests

* cmake is in patch now

* updated the dependencies from buildkite config

* dockerfile cleanup

* change how git handles line endings

* updated comment

* performance improvment for volume

* changed workdir folder

* using gnuwin package

split installation into separate layers to speed up incremental changes
This commit is contained in:
ChristianKuehnel 2019-11-26 17:10:30 +01:00 committed by GitHub
parent 9b90c3fb20
commit de34fb9572
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 387 additions and 0 deletions

68
Jenkins/Windows-pipeline/Jenkinsfile vendored Normal file
View file

@ -0,0 +1,68 @@
// Copyright 2019 Google LLC
//
// Licensed under the the Apache License v2.0 with LLVM Exceptions (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://llvm.org/LICENSE.txt
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
pipeline {
agent any
triggers {
pollSCM 'H H/2 * * *'
}
environment {
BUILD_ID="${JOB_BASE_NAME}-${BUILD_NUMBER}"
//TARGET_DIR="/mnt/nfs/results/${BUILD_ID}"
SCRIPT_DIR = "${WORKSPACE}\\llvm-premerge-checks\\scripts"
}
stages {
stage("git checkout"){
steps {
git url: 'https://github.com/llvm/llvm-project.git'
sh 'git clean -fdx'
sh 'mkdir -p llvm-premerge-checks'
dir("llvm-premerge-checks")
{
git url: 'https://github.com/google/llvm-premerge-checks.git'
}
}
}
stage('CMake') {
steps {
sh "${SCRIPT_DIR}\\run_cmake.bat"
}
}
stage('ninja all') {
steps {
sh "${SCRIPT_DIR}\\run_ninja.bat all"
}
}
stage('ninja check') {
steps {
sh "${SCRIPT_DIR}\\run_ninja.bat check"
}
}
stage('ninja check-all') {
steps {
sh "${SCRIPT_DIR}\\run_ninja.bat check-all"
}
}
}
// post {
// always {
// echo "Console log is available at https://results.new.llvm-merge-guard.org/${BUILD_ID}"
// dir("${env.TARGET_DIR}") {
// // copy console log to result folder
// sh "wget -qO console-log.txt http://jenkins-ui.jenkins.svc.cluster.local:8080/job/${JOB_BASE_NAME}/${BUILD_NUMBER}/consoleText"
// }
// }
// }
}

View file

@ -1,2 +1,11 @@
# Overview
This folder contains files related to the machines running the build/test/checks for the merge guards.
## Scripts
The scripts are written in bash (for Linux) and powershell (for Windows).
### build_run.(sh|ps1)
Build the docker image and run it locally. This is useful for testing it.
### build_deploy.(sh|ps1)
Build the docker and deploy it to the GCP registry. This is useful for deploying it in the Kubernetes cluster.

View file

@ -0,0 +1,56 @@
# escape=`
# use windows server core image
ARG version=ltsc2019
FROM mcr.microsoft.com/windows/servercore:$version
# install chocolately as package manager
RUN powershell -Command `
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')) ; `
choco feature disable --name showDownloadProgress
# install Visual Studio build tools
RUN powershell -NoProfile -InputFormat None -Command `
choco install visualcpp-build-tools `
--version 15.0.26228.20170424 -y --params "'/IncludeOptional'" ;`
Write-Host 'Waiting for Visual C++ Build Tools to finish'; `
Wait-Process -Name vs_installer
# install other tools as described in https://llvm.org/docs/GettingStartedVS.html
# and a few more that were not documented...
RUN choco install -y git & `
choco install -y cmake --version 3.15.4 & `
choco install -y python2 & `
choco install -y gnuwin32-coreutils.install & `
choco install -y ninja & `
choco install -y grep & `
choco install -y sed & `
choco install -y diffutils
RUN pip install psutil
# configure Python encoding
ENV PYTHONIOENCODING=UTF-8
# update the path variable
RUN powershell.exe -Command $path = $env:path + ';c:\Program Files (x86)\GnuWin32\bin;C:\Program Files\CMake\bin'; Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' -Name Path -Value $path
# use this drive to store the worksapce'
VOLUME W:
# install buildkite agent as described in the documentation
# https://buildkite.com/docs/agent/v3/windows
# Supply your agent token via the arguement "-token <mytoken" when building the image
ARG token
ENV buildkiteAgentToken="${token}"
ENV BUILDKITE_BUILD_PATH=W:\buildkite
ENV BUILDKITE_AGENT_NAME=amd64-windows-visualstudio2017
RUN powershell -NoProfile -InputFormat None -Command `
Set-ExecutionPolicy Bypass -Scope Process -Force ; `
iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/buildkite/agent/master/install.ps1'))
# support long file names and do not change line endings
RUN git config --system core.longpaths true & `
git config --global core.autocrlf false
CMD "C:\buildkite-agent\bin\buildkite-agent.exe" start

View file

@ -0,0 +1,44 @@
# escape=`
# use windows server core image
ARG version=ltsc2019
FROM mcr.microsoft.com/windows/servercore:$version
# install chocolately as package manager
RUN powershell -Command `
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')) ; `
choco feature disable --name showDownloadProgress
# install Visual Studio build tools
RUN powershell -NoProfile -InputFormat None -Command `
choco install visualcpp-build-tools `
--version 15.0.26228.20170424 -y --params "'/IncludeOptional'" ;`
Write-Host 'Waiting for Visual C++ Build Tools to finish'; `
Wait-Process -Name vs_installer
# install other tools as described in https://llvm.org/docs/GettingStartedVS.html
# and a few more that were not documented...
RUN choco install -y git
RUN choco install -y cmake --version 3.15.4
RUN choco install -y python2
RUN choco install -y ninja
RUN choco install -y gnuwin
RUN pip install psutil
# configure Python encoding
ENV PYTHONIOENCODING=UTF-8
# update the path variable
RUN powershell.exe -Command $path = $env:path + ';c:\Program Files (x86)\GnuWin32\bin;C:\Program Files\CMake\bin'; Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' -Name Path -Value $path
# use this folder to store the worksapce'
VOLUME C:\workspace
WORKDIR C:\workspace
# support long file names during git checkout
RUN git config --system core.longpaths true & `
git config --global core.autocrlf false
# Start developer command prompt with any other commands specified.
#ENTRYPOINT "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat" &
CMD cmd

View file

@ -0,0 +1,33 @@
# Copyright 2019 Google LLC
# Licensed under the the Apache License v2.0 with LLVM Exceptions (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# https://llvm.org/LICENSE.txt
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# define command line arguments
param(
[Parameter(Mandatory=$true)][string]$IMAGE_NAME
)
New-Variable -Name ROOT_DIR -Value (Get-Item $PSScriptRoot).Parent.FullName
# get config options
Get-Content "${ROOT_DIR}/k8s_config" | Foreach-Object{
$var = $_.Split('=')
New-Variable -Name $var[0] -Value $var[1]
}
New-Variable -Name QUALIFIED_NAME -Value "${GCR_HOSTNAME}/${GCP_PROJECT}/${IMAGE_NAME}"
Set-Location "$PSScriptRoot\$IMAGE_NAME"
docker build -t $IMAGE_NAME .
docker tag $IMAGE_NAME $QUALIFIED_NAME
docker push $QUALIFIED_NAME

35
containers/build_run.ps1 Normal file
View file

@ -0,0 +1,35 @@
# Copyright 2019 Google LLC
#
# Licensed under the the Apache License v2.0 with LLVM Exceptions (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://llvm.org/LICENSE.txt
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# define command line arguments
param(
[Parameter(Mandatory=$true)][string]$IMAGE_NAME,
[string]$token
)
# set script to stop on first error
$ErrorActionPreference = "Stop"
# some docs recommend setting 2GB memory limit
docker build --memory 2GB -t $IMAGE_NAME --build-arg token=$token "$PSScriptRoot\$IMAGE_NAME"
If ($LastExitCode -ne 0) {
exit
}
# mount a persistent workspace for experiments
New-Item -ItemType Directory -Force -Path $Env:USERPROFILE\workspace
docker run -it -v $Env:USERPROFILE\workspace:C:\workspace $IMAGE_NAME
If ($LastExitCode -ne 0) {
exit
}

View file

@ -31,6 +31,11 @@ gcloud container clusters create $GCP_CLUSTER --zone $GCP_ZONE \
gcloud container node-pools create jenkins-agents --cluster $GCP_CLUSTER --zone $GCP_ZONE \
--machine-type=n1-standard-32 --num-nodes=2 --local-ssd-count=1
# Windows agents with local ssd
gcloud container node-pools create windows-pool --cluster $GCP_CLUSTER \
--image-type=WINDOWS_SAC --no-enable-autoupgrade \
--machine-type=n1-standard-16 --local-ssd-count=1
# create static IP address
# IP can be created, but not used in Ingress. Not sure why
gcloud compute addresses create web-static-ip --zone=$GCP_ZONE

View file

@ -188,3 +188,42 @@ spec:
type: Directory
nodeSelector:
cloud.google.com/gke-nodepool: jenkins-agents
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: agent-windows-visualstudio2017-ssd
namespace: jenkins
spec:
replicas: 1
template:
metadata:
labels:
app: agent-windows-visualstudio2017-ssd
spec:
containers:
- name: agent-windows-visualstudio2017-ssd
image: gcr.io/llvm-premerge-checks/agent-windows
resources:
limits:
cpu: 14
memory: 20Gi
requests:
cpu: 14
memory: 20Gi
# volumeMounts:
# - name: nfs-pvc
# mountPath: /mnt/nfs
# - name: ssd
# mountPath: /mnt/disks/ssd0
# volumes:
# - name: nfs-pvc
# persistentVolumeClaim:
# claimName: nfs-jenkins
# - name: ssd
# hostPath:
# # directory location on host
# path: /mnt/disks/ssd0
# type: Directory
nodeSelector:
cloud.google.com/gke-nodepool: jenkins-agents

24
scripts/benchmark.ps1 Normal file
View file

@ -0,0 +1,24 @@
# Copyright 2019 Google LLC
# Licensed under the the Apache License v2.0 with LLVM Exceptions (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# https://llvm.org/LICENSE.txt
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
param(
[Parameter(Mandatory=$true)][string]$WORKDIR
)
Measure-Command { git clone --depth 1 https://github.com/llvm/llvm-project $WORKDIR }
Set-Location $WORKDIR
Measure-Command {& $PSScriptRoot\run_cmake.bat}
Measure-Command {& $PSScriptRoot\run_ninja.bat all}
Measure-Command {& $PSScriptRoot\run_ninja.bat check-all}

25
scripts/run_buildkite.bat Normal file
View file

@ -0,0 +1,25 @@
rem Copyright 2019 Google LLC
rem
rem Licensed under the the Apache License v2.0 with LLVM Exceptions (the "License");
rem you may not use this file except in compliance with the License.
rem You may obtain a copy of the License at
rem
rem https://llvm.org/LICENSE.txt
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.
md build
cd build
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat" -arch=amd64 -host_arch=amd64
cmake.exe ..\llvm -G Ninja ^
-D LLVM_ENABLE_PROJECTS="clang;clang-tools-extra;libcxx;libcxxabi;lld" ^
-D LLVM_ENABLE_ASSERTIONS=ON
ninja all
ninja check-all

27
scripts/run_cmake.bat Normal file
View file

@ -0,0 +1,27 @@
@rem Copyright 2019 Google LLC
@rem
@rem Licensed under the the Apache License v2.0 with LLVM Exceptions (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://llvm.org/LICENSE.txt
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
PUSHD %1
md build
cd build
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat" -arch=amd64 -host_arch=amd64
cmake.exe ..\llvm -G Ninja -DCMAKE_BUILD_TYPE=Release ^
-D LLVM_ENABLE_PROJECTS="clang;clang-tools-extra;libcxx;libcxxabi;lld" ^
-D LLVM_ENABLE_ASSERTIONS=ON ^
-DLLVM_LIT_ARGS="-v --xunit-xml-output test-results.xml"
POPD

22
scripts/run_ninja.bat Normal file
View file

@ -0,0 +1,22 @@
@rem Copyright 2019 Google LLC
@rem
@rem Licensed under the the Apache License v2.0 with LLVM Exceptions (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://llvm.org/LICENSE.txt
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
PUSHD %1
cd build
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat" -arch=amd64 -host_arch=amd64
ninja %1
POPD