Test a test script for remote CI services locally

Posted: , Modified:   loci CI Python Go


You usually employ remote CI services such as Travis CI to automatically test your projects hosted in GitHub. Your tests should be passed in such CI services always because you have made sure your codebase passes the tests before pushing. However, .travis.yml, the configuration file of Travis, sometimes has bugs and your dependency list sometime loses any libraries.

If your codebase fails tests in remote CI services, you need to fix bugs and re-push, and your commit history gets messy. If you’re working with colleague’s repository, you should care about it more.

To evaluate those tests locally, I made Loci, which runs tests in a sandbox based on Docker. Loci currently supports Python and Go projects.


Loci uses Docker. If you don’t have it, install it first.

You can install Loci in several ways. If you’re familiar with Go, run

$ go get github.com/jkawamoto/loci

or if you’re a Homebrew user, run

$ brew tap jkawamoto/loci
$ brew install loci

Otherwise, you can get a compiled binary from GitHub.


If your current directory has .travis.yml, just run loci command. If you want to test another file, give the path after loci command like loci <path>. First time, Loci build container images which install dependent packages listed in .travis.yml, and it may take long time, but those images can be reusable.

If you have cache servers of APT repository and PyPI repository, give their addresses via --apt-proxy and --pypi-proxy flags. Those cache servers may reduce network traffic and building time.

Here is the whole command line options of Loci:

loci [global options] [script file]

  If script file isn't given, .travis.yml will be used.

   --name NAME, -n NAME  creating a container named NAME to run tests,
                         and that container will not be deleted.
   --tag TAG, -t TAG     creating an image named TAG.
   --base TAG, -b TAG    use image TAG as the base image.
                         (default: "ubuntu:latest")
   --verbose             verbose mode, which prints Dockerfile and
   --apt-proxy URL       URL for a proxy server of apt repository.
   --pypi-proxy URL      URL for a proxy server of pypi repository.
   --http-proxy URL      URL for a http proxy server. [$HTTP_PROXY]
   --https-proxy URL     URL for a https proxy server. [$HTTPS_PROXY]
   --no-proxy LIST       Comma separated URL LIST for which proxies won't
                         be used. [$NO_PROXY]
   --help, -h            show help
   --version, -v         print the version

Future work

Loci currently supports Python and Go projects. I’ll supports other languages and welcome any pull requests.