Skip to content

Commit a44915a

Browse files
[Github] Add a windows CI container (#118206)
This patch adds a windows CI container mostly based off of the existing container used for Buildkite (https://github.com/google/llvm-premerge-checks/blob/a687e33c37fbdcf67b52805c8cf3a8ed145e3243/containers/buildkite-windows/Dockerfile#L1). This is intended to be a starting point as we transition to Github Actions with the eventual plan being to build a custom windows toolchain similar to what we do on Linux.
1 parent 229d78d commit a44915a

File tree

2 files changed

+193
-0
lines changed

2 files changed

+193
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Build Windows CI Container
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
paths:
11+
- .github/workflows/build-ci-container-windows.yml
12+
- '.github/workflows/containers/github-action-ci-windows/**'
13+
pull_request:
14+
branches:
15+
- main
16+
paths:
17+
- .github/workflows/build-ci-container-windows.yml
18+
- '.github/workflows/containers/github-action-ci-windows/**'
19+
20+
jobs:
21+
build-ci-container-windows:
22+
if: github.repository_owner == 'llvm'
23+
runs-on: windows-2019
24+
outputs:
25+
container-name: ${{ steps.vars.outputs.container-name }}
26+
container-name-tag: ${{ steps.vars.outputs.container-name-tag }}
27+
container-filename: ${{ steps.vars.outputs.container-filename }}
28+
steps:
29+
- name: Checkout LLVM
30+
uses: actions/checkout@v4
31+
with:
32+
sparse-checkout: .github/workflows/containers/github-action-ci-windows
33+
- name: Write Variables
34+
id: vars
35+
run: |
36+
$tag = [int64](Get-Date -UFormat %s)
37+
$container_name="ghcr.io/$env:GITHUB_REPOSITORY_OWNER/ci-windows-2019"
38+
echo "container-name=${container_name}" >> $env:GITHUB_OUTPUT
39+
echo "container-name-tag=${container_name}:${tag}" >> $env:GITHUB_OUTPUT
40+
echo "container-filename=ci-windows-${tag}.tar" >> $env:GITHUB_OUTPUT
41+
- name: Build Container
42+
working-directory: .github/workflows/containers/github-action-ci-windows
43+
run: |
44+
docker build -t ${{ steps.vars.outputs.container-name-tag }} .
45+
- name: Save container image
46+
run: |
47+
docker save ${{ steps.vars.outputs.container-name-tag }} > ${{ steps.vars.outputs.container-filename }}
48+
- name: Upload container image
49+
uses: actions/upload-artifact@v4
50+
with:
51+
name: container
52+
path: ${{ steps.vars.outputs.container-filename }}
53+
retention-days: 14
54+
55+
push-ci-container:
56+
if: github.event_name == 'push'
57+
needs:
58+
- build-ci-container-windows
59+
permissions:
60+
packages: write
61+
runs-on: windows-2019
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
steps:
65+
- name: Download container
66+
uses: actions/download-artifact@v4
67+
with:
68+
name: container
69+
- name: Push Container
70+
run: |
71+
docker load -i ${{ needs.build-ci-container.outptus.container-filename }}
72+
docker tag ${{ steps.vars.outputs.container-name-tag }} ${{ steps.vars.outputs.container-name }}:latest
73+
docker login -u ${{ github.actor }} -p $env:GITHUB_TOKEN ghcr.io
74+
docker push ${{ needs.build-ci-container.outputs.container-name-tag }}
75+
docker push ${{ needs.build-ci-container.outputs.container-name }}:latest
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Agent image for LLVM org cluster.
2+
# .net 4.8 is required by chocolately package manager.
3+
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019
4+
5+
# Restore the default Windows shell for correct batch processing.
6+
SHELL ["cmd", "/S", "/C"]
7+
8+
# Download the Build Tools bootstrapper.
9+
ADD https://aka.ms/vs/16/release/vs_buildtools.exe /TEMP/vs_buildtools.exe
10+
11+
RUN powershell -Command Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
12+
13+
# Download channel for fixed install.
14+
ARG CHANNEL_URL=https://aka.ms/vs/16/release/channel
15+
ADD ${CHANNEL_URL} /TEMP/VisualStudio.chman
16+
17+
# Install Build Tools with C++ workload.
18+
# - Documentation for docker installation
19+
# https://docs.microsoft.com/en-us/visualstudio/install/build-tools-container?view=vs-2019
20+
# - Documentation on workloads
21+
# https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2019#c-build-tools
22+
# - Documentation on flags
23+
# https://docs.microsoft.com/en-us/visualstudio/install/use-command-line-parameters-to-install-visual-studio?view=vs-2019
24+
RUN /TEMP/vs_buildtools.exe --quiet --wait --norestart --nocache \
25+
--channelUri C:\TEMP\VisualStudio.chman \
26+
--installChannelUri C:\TEMP\VisualStudio.chman \
27+
--installPath C:\BuildTools \
28+
--add Microsoft.VisualStudio.Workload.VCTools \
29+
--add Microsoft.VisualStudio.Component.VC.ATL \
30+
--includeRecommended \
31+
|| IF "%ERRORLEVEL%"=="3010" EXIT 0
32+
33+
# Register DIA dll (Debug Interface Access) so it can be used to symbolize
34+
# the stack traces. Register dll for 32 and 64 bit.
35+
# see https://developercommunity.visualstudio.com/content/problem/290674/msdia140dll-is-not-registered-on-vs2017-hosts.html
36+
37+
RUN regsvr32 /S "C:\BuildTools\DIA SDK\bin\amd64\msdia140.dll" & \
38+
regsvr32 /S "C:\BuildTools\DIA SDK\bin\msdia140.dll"
39+
40+
# install tools as described in https://llvm.org/docs/GettingStartedVS.html
41+
# and a few more that were not documented...
42+
RUN choco install -y ninja git
43+
# Pin an older version of Python; the current Python 3.10 fails when
44+
# doing "pip install" for the other dependencies, as it fails to find libxml
45+
# while compiling some package.
46+
RUN choco install -y python3 --version 3.9.7
47+
48+
# ActivePerl is currently not installable via Chocolatey, see
49+
# http://disq.us/p/2ipditb. Install StrawberryPerl instead. Unfortunately,
50+
# StrawberryPerl not only installs Perl, but also a redundant C/C++ compiler
51+
# toolchain, and a copy of pkg-config which can cause misdetections for other
52+
# built products, see
53+
# https://github.com/StrawberryPerl/Perl-Dist-Strawberry/issues/11 for further
54+
# details. Remove the redundant and unnecessary parts of the StrawberryPerl
55+
# install.
56+
RUN choco install -y strawberryperl && \
57+
rmdir /q /s c:\strawberry\c && \
58+
del /q c:\strawberry\perl\bin\pkg-config*
59+
60+
# libcxx requires clang(-cl) to be available
61+
RUN choco install -y sccache llvm
62+
RUN pip install psutil
63+
64+
RUN curl -LO https://github.com/mstorsjo/llvm-mingw/releases/download/20230320/llvm-mingw-20230320-ucrt-x86_64.zip && \
65+
powershell Expand-Archive llvm-mingw-*-ucrt-x86_64.zip -DestinationPath . && \
66+
del llvm-mingw-*-ucrt-x86_64.zip && \
67+
ren llvm-mingw-20230320-ucrt-x86_64 llvm-mingw
68+
69+
# configure Python encoding
70+
ENV PYTHONIOENCODING=UTF-8
71+
72+
# update the path variable
73+
# C:\Program Files\Git\usr\bin contains a usable bash and other unix tools.
74+
# C:\llvm-mingw\bin contains Clang configured for mingw targets and
75+
# corresponding sysroots. Both the 'llvm' package (with Clang defaulting
76+
# to MSVC targets) and this directory contains executables named
77+
# 'clang.exe' - add this last to let the other one have precedence.
78+
# To use these compilers, use the triple prefixed form, e.g.
79+
# x86_64-w64-mingw32-clang.
80+
# C:\buildtools and SDK paths are ones that are set by c:\BuildTools\Common7\Tools\VsDevCmd.bat -arch=amd64 -host_arch=amd64
81+
RUN powershell -Command \
82+
[System.Environment]::SetEnvironmentVariable('PATH', \
83+
[System.Environment]::GetEnvironmentVariable('PATH', 'machine') + ';C:\Program Files\Git\usr\bin;C:\llvm-mingw\bin' \
84+
+ ';C:\BuildTools\Common7\IDE\' \
85+
+ ';C:\BuildTools\Common7\IDE\CommonExt ensions\Microsoft\TeamFoundation\Team Explorer' \
86+
+ ';C:\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin' \
87+
+ ';C:\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja' \
88+
+ ';C:\BuildTools\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer' \
89+
+ ';C:\BuildTools\Common7\IDE\CommonExtensions\Microsoft\TestWindow' \
90+
+ ';C:\BuildTools\Common7\IDE\VC\VCPackages' \
91+
+ ';C:\BuildTools\Common7\Tools\' \
92+
+ ';C:\BuildTools\Common7\Tools\devinit' \
93+
+ ';C:\BuildTools\MSBuild\Current\Bin' \
94+
+ ';C:\BuildTools\MSBuild\Current\bin\Roslyn' \
95+
+ ';C:\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64' \
96+
+ ';C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64\' \
97+
+ ';C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64' \
98+
+ ';C:\Program Files (x86)\Windows Kits\10\bin\x64' \
99+
+ ';C:\Windows\Microsoft.NET\Framework64\v4.0.30319' \
100+
,'machine')
101+
102+
# support long file names during git checkout
103+
RUN git config --system core.longpaths true & \
104+
git config --global core.autocrlf false
105+
106+
# handle for debugging of files beeing locked by some processes.
107+
RUN choco install -y handle
108+
109+
RUN pip3 install pywin32 buildbot-worker==2.8.4
110+
111+
ARG RUNNER_VERSION=2.319.1
112+
ENV RUNNER_VERSION=$RUNNER_VERSION
113+
114+
RUN powershell -Command \
115+
Invoke-WebRequest -Uri https://github.com/actions/runner/releases/download/v${env:RUNNER_VERSION}/actions-runner-win-x64-${env:RUNNER_VERSION}.zip -OutFile actions-runner-win.zip ; \
116+
Add-Type -AssemblyName System.IO.Compression.FileSystem ; \
117+
[System.IO.Compression.ZipFile]::ExtractToDirectory('actions-runner-win.zip', $PWD) ;\
118+
rm actions-runner-win.zip

0 commit comments

Comments
 (0)