Skip to content
This repository has been archived by the owner on Apr 12, 2021. It is now read-only.

깃허브 코멘트 테스트 스크립트 추가 #35

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ android:
before_install:
- chmod +x gradlew
- chmod +rx app
skip_cleanup: true
script:
- ./gradlew clean build ktlint
- export CI=true
- export CI_NAME=travis-ci
- ./gradlew jacocoTestReport coveralls
after_success:
- sh deploy.sh
36 changes: 36 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
export TRAVIS_REPO_SLUG='JSpiner/epub-viewer'
export TRAVIS_PULL_REQUEST=35

export REPORT_PATH="./app/build/reports/jacoco/jacocoTestDebugUnitTestReport/jacocoTestDebugUnitTestReport.xml"

reportContent=$(cat $REPORT_PATH)

missedCountList=$(echo $reportContent | grep -oP '(?<=missed=\")([^\"]*)')
coveredCountList=$(echo $reportContent | grep -oP '(?<=covered=\")([^\"]*)')
missedCountSum=0
coveredCountSum=0

for i in ${#missedCountList[@]}
do
missedCountSum=$((missedCountSum + ${missedCountList[i]}))
done

for i in ${#coveredCountList[@]}
do
coveredCountSum=$((coveredCountSum + ${coveredCountList[i]}))
done
echo $coveredCountSum
echo $missedCountSum

coverage=$(echo print\($coveredCountSum / ($missedCountSum + $coveredCountSum) * 100\) | python)
echo $coverage
echo "done"

curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST \
-d "{\"body\": \"\
## Pull Request Test Coverage Report for [PR ${TRAVIS_PULL_REQUEST}](https://github.com/{TRAVIS_REPO_SLUG}/{TRAVIS_PULL_REQUEST})\n \
| Totals | ![status](https://img.shields.io/badge/Coverage-${coverage}%20-brightgreen.svg) | \
| :-- | --: | \
| Covered Lines: | ${coveredCountSum} | \
| Missed Lines: | ${missedCountSum} |" \
"https://api.github.com/repos/${TRAVIS_REPO_SLUG}/issues/${TRAVIS_PULL_REQUEST}/comments"