Skip to content

Commit fce7626

Browse files
authored
Merge pull request #4 from ole/travis-ci
Continuous integration setup with Travis CI
2 parents e93a766 + 99007a8 commit fce7626

3 files changed

Lines changed: 57 additions & 0 deletions

File tree

.travis.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
matrix:
2+
include:
3+
- os: osx
4+
language: generic
5+
# Xcode version implicitly defines the Swift version to be used on macOS.
6+
osx_image: xcode8.2
7+
8+
- os: linux
9+
language: generic
10+
sudo: required
11+
services:
12+
- docker
13+
env:
14+
# The Docker image to use on Linux in Docker notation,
15+
# e.g. "swift" or "myusername/myswift" or "swift:3.0.2".
16+
# The image must have Swift installed so that the `swift`
17+
# command is in the `$PATH`.
18+
#
19+
# I recommend Docker Hub's "official" (not maintained by Apple)
20+
# Swift image at https://hub.docker.com/r/_/swift/. Its name
21+
# is simply "swift".
22+
#
23+
# You can use tags to select a specific Swift version if the
24+
# image supports it, e.g. "swift:3.0.2" or "swift:latest".
25+
DOCKER_IMAGE="swift:3.0.2"
26+
27+
script:
28+
- chmod ugo+x ./scripts/travis-build-script.sh
29+
- ./scripts/travis-build-script.sh

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ Written by Ole Begemann, February 2017.
88

99
For more info, see my accompanying [blog article](https://oleb.net/blog/2017/02/sorted-array/).
1010

11+
## Status
12+
13+
[![Build Status](https://travis-ci.org/ole/SortedArray.svg?branch=master)](https://travis-ci.org/ole/SortedArray)
14+
1115
## Usage
1216

1317
Clone the repository and add or copy `SortedArray.swift` to your project. It has no dependencies.

scripts/travis-build-script.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
# The build script used for continuous integration builds on Travis CI
4+
# <https://travis-ci.org/>. Supports testing Swift Package Manager
5+
# packages on macOS and Linux.
6+
7+
echo "Running on OS: ${TRAVIS_OS_NAME}"
8+
9+
if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
10+
# macOS
11+
swift build --clean
12+
swift build
13+
swift test
14+
elif [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
15+
# Linux
16+
echo "Using Docker image: ${DOCKER_IMAGE}"
17+
# Download the Docker container. This is not strictly necessary since
18+
# docker run would automatically download a missing container.
19+
docker pull ${DOCKER_IMAGE}
20+
# Share the current directory (where Travis checked out the repository)
21+
# with the Docker container.
22+
# Then, in the container, cd into that directory and run the tests.
23+
docker run --volume "$(pwd):/root/repo" ${DOCKER_IMAGE} /bin/bash -c "cd /root/repo; swift build --clean; swift build; swift test"
24+
fi

0 commit comments

Comments
 (0)