Skip to content
Closed
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
20 changes: 14 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
matrix:
include:
- os: osx
language: generic
# Xcode version implicitly defines the Swift version to be used on macOS.
language: objective-c
osx_image: xcode8.2

- os: osx
language: objective-c
osx_image: xcode8.3
- 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".
# e.g. "swift" or "myusername/myswift" or "swift:3.1".
# The image must have Swift installed so that the `swift`
# command is in the `$PATH`.
#
Expand All @@ -21,8 +22,15 @@ matrix:
# 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"
# image supports this, e.g. "swift:3.0.2" or "swift:latest".
- DOCKER_IMAGE="swift:3.0"
- os: linux
language: generic
sudo: required
services:
- docker
env:
- DOCKER_IMAGE="swift:3.1"

script:
- chmod ugo+x ./scripts/travis-build-script.sh
Expand Down
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM swift:3.0.2

WORKDIR /package

COPY Package.swift ./
RUN swift package fetch

COPY . ./
RUN swift build

CMD swift test
10 changes: 6 additions & 4 deletions scripts/travis-build-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@
# <https://travis-ci.org/>. Supports testing Swift Package Manager
# packages on macOS and Linux.

set -ue -o pipefail

echo "Running on OS: ${TRAVIS_OS_NAME}"

if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
# macOS
# 1. Test using Swift Package Manager
swift --version
# Replace with swift package clean when dropping Swift 3.0 support.
swift build --clean
swift build
swift test

# 2. Test using xcodebuild
set -o pipefail
xcodebuild test -scheme SortedArray-macOS | xcpretty
xcodebuild test -scheme SortedArray-iOS -destination "platform=iOS Simulator,name=iPhone 7,OS=10.1" | xcpretty
xcodebuild test -scheme SortedArray-tvOS -destination "platform=tvOS Simulator,name=Apple TV 1080p" | xcpretty
Expand All @@ -25,9 +27,9 @@ elif [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
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}
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"
docker run --volume "$(pwd):/package" "${DOCKER_IMAGE}" /bin/bash -c "cd /package; swift --version; swift build --clean; swift test"
fi