From 30b59b3432344ce6ba2ded960194aa88bd01e030 Mon Sep 17 00:00:00 2001 From: Kenny Root Date: Thu, 20 Aug 2015 16:02:27 -0700 Subject: travis: make sure we do not increase lint issues --- .travis.yml | 8 +++++++- scripts/check-lint-count.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100755 scripts/check-lint-count.sh diff --git a/.travis.yml b/.travis.yml index d7b9232..540cff3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ cache: - $HOME/.gradle/caches/ - $HOME/.gradle/wrapper/dists/ - $HOME/.cache/ndk + - $HOME/.cache/lint before_cache: - find $HOME/.gradle -name "*.lock" -exec rm {} \; - rm -rf $HOME/.gradle/caches/[1-9]* @@ -24,6 +25,7 @@ addons: - ia32-libs-multiarch - libgd2-xpm - p7zip-full + - libxml2-utils # ./scripts/check-lint-count.sh coverity_scan: project: name: "connectbot/connectbot" @@ -39,6 +41,8 @@ before_script: - curl https://dl.google.com/android/ndk/android-ndk-${NDK_VERSION}-linux-x86_64.bin -z $HOME/.cache/ndk/ndk-${NDK_VERSION}.bin -o $HOME/.cache/ndk/ndk-${NDK_VERSION}.bin - 7z x -y $HOME/.cache/ndk/ndk-${NDK_VERSION}.bin | grep -v 'ing ' - echo "ndk.dir=`pwd`/android-ndk-${NDK_VERSION}" >> local.properties + # For the lint checking mechanism + - mkdir -p $HOME/.cache/lint android: components: @@ -49,6 +53,8 @@ android: license: - '.+' -script: ./gradlew build check jacocoTestDebugReport +script: + - ./gradlew build check jacocoTestDebugReport + - ./scripts/check-lint-count.sh app/build/outputs/lint-results.xml $HOME/.cache/lint/issue-count.txt $HOME/.cache/lint/issue-count.txt after_success: ./gradlew coveralls diff --git a/scripts/check-lint-count.sh b/scripts/check-lint-count.sh new file mode 100755 index 0000000..4848e62 --- /dev/null +++ b/scripts/check-lint-count.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +# +# Checks the number of lint issues against historical values. Used in +# Travis CI builds to fail when the number increases by exploiting the +# caching mechanism. + +# This is to prime the system: when I submitted this change, this is the +# number of lint warnings that existed. +DEFAULT_NUMBER=207 + +if [[ $# != 3 || ! -f $1 ]]; then \ + echo "Usage: $0 " + exit 1 +elif [[ ! -d $(dirname $3) ]]; then \ + echo "Error: directory $(dirname $3) does not exist." + exit 1 +fi + +lint_file="$1" +historical_file="$2" +success_file="$3" + +xmllint="$(which xmllint)" + +if [[ ! -x $xmllint ]]; then \ + echo "Error: cannot find xmllint" + exit 1 +fi + +if [[ -f $historical_file ]]; then \ + historical_count="$(cat $historical_file)" +else \ + historical_count=$DEFAULT_NUMBER +fi + +new_count="$($xmllint --xpath 'count(//issue)' "$lint_file")" + +if [[ $new_count > $historical_count ]]; then \ + echo "FAILURE: lint issues increased from $historical_count to $new_count" + exit 2 +fi + +if [[ $TRAVIS_PULL_REQUEST == false ]]; then \ + # Okay, we either stayed the same or reduced our number. + # Write it out so we can check it next build! + echo $new_count > $success_file +fi -- cgit v1.2.3