Running Mir CI Locally

For the Impatient

In order to run Mir CI locally, you need:

  1. A version of spread with various fixes, such as can be found here
  2. LXD installed
  3. To enter the Mir source directory, and run something like spread lxd:ubuntu-16.04:…:amd64

A Fuller Exposition


For Mir we use Travis CI. We want to be sure we can build on a bunch of different systems - currently: Ubuntu 16.04, Ubuntu 17.10, the latest Ubuntu development release, Fedora 27 - on amd64 and aarch64 architectures, and with the clang compiler to pick up problems gcc doesn’t.

That ends up being a lot of builds. Also unfortunately, our build + test cycle takes more than 60 minutes on the Travis builders. Fortunately, the enterprising snap team at Canonical has had similar problems in the past, and built the spread tool. We can ship out the build matrix to our (substantially beefier) Linode systems, and everyone retires for ice cream.

A secondary bonus of using spread is that it’s easy to spin up a very good facsimile of the CI environment locally, using the lxd provider!


First, you’ll need LXD. For cross-distro support I’ll be using the Snap version of LXD for this guide.

  1. Install snapd for your distro
  2. Install LXD (as root, or using sudo): sudo snap install lxd
  3. Install the spread snap. Unfortunately, the version in the Snap store has a number of issues - the lxd backend is nonfunctional, and it fails with Fedora images. Until these pull requests are merged, you need to:
    1. Download my build of spread
    2. Install it with sudo snap install –dangerous spread.snap
    3. Connect up the lxd interface with sudo snap connect spread:lxd lxd:lxd

Running the tests

Now we can run the Mir tests, using spread on the local machine! Because we’re using the LXD snap, the LXD socket is not in the location that spread expects, so we need to set LXD_DIR=/var/snap/lxd/common/lxd in the environment.

Now, to investigate a failing build, we can run:

LXD_DIR=/var/snap/lxd/common/lxd spread -debug lxd:fedora-27:...:amd64

The -debug flag tells spread to stop and run a shell on failure, which can make debugging failures much more pleasant. The Mir source is in $SPREAD_DIR. Where the build is depends on the test - for Ubuntu tests the build tree is under the source tree, for Fedora tests the build tree is in a directory in /tmp. These paths come from the build scripts in spread/build/fedora/task.yaml and spread/build/ubuntu/task.yaml.

spread -list will show a list of all the tests it’s possible to run. You can use ... as a wildcard within the test selector - for example, lxd:...:amd64 will run all the amd64 flavour tests specified for the LXD backend, lxd:ubuntu-16.04:... will run all the test flavours for the Ubuntu 16.04 system, and lxd:... will just run all the tests that are defined for the LXD platform.

How things change when spread is fixed in the Snap store

Once the required pull requests land and spread is updated in the Snap store, you’ll be able to run sudo snap install spread rather than downloading my prebuilt snap and installing with --dangerous. Everything else remains the same.

comments powered by Disqus