Skip to content

Commit

Permalink
Merge pull request #4 from ole/travis-ci
Browse files Browse the repository at this point in the history
Continuous integration setup with Travis CI
  • Loading branch information
ole authored Mar 18, 2017
2 parents e93a766 + 99007a8 commit fce7626
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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:
- chmod ugo+x ./scripts/travis-build-script.sh
- ./scripts/travis-build-script.sh
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
24 changes: 24 additions & 0 deletions scripts/travis-build-script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

# The build script used for continuous integration builds on Travis CI
# <https://travis-ci.org/>. 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

0 comments on commit fce7626

Please sign in to comment.