From de34fb9572ec220130d79a429f9e677177389de2 Mon Sep 17 00:00:00 2001 From: ChristianKuehnel Date: Tue, 26 Nov 2019 17:10:30 +0100 Subject: [PATCH] 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 --- Jenkins/Windows-pipeline/Jenkinsfile | 68 +++++++++++++++++++ containers/README.md | 9 +++ containers/agent-windows-buildkite/Dockerfile | 56 +++++++++++++++ containers/agent-windows/Dockerfile | 44 ++++++++++++ containers/build_deploy.ps1 | 33 +++++++++ containers/build_run.ps1 | 35 ++++++++++ kubernetes/cluster_create.sh | 5 ++ kubernetes/jenkins.yaml | 39 +++++++++++ scripts/benchmark.ps1 | 24 +++++++ scripts/run_buildkite.bat | 25 +++++++ scripts/run_cmake.bat | 27 ++++++++ scripts/run_ninja.bat | 22 ++++++ 12 files changed, 387 insertions(+) create mode 100644 Jenkins/Windows-pipeline/Jenkinsfile create mode 100644 containers/agent-windows-buildkite/Dockerfile create mode 100644 containers/agent-windows/Dockerfile create mode 100644 containers/build_deploy.ps1 create mode 100644 containers/build_run.ps1 create mode 100644 scripts/benchmark.ps1 create mode 100644 scripts/run_buildkite.bat create mode 100644 scripts/run_cmake.bat create mode 100644 scripts/run_ninja.bat diff --git a/Jenkins/Windows-pipeline/Jenkinsfile b/Jenkins/Windows-pipeline/Jenkinsfile new file mode 100644 index 0000000..e41b9c0 --- /dev/null +++ b/Jenkins/Windows-pipeline/Jenkinsfile @@ -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" + // } + // } + // } +} \ No newline at end of file diff --git a/containers/README.md b/containers/README.md index 1f0fd27..d054770 100644 --- a/containers/README.md +++ b/containers/README.md @@ -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. \ No newline at end of file diff --git a/containers/agent-windows-buildkite/Dockerfile b/containers/agent-windows-buildkite/Dockerfile new file mode 100644 index 0000000..1e643c1 --- /dev/null +++ b/containers/agent-windows-buildkite/Dockerfile @@ -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