2018-03-02 14:08:09 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2020-02-13 11:33:58 +03:00
|
|
|
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"
|
|
|
|
|
2020-06-17 10:56:12 +03:00
|
|
|
# delete all old comments, matching this type
|
|
|
|
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] test failed.*") | tostring)'| grep "true|true" | tr -d "\"" | cut -f1 -d"|")
|
|
|
|
|
|
|
|
echo $oldComments | while read comment ; do
|
|
|
|
curl 2>/dev/null -u $GITHUB_USER:$GITHUB_PASSWORD -X DELETE https://api.github.com/repos/nextcloud/android/issues/comments/$comment
|
|
|
|
done
|
|
|
|
|
2020-02-13 11:33:58 +03:00
|
|
|
curl -u $GITHUB_USER:$GITHUB_PASSWORD -X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments \
|
2020-06-17 10:56:12 +03:00
|
|
|
-d "{ \"body\" : \"$BRANCH_TYPE test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/$REMOTE_FOLDER \" }"
|
2020-02-13 11:33:58 +03:00
|
|
|
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2019-02-07 09:28:28 +03:00
|
|
|
#1: LOG_USERNAME
|
|
|
|
#2: LOG_PASSWORD
|
|
|
|
#3: DRONE_BUILD_NUMBER
|
|
|
|
#4: TYPE (IT or Unit)
|
|
|
|
#5: DRONE_PULL_REQUEST
|
|
|
|
#6: GIT_USERNAME
|
|
|
|
#7: GIT_TOKEN
|
|
|
|
|
2018-11-01 12:59:08 +03:00
|
|
|
URL=https://nextcloud.kaminsky.me/remote.php/webdav/android-integrationTests
|
2018-03-02 14:08:09 +03:00
|
|
|
ID=$3
|
|
|
|
USER=$1
|
|
|
|
PASS=$2
|
2020-06-10 07:56:17 +03:00
|
|
|
BRANCH=$4
|
|
|
|
TYPE=$5
|
|
|
|
PR=$6
|
|
|
|
GITHUB_USER=$7
|
|
|
|
GITHUB_PASSWORD=$8
|
2020-06-19 12:05:47 +03:00
|
|
|
REMOTE_FOLDER=$ID-$TYPE-$BRANCH
|
2020-06-17 10:56:12 +03:00
|
|
|
BRANCH_TYPE=$BRANCH-$TYPE
|
2018-03-02 14:08:09 +03:00
|
|
|
|
2019-06-06 00:54:07 +03:00
|
|
|
set -e
|
|
|
|
|
2018-03-02 14:08:09 +03:00
|
|
|
if [ $TYPE = "IT" ]; then
|
2020-02-05 13:35:02 +03:00
|
|
|
FOLDER=build/reports/androidTests/connected/flavors/GPLAY
|
2019-12-10 17:26:31 +03:00
|
|
|
elif [ $TYPE = "Unit" ]; then
|
2020-02-05 13:35:02 +03:00
|
|
|
FOLDER=build/reports/tests/testGplayDebugUnitTest
|
2019-12-10 17:26:31 +03:00
|
|
|
else
|
2020-02-13 11:33:58 +03:00
|
|
|
FOLDER=build/reports/shot/verification
|
2018-03-02 14:08:09 +03:00
|
|
|
fi
|
|
|
|
|
2020-02-13 11:33:58 +03:00
|
|
|
if [ -e $FOLDER ]; then
|
|
|
|
upload $FOLDER
|
|
|
|
else
|
2020-06-17 10:56:12 +03:00
|
|
|
echo "$BRANCH_TYPE test failed, but no output was generated. Maybe a preliminary stage failed."
|
2018-03-02 14:08:09 +03:00
|
|
|
|
2020-02-13 11:33:58 +03:00
|
|
|
curl -u $GITHUB_USER:$GITHUB_PASSWORD \
|
|
|
|
-X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments \
|
2020-06-17 10:56:12 +03:00
|
|
|
-d "{ \"body\" : \"$BRANCH_TYPE test failed, but no output was generated. Maybe a preliminary stage failed. \" }"
|
2019-02-07 09:28:28 +03:00
|
|
|
|
2020-02-13 11:33:58 +03:00
|
|
|
if [ -e build/reports/androidTests/connected/flavors/GPLAY ] ; then
|
|
|
|
TYPE="IT"
|
2020-06-17 10:56:12 +03:00
|
|
|
BRANCH_TYPE=$BRANCH-$TYPE
|
2020-02-13 11:33:58 +03:00
|
|
|
upload "build/reports/androidTests/connected/flavors/GPLAY"
|
|
|
|
fi
|
2020-02-05 13:35:02 +03:00
|
|
|
|
2020-02-13 11:33:58 +03:00
|
|
|
if [ -e build/reports/tests/testGplayDebugUnitTest ] ; then
|
|
|
|
TYPE="Unit"
|
2020-06-17 10:56:12 +03:00
|
|
|
BRANCH_TYPE=$BRANCH-$TYPE
|
2020-02-13 11:33:58 +03:00
|
|
|
upload "build/reports/tests/testGplayDebugUnitTest"
|
|
|
|
fi
|
2020-02-05 13:35:02 +03:00
|
|
|
|
2020-02-13 11:33:58 +03:00
|
|
|
if [ -e build/reports/shot/verification ] ; then
|
|
|
|
TYPE="Screenshot"
|
2020-06-17 10:56:12 +03:00
|
|
|
BRANCH_TYPE=$BRANCH-$TYPE
|
2020-02-13 11:33:58 +03:00
|
|
|
upload "build/reports/shot/verification"
|
|
|
|
fi
|
|
|
|
fi
|