uploadReport.sh 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. TYPE=$4
  23. PR=$5
  24. GITHUB_USER=$6
  25. GITHUB_PASSWORD=$7
  26. REMOTE_FOLDER=$ID-$TYPE
  27. set -e
  28. if [ $TYPE = "IT" ]; then
  29. FOLDER=build/reports/androidTests/connected/flavors/GPLAY
  30. elif [ $TYPE = "Unit" ]; then
  31. FOLDER=build/reports/tests/testGplayDebugUnitTest
  32. else
  33. FOLDER=build/reports/shot/verification
  34. fi
  35. if [ -e $FOLDER ]; then
  36. upload $FOLDER
  37. else
  38. echo "$TYPE test failed, but no output was generated. Maybe a preliminary stage failed."
  39. curl -u $GITHUB_USER:$GITHUB_PASSWORD \
  40. -X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments \
  41. -d "{ \"body\" : \"$TYPE test failed, but no output was generated. Maybe a preliminary stage failed. \" }"
  42. if [ -e build/reports/androidTests/connected/flavors/GPLAY ] ; then
  43. TYPE="IT"
  44. upload "build/reports/androidTests/connected/flavors/GPLAY"
  45. fi
  46. if [ -e build/reports/tests/testGplayDebugUnitTest ] ; then
  47. TYPE="Unit"
  48. upload "build/reports/tests/testGplayDebugUnitTest"
  49. fi
  50. if [ -e build/reports/shot/verification ] ; then
  51. TYPE="Screenshot"
  52. upload "build/reports/shot/verification"
  53. fi
  54. fi