From 6ab58b7b1ab2e7048f3fb7bc28ec6e38210c528b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Brey=20Vilas?= Date: Fri, 3 Sep 2021 12:29:58 +0200 Subject: [PATCH 1/5] scripts: androidScreenshotTest: Fail on first error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Álvaro Brey Vilas --- scripts/androidScreenshotTest | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/androidScreenshotTest b/scripts/androidScreenshotTest index 97c6267893..f664ff1a28 100755 --- a/scripts/androidScreenshotTest +++ b/scripts/androidScreenshotTest @@ -1,4 +1,5 @@ #!/bin/bash +set -e if [ $# -lt 2 ]; then echo "1: record: true/false From 4121cd9e507826d4c3f38cff716ae7458183292f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Brey=20Vilas?= Date: Fri, 3 Sep 2021 12:35:38 +0200 Subject: [PATCH 2/5] androidScreenshotTest: Use full path to emulator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In some systems (like mine) emulator will fail if not called by full path Signed-off-by: Álvaro Brey Vilas --- scripts/androidScreenshotTest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/androidScreenshotTest b/scripts/androidScreenshotTest index f664ff1a28..5094740879 100755 --- a/scripts/androidScreenshotTest +++ b/scripts/androidScreenshotTest @@ -59,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 From 47689c938cf2876037d56b62611d14b947239c8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Brey=20Vilas?= Date: Fri, 3 Sep 2021 12:48:30 +0200 Subject: [PATCH 3/5] scripts:uploadReport: Fix github authorization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Álvaro Brey Vilas --- scripts/uploadReport.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/scripts/uploadReport.sh b/scripts/uploadReport.sh index 0d4b0e50c1..ee31d80355 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 @@ -71,7 +77,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. \" }" From f3f14bfcc43c5b9e62fc5349a08bc59a18d5c831 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Brey=20Vilas?= Date: Mon, 6 Sep 2021 11:29:03 +0200 Subject: [PATCH 4/5] scripts:uploadReport: Fix git token usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Álvaro Brey Vilas --- .drone.yml | 4 ++-- scripts/runAllScreenshotCombinations | 2 +- scripts/runCombinedTest.sh | 4 ++-- scripts/uploadReport.sh | 7 +++---- 4 files changed, 8 insertions(+), 9 deletions(-) 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/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 ee31d80355..f42f0f19fe 100755 --- a/scripts/uploadReport.sh +++ b/scripts/uploadReport.sh @@ -41,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 @@ -51,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 From 131373f066e077622a5c806ba6d10f56a45fcfd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Brey=20Vilas?= Date: Mon, 6 Sep 2021 12:07:41 +0200 Subject: [PATCH 5/5] scripts: Remove deleteOldComments.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Only used by screenShotTest.yml, but uploadReports.sh already has a function for the same purpose. Signed-off-by: Álvaro Brey Vilas --- .github/workflows/screenShotTest.yml | 2 -- scripts/deleteOldComments.sh | 28 ---------------------------- 2 files changed, 30 deletions(-) delete mode 100755 scripts/deleteOldComments.sh 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/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