Skip to content

Commit ebebe95

Browse files
authored
Travis CI setup
1 parent 0c7b31f commit ebebe95

File tree

5 files changed

+72
-9
lines changed

5 files changed

+72
-9
lines changed

.travis.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# make sudo to enforce running on a real linux VM and not in a container on a macOS VM.
2+
sudo: required
3+
# do not use swift as language, since otherwise the build always runs on a macOS VM.
4+
language: c
5+
dist: trusty # Ubuntu 14.04 LTS
6+
osx_image: xcode9.3beta
7+
8+
matrix:
9+
include:
10+
- os: linux
11+
compiler: clang
12+
- os: linux
13+
compiler: gcc
14+
- os: osx
15+
compiler: clang
16+
17+
before_install:
18+
- uname -a
19+
- |
20+
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
21+
# update silently
22+
brew update >/dev/null
23+
brew upgrade swiftlint
24+
# check swift version
25+
swift --version
26+
fi
27+
- |
28+
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
29+
sudo apt-get update
30+
sudo apt-get install clang-3.6
31+
export SWIFT_VERSION=4.1
32+
# download swift
33+
SWIFT_ARCHIVE=swift-$SWIFT_VERSION-RELEASE-ubuntu14.04.tar.gz
34+
curl https://swift.org/builds/swift-$SWIFT_VERSION-release/ubuntu1404/swift-$SWIFT_VERSION-RELEASE/$SWIFT_ARCHIVE -s -o $SWIFT_ARCHIVE
35+
tar xf $SWIFT_ARCHIVE
36+
rm -f $SWIFT_ARCHIVE
37+
# setup env for swift
38+
export SWIFT_HOME=$(pwd)/swift-$SWIFT_VERSION-RELEASE-ubuntu14.04/usr/bin/
39+
export PATH=$SWIFT_HOME:$PATH
40+
# check swift version
41+
swift --version
42+
fi
43+
script:
44+
- swift build
45+
- swift test
46+
- |
47+
# lint on osx only (no need to do this on every platform)
48+
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
49+
swiftlint --reporter json > swiftlint.json
50+
cat swiftlint.json
51+
# check for warnings as well
52+
grep "Warning" swiftlint.json > /dev/null && echo "linting failed" && exit 1;
53+
echo "linting passed"
54+
fi

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# vincenty
22

3+
[![Swift Version](https://img.shields.io/badge/swift-4.1-blue.svg)](https://swift.org)
4+
![Platform](https://img.shields.io/badge/platform-osx--64|linux--64-lightgrey.svg)
5+
[![Build Travis-CI Status](https://travis-ci.org/dastrobu/vincenty.png?branch=master)](https://travis-ci.org/dastrobu/vincenty.png?branch=master)
6+
37
Solver for the inverse geodesic problem in Swift.
48

59
The inverse geodesic problem must be solved to compute the distance between two points on an oblate spheroid, or

Sources/vincenty/vincenty.swift

+7-4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ public enum ConvergenceError: Error {
1212
/// [WGS 84 ellipsoid](https://en.wikipedia.org/wiki/World_Geodetic_System) definition
1313
public let wgs84 = (a: 6378137.0, f: 1 / 298.257223563)
1414

15+
/// π (for convenience)
16+
private let pi = Double.pi
17+
1518
///
1619
/// Compute the distance between two points on an ellipsoid.
1720
/// The ellipsoid parameters default to the WGS-84 parameters.
@@ -38,10 +41,10 @@ public func distance(_ x: (lat: Double, lon: Double),
3841
assert(tol > 0, "tol '\(tol)' ≤ 0")
3942

4043
// validate lat and lon values
41-
assert(x.lat >= -Double.pi / 2 && x.lat <= Double.pi / 2, "x.lat '\(x.lat)' outside [-π/2, π]")
42-
assert(y.lat >= -Double.pi / 2 && y.lat <= Double.pi / 2, "y.lat '\(y.lat)' outside [-π/2, π]")
43-
assert(x.lon >= -Double.pi && x.lon <= Double.pi, "x.lon '\(y.lon)' outside [-π, π]")
44-
assert(y.lon >= -Double.pi && y.lon <= Double.pi, "y.lon '\(y.lon)' outside [-π, π]")
44+
assert(x.lat >= -pi / 2 && x.lat <= pi / 2, "x.lat '\(x.lat)' outside [-π/2, π]")
45+
assert(y.lat >= -pi / 2 && y.lat <= pi / 2, "y.lat '\(y.lat)' outside [-π/2, π]")
46+
assert(x.lon >= -pi && x.lon <= pi, "x.lon '\(y.lon)' outside [-π, π]")
47+
assert(y.lon >= -pi && y.lon <= pi, "y.lon '\(y.lon)' outside [-π, π]")
4548

4649
// shortcut for zero distance
4750
if x == y {

Tests/LinuxMain.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import XCTest
22

3-
import GeodesicsTests
3+
import vincentyTests
44

55
var tests = [XCTestCaseEntry]()
6-
tests += GeodesicsTests.allTests()
6+
tests += vincentyTests.allTests()
77
XCTMain(tests)

Tests/vincentyTests/vincentyTests.swift

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import XCTest
22
@testable import vincenty
33

44
// some constants
5-
65
private let zero = (lat: 0.0, lon: 0.0)
76
private let northPole = (lat: Double.pi / 2, lon: 0.0)
87
private let southPole = (lat: -Double.pi / 2, lon: 0.0)
@@ -81,9 +80,12 @@ final class VincentyTests: XCTestCase {
8180
XCTAssertEqual(try! distance(x, y), 111319.491, accuracy: delta)
8281
}
8382

83+
#if !os(macOS)
8484
static var allTests = [
85-
("testShortcutForEqualPoints", testShortcutForEqualPoints),
86-
("testPoles", testPoles),
8785
("testGrs80", testGrs80),
86+
("testPoles", testPoles),
87+
("testShortcutForEqualPoints", testShortcutForEqualPoints),
88+
("testVincentyDistance", testVincentyDistance),
8889
]
90+
#endif
8991
}

0 commit comments

Comments
 (0)