diff --git a/.drone.yml b/.drone.yml index 5ef12aad7a..56d97cd80f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -26,11 +26,11 @@ steps: - ./gradlew assembleGplayDebug - scripts/wait_for_emulator.sh - scripts/deleteOutdatedComments.sh "stable" "Unit" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN - - ./gradlew jacocoTestGplayDebugUnitTestReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "stable" "Unit" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN + - ./gradlew jacocoTestGplayDebugUnitTestReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "stable" "Unit" $DRONE_PULL_REQUEST $GIT_TOKEN - ./gradlew installGplayDebugAndroidTest - scripts/wait_for_server.sh "server" - scripts/deleteOutdatedComments.sh "stable" "IT" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN - - ./gradlew createGplayDebugCoverageReport -Pcoverage -Pandroid.testInstrumentationRunnerArguments.notAnnotation=com.owncloud.android.utils.ScreenshotTest || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "stable" "IT" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN + - ./gradlew createGplayDebugCoverageReport -Pcoverage -Pandroid.testInstrumentationRunnerArguments.notAnnotation=com.owncloud.android.utils.ScreenshotTest || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "stable" "IT" $DRONE_PULL_REQUEST $GIT_TOKEN - ./gradlew combinedTestReport - name: notify image: drillster/drone-email diff --git a/.github/workflows/screenShotTest.yml b/.github/workflows/screenShotTest.yml index 4bdb0e5ebb..9fbfea9f29 100644 --- a/.github/workflows/screenShotTest.yml +++ b/.github/workflows/screenShotTest.yml @@ -23,8 +23,6 @@ jobs: mkdir -p $HOME/.gradle echo "org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > $HOME/.gradle/gradle.properties ./gradlew assembleGplayDebug - - name: Delete old comments - run: scripts/deleteOldComments.sh "${{ matrix.color }}-${{ matrix.scheme }}" "Screenshot" ${{github.event.number}} ${{ secrets.GITHUB_TOKEN }} - name: run tests uses: reactivecircus/android-emulator-runner@v2 with: diff --git a/scripts/androidScreenshotTest b/scripts/androidScreenshotTest index 97c6267893..5094740879 100755 --- a/scripts/androidScreenshotTest +++ b/scripts/androidScreenshotTest @@ -1,4 +1,5 @@ #!/bin/bash +set -e if [ $# -lt 2 ]; then echo "1: record: true/false @@ -58,7 +59,7 @@ while read line ; do done < <(adb devices | cut -f1) if [ "$emulatorIsRunning" == false ] ; then - emulator -writable-system -avd uiComparison -no-snapshot -gpu swiftshader_indirect -no-audio -skin 500x833 & + "$(command -v emulator)" -writable-system -avd uiComparison -no-snapshot -gpu swiftshader_indirect -no-audio -skin 500x833 & fi if [ -e $5 ] ; then diff --git a/scripts/deleteOldComments.sh b/scripts/deleteOldComments.sh deleted file mode 100755 index 96d69cfed5..0000000000 --- a/scripts/deleteOldComments.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -#1: LOG_USERNAME -#2: LOG_PASSWORD -#3: DRONE_BUILD_NUMBER -#4: BRANCH (stable or master) -#5: TYPE (IT or Unit) -#6: DRONE_PULL_REQUEST -#7: GITHUB_TOKEN - -BRANCH=$1 -TYPE=$2 -PR=$3 -GITHUB_USER=$4 -GITHUB_PASSWORD=$5 -BRANCH_TYPE=$BRANCH-$TYPE - - # delete all old comments, matching this type -echo "Deleting old comments for $BRANCH_TYPE" -oldComments=$(curl 2>/dev/null --header "authorization: Bearer $GITHUB_TOKEN" -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"|") -count=$(echo $oldComments | grep true | wc -l) -echo "Found $count old comments" - -echo $oldComments | while read comment ; do -echo "Deleting comment: $comment" -curl 2>/dev/null --header "authorization: Bearer $GITHUB_TOKEN" -X DELETE https://api.github.com/repos/nextcloud/android/issues/comments/$comment -done - -exit 0 diff --git a/scripts/runAllScreenshotCombinations b/scripts/runAllScreenshotCombinations index 28e453506d..dc0fb58572 100755 --- a/scripts/runAllScreenshotCombinations +++ b/scripts/runAllScreenshotCombinations @@ -43,7 +43,7 @@ do && scripts/deleteOutdatedComments.sh "$1-$darkMode-$color" "Screenshot" "$4" \ "$GIT_USERNAME" "$GIT_TOKEN" \ || resultCode=1 && scripts/uploadReport.sh "$LOG_USERNAME" "$LOG_PASSWORD" "$4" \ - "$1-$darkMode-$color" "Screenshot" "$4" "$GIT_USERNAME" "$GIT_TOKEN" + "$1-$darkMode-$color" "Screenshot" "$4" "$GIT_TOKEN" fi done < scripts/screenshotCombinations diff --git a/scripts/runCombinedTest.sh b/scripts/runCombinedTest.sh index 76808cc45a..5b23eddb92 100755 --- a/scripts/runCombinedTest.sh +++ b/scripts/runCombinedTest.sh @@ -18,7 +18,7 @@ scripts/wait_for_emulator.sh stat=$? if [ ! $stat -eq 0 ]; then - bash scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "master" "Unit" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN + bash scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "master" "Unit" $DRONE_PULL_REQUEST $GIT_TOKEN fi ./gradlew installGplayDebugAndroidTest @@ -27,7 +27,7 @@ scripts/wait_for_server.sh "server" stat=$(( stat | $? )) if [ ! $stat -eq 0 ]; then - bash scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "master" "IT" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN + bash scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "master" "IT" $DRONE_PULL_REQUEST $GIT_TOKEN fi ./gradlew combinedTestReport diff --git a/scripts/uploadReport.sh b/scripts/uploadReport.sh index 0d4b0e50c1..f42f0f19fe 100755 --- a/scripts/uploadReport.sh +++ b/scripts/uploadReport.sh @@ -1,15 +1,21 @@ #!/usr/bin/env bash +curl_gh() { + curl \ + --header "authorization: Bearer $GITHUB_TOKEN" \ + "$@" +} + deleteOldComments() { # delete all old comments, matching this type echo "Deleting old comments for $BRANCH_TYPE" - oldComments=$(curl > /dev/null 2>&1 -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"|") + oldComments=$(curl_gh > /dev/null 2>&1 -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"|") count=$(echo $oldComments | grep true | wc -l) echo "Found $count old comments" echo $oldComments | while read comment ; do echo "Deleting comment: $comment" - curl > /dev/null 2>&1 -u $GITHUB_USER:$GITHUB_PASSWORD -X DELETE https://api.github.com/repos/nextcloud/android/issues/comments/$comment + curl_gh > /dev/null 2>&1 -X DELETE https://api.github.com/repos/nextcloud/android/issues/comments/$comment done } @@ -23,7 +29,7 @@ upload() { 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 \ + curl_gh -X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments \ -d "{ \"body\" : \"$BRANCH_TYPE test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/$REMOTE_FOLDER \" }" exit 1 @@ -35,8 +41,7 @@ upload() { #4: BRANCH (stable or master) #5: TYPE (IT or Unit) #6: DRONE_PULL_REQUEST -#7: GIT_USERNAME -#8: GIT_TOKEN +#7: GITHUB_TOKEN URL=https://nextcloud.kaminsky.me/remote.php/webdav/android-integrationTests ID=$3 @@ -45,8 +50,8 @@ PASS=$2 BRANCH=$4 TYPE=$5 PR=$6 -GITHUB_USER=$7 -GITHUB_PASSWORD=$8 +GITHUB_TOKEN="$7" + REMOTE_FOLDER=$ID-$TYPE-$BRANCH-$(date +%H-%M) BRANCH_TYPE=$BRANCH-$TYPE @@ -71,7 +76,7 @@ else deleteOldComments echo "$BRANCH_TYPE test failed, but no output was generated. Maybe a preliminary stage failed." - curl > /dev/null 2>&1 -u $GITHUB_USER:$GITHUB_PASSWORD \ + curl_gh > /dev/null 2>&1 \ -X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments \ -d "{ \"body\" : \"$BRANCH_TYPE test failed, but no output was generated. Maybe a preliminary stage failed. \" }"