Browse Source

upload preliminary step

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
tobiasKaminsky 5 years ago
parent
commit
5cc0360855
1 changed files with 36 additions and 16 deletions
  1. 36 16
      scripts/uploadReport.sh

+ 36 - 16
scripts/uploadReport.sh

@@ -1,5 +1,19 @@
 #!/usr/bin/env bash
 
+upload() {
+    cd $1
+
+    find . -type d -exec curl -u $USER:$PASS -X MKCOL $URL/$REMOTE_FOLDER/$(echo {} | sed s#\./##) \;
+    find . -type f -exec curl -u $USER:$PASS -X PUT $URL/$REMOTE_FOLDER/$(echo {} | sed s#\./##) --upload-file {} \;
+
+    echo "Uploaded failing tests to https://www.kaminsky.me/nc-dev/android-integrationTests/$REMOTE_FOLDER"
+
+    curl -u $GITHUB_USER:$GITHUB_PASSWORD -X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments \
+    -d "{ \"body\" : \"$TYPE test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/$REMOTE_FOLDER \" }"
+
+    exit 1
+}
+
 #1: LOG_USERNAME
 #2: LOG_PASSWORD
 #3: DRONE_BUILD_NUMBER
@@ -13,6 +27,9 @@ ID=$3
 USER=$1
 PASS=$2
 TYPE=$4
+PR=$5
+GITHUB_USER=$6
+GITHUB_PASSWORD=$7
 REMOTE_FOLDER=$ID-$TYPE
 
 set -e
@@ -22,27 +39,30 @@ if [ $TYPE = "IT" ]; then
 elif [ $TYPE = "Unit" ]; then
     FOLDER=build/reports/tests/testGplayDebugUnitTest
 else
-    FOLDER=build/reports/shot/verification/
+    FOLDER=build/reports/shot/verification
 fi
 
-if [ ! -e $FOLDER ]; then
+if [ -e $FOLDER ]; then
+    upload $FOLDER
+else
     echo "$TYPE test failed, but no output was generated. Maybe a preliminary stage failed."
 
-    curl -u $6:$7 \
-    -X POST https://api.github.com/repos/nextcloud/android/issues/$5/comments \
+    curl -u $GITHUB_USER:$GITHUB_PASSWORD \
+    -X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments \
     -d "{ \"body\" : \"$TYPE test failed, but no output was generated. Maybe a preliminary stage failed. \" }"
 
-    exit 1
-fi
-
-cd $FOLDER
+    if [ -e build/reports/androidTests/connected/flavors/GPLAY ] ; then
+        TYPE="IT"
+        upload "build/reports/androidTests/connected/flavors/GPLAY"
+    fi
 
-find . -type d -exec curl -u $USER:$PASS -X MKCOL $URL/$REMOTE_FOLDER/$(echo {} | sed s#\./##) \;
-find . -type f -exec curl -u $USER:$PASS -X PUT $URL/$REMOTE_FOLDER/$(echo {} | sed s#\./##) --upload-file {} \;
+    if [ -e build/reports/tests/testGplayDebugUnitTest ] ; then
+        TYPE="Unit"
+        upload "build/reports/tests/testGplayDebugUnitTest"
+    fi
 
-echo "Uploaded failing tests to https://www.kaminsky.me/nc-dev/android-integrationTests/$REMOTE_FOLDER"
-
-curl -u $6:$7 -X POST https://api.github.com/repos/nextcloud/android/issues/$5/comments \
--d "{ \"body\" : \"$TYPE test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/$REMOTE_FOLDER \" }"
-
-exit 1
+    if [ -e build/reports/shot/verification ] ; then
+        TYPE="Screenshot"
+        upload "build/reports/shot/verification"
+    fi
+fi