uploadReport.sh 2.7 KB

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