From 7a77f63e6dc77dbc01dad967333d821301f783f9 Mon Sep 17 00:00:00 2001 From: Elliot Chance Date: Thu, 9 Nov 2017 14:01:19 +1100 Subject: [PATCH] Add Github status to PR for c2go tests and warnings (#338) --- .travis.yml | 5 ++++- travis/test.sh | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 032918e9c..eaaf234bd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,10 @@ os: - osx env: - - SCRIPT=test CLANG=3.9 + global: + secure: "p/4P6/KQKnkUmTQPUkkuu/Q9n4KR9tno5i6gBf9yJ/SbBRg1YTM5G5QvvZUasOAOeb8sxQaoJqd+H6Jmnj3sgB/zBFrAId+S8IMckuUMPLGvt928MXA+R1DdRDr9arHGKodyaF6VUJkQU78IQusv71FDvV2bdesMJPNc27l3WbEJPEoPGpQMiM6pgZgYFEnpRHTgi3Fmp5FN9jR+evQpPOwvsAVfNuLH2kZ3prk7XDpP2Nx0SmdwVzSKiKFW8XyiM6aHmjWLOOIDbmIynD1Hl2iUTEhbzubIPgBmYt3AbgYL4WzmnnZEfKMFmVGjHmdNIiW1EndI4iLjCpqdTWqOLY7kge8DW+/eURb0WsIAJJsllc/D6P9l2SU1v9PJROdY2dLI5oO06PSvFgXgpyCz0IG1ARYw2JF9JxG1kkNtdcPindn3mlPTcfwHUh41y7mZEYBD22NMl9AyWE1Igqgx2TEYZf+TcyUpV2pLxY7QwcCrga77iCiSrzylKLvrgABaU/zgQXEUe2Oymv4LvgtiwMBJl6x+80yVEMdIMHb10IShThzEgcmMDd1rNDt8k48A3GUVaFi4xu4i3Zoiq2OGQLNOKmejWpNYYHP7iD6gTqRwV5h9t+iTobbxs1WkJfh5VMHKaLN1qQmEz3Nzr08zZ8rkAJ9X3Xf588HhZKVvVsQ=" + matrix: + - SCRIPT=test CLANG=3.9 matrix: include: diff --git a/travis/test.sh b/travis/test.sh index 5609d77b4..a439d373e 100755 --- a/travis/test.sh +++ b/travis/test.sh @@ -47,8 +47,11 @@ if [ $COVERAGE_FILES != 0 ]; then fi # Print stats -echo "Unit tests: " $(grep "=== RUN" $OUTFILE | wc -l) -echo "Integration tests: " $(grep "# Total tests" $OUTFILE | cut -c21-) +UNIT_TESTS=$(grep "=== RUN" $OUTFILE | wc -l | tr -d '[:space:]') +INT_TESTS=$(grep "# Total tests" $OUTFILE | cut -c21- | tr -d '[:space:]') + +echo "Unit tests: ${UNIT_TESTS}" +echo "Integration tests: ${INT_TESTS}" # These steps are from the README to verify it can be installed and run as # documented. @@ -94,3 +97,12 @@ echo "In file sqlite3.go : $SQLITE_WARNING_SQLITE3 warnings." SQLITE_WARNING_SHELL=`cat $SQLITE_TEMP_FOLDER/shell.go | grep "// Warning" | wc -l` echo "In file shell.go : $SQLITE_WARNING_SHELL warnings." + +# Update Github PR statuses. These two statuses will always pass but will show +# information about the number of tests run and how many warnings are generated +# in the SQLite3 transpile. +if [ "$TRAVIS_OS_NAME" == "osx" ]; then + curl -H "Authorization: token ${GITHUB_API_TOKEN}" -H "Content-Type: application/json" https://api.github.com/repos/elliotchance/c2go/statuses/${TRAVIS_COMMIT} -d "{\"state\": \"success\",\"target_url\": \"https://travis-ci.org/elliotchance/c2go/builds/${TRAVIS_JOB_ID}\", \"description\": \"$(($UNIT_TESTS + $INT_TESTS)) tests passed (${UNIT_TESTS} unit + ${INT_TESTS} integration)\", \"context\": \"c2go/tests\"}" + + curl -H "Authorization: token ${GITHUB_API_TOKEN}" -H "Content-Type: application/json" https://api.github.com/repos/elliotchance/c2go/statuses/${TRAVIS_COMMIT} -d "{\"state\": \"success\",\"target_url\": \"https://travis-ci.org/elliotchance/c2go/builds/${TRAVIS_JOB_ID}\", \"description\": \"$(($SQLITE_WARNING_SQLITE3 + $SQLITE_WARNING_SHELL)) warnings\", \"context\": \"c2go/sqlite3\"}" +fi