uploadReport.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/usr/bin/env bash
  2. # SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
  3. # SPDX-FileCopyrightText: 2018-2022 Tobias Kaminsky <tobias@kaminsky.me>
  4. # SPDX-License-Identifier: AGPL-3.0-or-later
  5. upload() {
  6. scripts/deleteOldComments.sh "$BRANCH" "$TYPE" "$PR"
  7. cd $1
  8. find . -type d -exec curl > /dev/null 2>&1 -u $USER:$PASS -X MKCOL $URL/$REMOTE_FOLDER/$(echo {} | sed s#\./##) \;
  9. find . -type f -exec curl > /dev/null 2>&1 -u $USER:$PASS -X PUT $URL/$REMOTE_FOLDER/$(echo {} | sed s#\./##) --upload-file {} \;
  10. echo "Uploaded failing tests to https://www.kaminsky.me/nc-dev/android-integrationTests/$REMOTE_FOLDER"
  11. curl_gh -X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments \
  12. -d "{ \"body\" : \"$BRANCH_TYPE test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/$REMOTE_FOLDER \" }"
  13. exit 1
  14. }
  15. #1: LOG_USERNAME
  16. #2: LOG_PASSWORD
  17. #3: DRONE_BUILD_NUMBER
  18. #4: BRANCH (stable or master)
  19. #5: TYPE (IT or Unit)
  20. #6: DRONE_PULL_REQUEST
  21. URL=https://nextcloud.kaminsky.me/remote.php/webdav/android-integrationTests
  22. ID=$3
  23. USER=$1
  24. PASS=$2
  25. BRANCH=$4
  26. TYPE=$5
  27. PR=$6
  28. source scripts/lib.sh
  29. REMOTE_FOLDER=$ID-$TYPE-$BRANCH-$(date +%H-%M)
  30. BRANCH_TYPE=$BRANCH-$TYPE
  31. set -e
  32. if [ -z $USER ] || [ -z $PASS ]; then
  33. echo "USER or PASS is empty!"
  34. exit 1
  35. fi
  36. if [ $TYPE = "IT" ]; then
  37. FOLDER=app/build/reports/androidTests/connected/flavors/gplay
  38. elif [ $TYPE = "Unit" ]; then
  39. FOLDER=app/build/reports/tests/testGplayDebugUnitTest
  40. else
  41. FOLDER=app/build/reports/shot/gplay/debug/verification
  42. fi
  43. if [ -e $FOLDER ]; then
  44. upload $FOLDER
  45. else
  46. scripts/deleteOldComments.sh "$BRANCH" "$TYPE" "$PR"
  47. echo "$BRANCH_TYPE test failed, but no output was generated. Maybe a preliminary stage failed."
  48. curl_gh > /dev/null 2>&1 \
  49. -X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments \
  50. -d "{ \"body\" : \"$BRANCH_TYPE test failed, but no output was generated. Maybe a preliminary stage failed. \" }"
  51. if [ -e app/build/reports/androidTests/connected/flavors/gplay ] ; then
  52. TYPE="IT"
  53. BRANCH_TYPE=$BRANCH-$TYPE
  54. upload "app/build/reports/androidTests/connected/flavors/gplay"
  55. fi
  56. if [ -e app/build/reports/tests/testGplayDebugUnitTest ] ; then
  57. TYPE="Unit"
  58. BRANCH_TYPE=$BRANCH-$TYPE
  59. upload "app/build/reports/tests/testGplayDebugUnitTest"
  60. fi
  61. if [ -e app/build/reports/shot/gplay/debug/verification ] ; then
  62. TYPE="Screenshot"
  63. BRANCH_TYPE=$BRANCH-$TYPE
  64. upload "app/build/reports/shot/gplay/debug/verification"
  65. fi
  66. exit 1 # always fail
  67. fi