Easy Swift Linux testing

TL;DR - Test your Swift code is Linux compatible with one command.

> brew tap iainsmith/formulae
> brew install swift-docker
> swift docker test --swift 4.1

Quick Start

Make sure you have docker installed on your mac. You probably want to download the Docker Mac App. Alternatively you can install docker with homebrew.

Install swift-docker

via Homebrew

> brew tap iainsmith/casks
> brew install swift-docker

from source

> git clone 
> swift build -c release -Xswiftc -static-stdlib

# copy the binary to somewhere on your path.
> cp .build/release/swift-docker ~/bin

Testing a new Swift Package

# Create an empty swift Package
mkdir TestPackage && cd TestPackage
spm init --type library

# Run the tests
> swift test # Check your tests pass on MacOS
> swift docker test # Check your tests pass on Linux.
> swift docker test --image  ibmcom/swift-ubuntu:4.1 # Run your tests on a specific docker image
> swift docker write-dockerfile # Create Dockerfile
> swift docker cleanup # Remove old images

Improvements

If you’ve got suggestions

swift-docker is written in Swift. You can find the source on github.com/iainsmith/SwiftDocker