Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Travis CI configuration #4

Merged
merged 3 commits into from
Mar 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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