uploadReport.sh 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/usr/bin/env bash
  2. upload() {
  3. cd $1
  4. find . -type d -exec curl -u $USER:$PASS -X MKCOL $URL/$REMOTE_FOLDER/$(echo {} | sed s#\./##) \;
  5. find . -type f -exec curl -u $USER:$PASS -X PUT $URL/$REMOTE_FOLDER/$(echo {} | sed s#\./##) --upload-file {} \;
  6. echo "Uploaded failing tests to https://www.kaminsky.me/nc-dev/android-integrationTests/$REMOTE_FOLDER"
  7. # delete all old comments, matching this type
  8. oldComments=$(curl 2>/dev/null -u $GITHUB_USER:$GITHUB_PASSWORD -X GET https://api.github.com/repos/nextcloud/android/issues/$PR/comments | jq --arg type $BRANCH_TYPE '.[] | (.id |tostring) + "|" + (.user.login | test("nextcloud-android-bot") | tostring) + "|" + (.body | test("[$TYPE] test failed.*") | tostring)'| grep "true|true" | tr -d "\"" | cut -f1 -d"|")
  9. echo $oldComments | while read comment ; do
  10. curl 2>/dev/null -u $GITHUB_USER:$GITHUB_PASSWORD -X DELETE https://api.github.com/repos/nextcloud/android/issues/comments/$comment
  11. done
  12. curl -u $GITHUB_USER:$GITHUB_PASSWORD -X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments \
  13. -d "{ \"body\" : \"$BRANCH_TYPE test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/$REMOTE_FOLDER \" }"
  14. exit 1
  15. }
  16. #1: LOG_USERNAME
  17. #2: LOG_PASSWORD
  18. #3: DRONE_BUILD_NUMBER
  19. #4: TYPE (IT or Unit)
  20. #5: DRONE_PULL_REQUEST
  21. #6: GIT_USERNAME
  22. #7: GIT_TOKEN
  23. URL=https://nextcloud.kaminsky.me/remote.php/webdav/android-integrationTests
  24. ID=$3
  25. USER=$1
  26. PASS=$2
  27. BRANCH=$4
  28. TYPE=$5
  29. PR=$6
  30. GITHUB_USER=$7
  31. GITHUB_PASSWORD=$8
  32. REMOTE_FOLDER=$ID-$TYPE-$BRANCH
  33. BRANCH_TYPE=$BRANCH-$TYPE
  34. set -e
  35. if [ $TYPE = "IT" ]; then
  36. FOLDER=build/reports/androidTests/connected/flavors/GPLAY
  37. elif [ $TYPE = "Unit" ]; then
  38. FOLDER=build/reports/tests/testGplayDebugUnitTest
  39. else
  40. FOLDER=build/reports/shot/verification
  41. fi
  42. if [ -e $FOLDER ]; then
  43. upload $FOLDER
  44. else
  45. echo "$BRANCH_TYPE test failed, but no output was generated. Maybe a preliminary stage failed."
  46. curl -u $GITHUB_USER:$GITHUB_PASSWORD \
  47. -X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments \
  48. -d "{ \"body\" : \"$BRANCH_TYPE test failed, but no output was generated. Maybe a preliminary stage failed. \" }"
  49. if [ -e build/reports/androidTests/connected/flavors/GPLAY ] ; then
  50. TYPE="IT"
  51. BRANCH_TYPE=$BRANCH-$TYPE
  52. upload "build/reports/androidTests/connected/flavors/GPLAY"
  53. fi
  54. if [ -e build/reports/tests/testGplayDebugUnitTest ] ; then
  55. TYPE="Unit"
  56. BRANCH_TYPE=$BRANCH-$TYPE
  57. upload "build/reports/tests/testGplayDebugUnitTest"
  58. fi
  59. if [ -e build/reports/shot/verification ] ; then
  60. TYPE="Screenshot"
  61. BRANCH_TYPE=$BRANCH-$TYPE
  62. upload "build/reports/shot/verification"
  63. fi
  64. fi