uploadReport.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. curl -u $GITHUB_USER:$GITHUB_PASSWORD -X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments \
  8. -d "{ \"body\" : \"$TYPE test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/$REMOTE_FOLDER \" }"
  9. exit 1
  10. }
  11. #1: LOG_USERNAME
  12. #2: LOG_PASSWORD
  13. #3: DRONE_BUILD_NUMBER
  14. #4: TYPE (IT or Unit)
  15. #5: DRONE_PULL_REQUEST
  16. #6: GIT_USERNAME
  17. #7: GIT_TOKEN
  18. URL=https://nextcloud.kaminsky.me/remote.php/webdav/android-integrationTests
  19. ID=$3
  20. USER=$1
  21. PASS=$2
  22. BRANCH=$4
  23. TYPE=$5
  24. PR=$6
  25. GITHUB_USER=$7
  26. GITHUB_PASSWORD=$8
  27. REMOTE_FOLDER=$ID-$TYPE
  28. set -e
  29. if [ $TYPE = "IT" ]; then
  30. FOLDER=build/reports/androidTests/connected/flavors/GPLAY
  31. elif [ $TYPE = "Unit" ]; then
  32. FOLDER=build/reports/tests/testGplayDebugUnitTest
  33. else
  34. FOLDER=build/reports/shot/verification
  35. fi
  36. if [ -e $FOLDER ]; then
  37. upload $FOLDER
  38. else
  39. echo "$BRANCH-$TYPE test failed, but no output was generated. Maybe a preliminary stage failed."
  40. curl -u $GITHUB_USER:$GITHUB_PASSWORD \
  41. -X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments \
  42. -d "{ \"body\" : \"$BRANCH-$TYPE test failed, but no output was generated. Maybe a preliminary stage failed. \" }"
  43. if [ -e build/reports/androidTests/connected/flavors/GPLAY ] ; then
  44. TYPE="IT"
  45. upload "build/reports/androidTests/connected/flavors/GPLAY"
  46. fi
  47. if [ -e build/reports/tests/testGplayDebugUnitTest ] ; then
  48. TYPE="Unit"
  49. upload "build/reports/tests/testGplayDebugUnitTest"
  50. fi
  51. if [ -e build/reports/shot/verification ] ; then
  52. TYPE="Screenshot"
  53. upload "build/reports/shot/verification"
  54. fi
  55. fi