Browse Source

#141: Added script to install swiftlint. Enabled on Travis CI

Andrea Bizzotto 8 years ago
parent
commit
66b966308d
2 changed files with 30 additions and 1 deletions
  1. 7 1
      .travis.yml
  2. 23 0
      scripts/install_swiftlint.sh

+ 7 - 1
.travis.yml

@@ -1,3 +1,9 @@
 language: objective-c
 osx_image: xcode8
-script: ./scripts/build.sh
+
+install:
+  - ./scripts/install_swiftlint.sh
+
+script:
+  - swiftlint
+  - ./scripts/build.sh

+ 23 - 0
scripts/install_swiftlint.sh

@@ -0,0 +1,23 @@
+#!/bin/bash
+
+# Installs the SwiftLint package.
+# Tries to get the precompiled .pkg file from Github, but if that
+# fails just recompiles from source.
+
+set -e
+
+SWIFTLINT_PKG_PATH="/tmp/SwiftLint.pkg"
+SWIFTLINT_PKG_URL="https://github.com/realm/SwiftLint/releases/download/0.16.1/SwiftLint.pkg"
+
+wget --output-document=$SWIFTLINT_PKG_PATH $SWIFTLINT_PKG_URL
+
+if [ -f $SWIFTLINT_PKG_PATH ]; then
+  echo "SwiftLint package exists! Installing it..."
+  sudo installer -pkg $SWIFTLINT_PKG_PATH -target /
+else
+  echo "SwiftLint package doesn't exist. Compiling from source..." &&
+  git clone https://github.com/realm/SwiftLint.git /tmp/SwiftLint &&
+  cd /tmp/SwiftLint &&
+  git submodule update --init --recursive &&
+  sudo make install
+fi