From aa7740e010efead486e5df0af4bc52898d109685 Mon Sep 17 00:00:00 2001 From: Ole Begemann Date: Sat, 18 Mar 2017 13:10:30 +0100 Subject: [PATCH 1/3] Add .travis.yml --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..430565b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +os: osx +language: objective-c +osx_image: xcode8.2 +script: + - swift build + - swift test From 10a148e75fc8ad2c7f43413b293da2aeb48a3320 Mon Sep 17 00:00:00 2001 From: Ole Begemann Date: Sat, 18 Mar 2017 13:17:33 +0100 Subject: [PATCH 2/3] Add Travis CI badge to readme --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 464505c..7305b47 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,10 @@ Written by Ole Begemann, February 2017. For more info, see my accompanying [blog article](https://oleb.net/blog/2017/02/sorted-array/). +## Status + +[![Build Status](https://travis-ci.org/ole/SortedArray.svg?branch=master)](https://travis-ci.org/ole/SortedArray) + ## Usage Clone the repository and add or copy `SortedArray.swift` to your project. It has no dependencies. From 99007a87e742ad1ed82e2f05d331c78e396b496d Mon Sep 17 00:00:00 2001 From: Ole Begemann Date: Sat, 18 Mar 2017 14:09:14 +0100 Subject: [PATCH 3/3] Joint Travis CI config for macOS and Linux --- .travis.yml | 33 ++++++++++++++++++++++++++++----- scripts/travis-build-script.sh | 24 ++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 scripts/travis-build-script.sh diff --git a/.travis.yml b/.travis.yml index 430565b..6186e58 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,29 @@ -os: osx -language: objective-c -osx_image: xcode8.2 +matrix: + include: + - os: osx + language: generic + # Xcode version implicitly defines the Swift version to be used on macOS. + osx_image: xcode8.2 + + - os: linux + language: generic + sudo: required + services: + - docker + env: + # The Docker image to use on Linux in Docker notation, + # e.g. "swift" or "myusername/myswift" or "swift:3.0.2". + # The image must have Swift installed so that the `swift` + # command is in the `$PATH`. + # + # I recommend Docker Hub's "official" (not maintained by Apple) + # Swift image at https://hub.docker.com/r/_/swift/. Its name + # is simply "swift". + # + # You can use tags to select a specific Swift version if the + # image supports it, e.g. "swift:3.0.2" or "swift:latest". + DOCKER_IMAGE="swift:3.0.2" + script: - - swift build - - swift test + - chmod ugo+x ./scripts/travis-build-script.sh + - ./scripts/travis-build-script.sh diff --git a/scripts/travis-build-script.sh b/scripts/travis-build-script.sh new file mode 100644 index 0000000..fda6007 --- /dev/null +++ b/scripts/travis-build-script.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# The build script used for continuous integration builds on Travis CI +# . Supports testing Swift Package Manager +# packages on macOS and Linux. + +echo "Running on OS: ${TRAVIS_OS_NAME}" + +if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then + # macOS + swift build --clean + swift build + swift test +elif [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then + # Linux + echo "Using Docker image: ${DOCKER_IMAGE}" + # Download the Docker container. This is not strictly necessary since + # docker run would automatically download a missing container. + docker pull ${DOCKER_IMAGE} + # Share the current directory (where Travis checked out the repository) + # with the Docker container. + # Then, in the container, cd into that directory and run the tests. + docker run --volume "$(pwd):/root/repo" ${DOCKER_IMAGE} /bin/bash -c "cd /root/repo; swift build --clean; swift build; swift test" +fi