Skip to content

Instantly share code, notes, and snippets.

@ecstatic-morse
Last active July 19, 2019 19:15
Show Gist options
  • Save ecstatic-morse/31e0021b8ac6c7e776238b1102164f80 to your computer and use it in GitHub Desktop.
Save ecstatic-morse/31e0021b8ac6c7e776238b1102164f80 to your computer and use it in GitHub Desktop.

Setting up a new Crater Windows agent machine

Operating System

The agent machine should run Windows Server build 1803 (not Windows 10). The machine should have Hyper-V enabled (images ending in v3 on Azure DevOps), although this may not be necessary since we only use process isolation. All testing has been performed on a server with a GUI, but all installation steps can be done at the command line (except configuration of Docker Desktop). It may be possible to use a headless server if Docker is already properly configured. The following paragraphs contain the rationale for choosing this particular build of Windows. If this does not interest you, skip to the next section.

Docker on Windows supports two different ways to run containers, process isolation and Hyper-V isolation. Hyper-V isolation is more secure and more flexible, but it is too slow for our purposes; it essentially spins up a VM for each container. In order to run process isolation, the build number of the agent machine and the docker image need to match. Windows Server 2016 additionally requires that the revision number of the agent machine and container image match as well. VMs based on a particular revision of Windows can be hard to find, so we must use a build later than Server 2016.

The rustops/crates-build-env-windows image is built on Azure Pipelines CI infrastructure, which provides a Windows 1803 host with docker pre-installed (the latest Windows version available on AppVeyor is Server 2016). As a result, we must use this same build of Windows to do crater runs. A later version of Windows may be used, but you'll need to build your own crates-build-env-windows image based on that version. Running containers with process isolation is not officially supported on Windows 10, so prefer Windows Server. However, you may be able to get this configuration working. Note that running containers requires a Windows 10 Professional or Enterprise license.

  • Download and run the Docker Desktop for Windows installer (not Docker Toolbox):

    (New-Object System.Net.WebClient).DownloadFile("https://download.docker.com/win/stable/Docker%20for%20Windows%20Installer.exe", ".\DockerInstaller.exe"); `
    .\DockerInstaller.exe
  • Check "Use Windows containers instead of Linux containers" during installation. This can be changed later by right-clicking the Docker icon in the dock.

  • After re-logging, Docker will detect whether "Containerization" and "Hyper-V" are enabled. If they are disabled, Docker will try to enable them for you.

Install chocolatey and git

Chocolately is a 3rd-party package manager for Windows. We'll use it to install a version of git which can be used directly from PowerShell, as well as some other useful things:

Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

Then we can install git:

choco install git

Install the Visual Studio VC++ tools

We could use the commands from the Dockerfile, but since we already installed chocolatey:

choco install -y visualstudio2017-workload-vctools

Install rust locally

Follow the normal procedure, but note that rustup-init.exe cannot be downloaded from the command line using normal Windows utilities. Instead, use curl, which is installed by default on newer versions of Windows or available via chocolately:

curl.exe -o rustup-init.exe https://win.rustup.rs/x86_64

Disabling "Real-time Protection" in "Settings > Update & Security > Windows Defender" may speed up the installation of rust-docs.

Build crater

Crater is located at https://github.com/rust-lang-nursery/crater.

Running minicrater tests require that the *.expected.json files match the output of crater exactly. However, when installed via chocolately, git has config core.autocrlf set to true by default. This will override the preferences in crater's .gitattributes file and cause the JSON files to have the wrong line endings (CRLF). Make sure you set core.autocrlf = false before cloning the repo.

If you've already cloned the repo, simply run the following from inside of it to replace the JSON files:

git config core.autocrlf false
rm -r tests/
git checkout -- tests/

Remember to run cargo run -- create-lists before running the tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment