uploadReport.sh 2.7 KB

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