Skip to content

Commit

Permalink
Stylecopping in Travis (#1636)
Browse files Browse the repository at this point in the history
* Run Stylecop in Travis Build

* Explicitly Ignore StreamingAssets

* Report clean Stylecop

* Use build matrix
  • Loading branch information
koosemose authored and bjubes committed Nov 21, 2016
1 parent 83e4570 commit 7c61625
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 12 deletions.
13 changes: 11 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,24 @@
# Using objective-c since windows build images are not available
# The chmod-ing may be uneccesary
language: objective-c
osx_image: xcode61
osx_image: xcode6.4
rvm:
- 2.1.2
before_install:
- chmod +x ./Scripts/install.sh
- chmod +x ./Scripts/test.sh
- chmod +x ./Scripts/mono.sh
- chmod +x ./Scripts/install-stylecop.sh
- chmod +x ./Scripts/check-style.sh
- chmod +x ./Scripts/travis.sh
env:
- JOB=unit-test
- JOB=stylecop
install:
- ./Scripts/install.sh
- ./Scripts/mono.sh
- ./Scripts/install-stylecop.sh
script:
- ./Scripts/test.sh --travis
- ./Scripts/travis.sh
notifications:
email: false
14 changes: 14 additions & 0 deletions Scripts/check-style.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
echo "Stylecopping"
StylecopOutput=$(mono /opt/stylecop/StyleCopCmd.Console.exe -rd Assets/ -vt)
StyleCopErrorCode=$?

if [ "$StyleCopErrorCode" == "0" ]; then
echo '\nNo Stylecop violations were found.\n'
fi


if [ "$StyleCopErrorCode" != "0" ]; then
echo '\nThe following Stylecop violations were thrown:\n'
echo "$StylecopOutput\n"
exit 1
fi
3 changes: 3 additions & 0 deletions Scripts/install-stylecop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
wget -O scc.zip "https://github.com/enckse/StyleCopCmd/releases/download/v1.3.6/StyleCopCmd-1.3.6.zip"
sudo mkdir /opt/stylecop
sudo unzip scc.zip -d /opt/stylecop
1 change: 1 addition & 0 deletions Scripts/mono-version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12.1
4 changes: 4 additions & 0 deletions Scripts/mono.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
wget -O "mono-version.txt" "https://raw.githubusercontent.com/enckse/travis-mono-scripts/master/mono-version.txt"
VER=$(cat "mono-version.txt")
wget "http://download.mono-project.com/archive/$VER/macos-10-x86/MonoFramework-MDK-$VER.macos10.xamarin.x86.pkg"
sudo installer -pkg "MonoFramework-MDK-$VER.macos10.xamarin.x86.pkg" -target /
17 changes: 7 additions & 10 deletions Scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ if [ "$endTestsFold" = 0 ]; then
travecho 'travis_fold:end:tests'
fi


#TERRIBLE error check logic - Please fix ASAP
errorCount=$(grep "failures" EditorTestResults.xml | awk -F"\"" '{print $8}') #find line with 'failures' and returns characters between quotation mark 8 and 9

Expand All @@ -110,26 +111,23 @@ if [ "$errorCount" != "0" ]; then
printf '\nThe following unit tests failed:'
echo | grep 'success="False"' EditorTestResults.xml | grep 'test-case'

rm "$(pwd)"/EditorTestResults.xml
exit 1
exitStatus=1
fi

errorCount=$(grep "failures" EditorTestResults.xml | awk -F"\"" '{print $6}') #now for errors

if [ "$errorCount" != "0" ]; then
echo "$errorCount" ' unit tests threw errors!'

rm "$(pwd)"/EditorTestResults.xml
exit 1
exitStatus=1
fi

errorCount=$(grep "failures" EditorTestResults.xml | awk -F"\"" '{print $12}') #inconlusive tests

if [ "$errorCount" != "0" ]; then
echo "$errorCount" ' unit tests were inconlusive!'

rm "$(pwd)"/EditorTestResults.xml
exit 1
exitStatus=1
fi


Expand All @@ -138,9 +136,8 @@ errorCount=$(grep "failures" EditorTestResults.xml | awk -F"\"" '{print $18}') #
if [ "$errorCount" != "0" ]; then
echo "$errorCount" ' unit tests were invalid!'

rm "$(pwd)"/EditorTestResults.xml
exit 1
exitStatus=1
fi
#end of unit test checks. at this point the test have suceeded or exited with an error code.

#end of unit test checks. at this point the test have suceeded or set exitStatus to 1.
rm "$(pwd)"/EditorTestResults.xml
exit $exitStatus
13 changes: 13 additions & 0 deletions Scripts/travis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#! /bin/sh
# This script is responsible for running the script that matches
# the environment variable travis selects.

if [ "$JOB" == "unit-test" ]; then
./Scripts/test.sh --travis
exit $?
fi


if [ "$JOB" == "stylecop" ]; then
./Scripts/check-style.sh
fi
1 change: 1 addition & 0 deletions Settings.StyleCop
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<Value>\.g\.cs$</Value>
<Value>\.generated\.cs$</Value>
<Value>\.g\.i\.cs$</Value>
<Value>StreamingAssets[/\\].+\.cs$</Value>
<Value>TemporaryGeneratedFile_.*\.cs$</Value>
</CollectionProperty>
</ParserSettings>
Expand Down

0 comments on commit 7c61625

Please sign in to comment.