Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/android.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÁlvaro Brey <alvaro.brey@nextcloud.com>2022-05-31 11:07:03 +0300
committerGitHub <noreply@github.com>2022-05-31 11:07:03 +0300
commitf54d234626bb99fa115c5df9effd8b3c9db980b4 (patch)
treee856630065b4b712add53c8b676a5fe1fe292ba6 /scripts
parentd51a9426d49eaba14ccc085198e4b0ac042d39f5 (diff)
Merge pull request #10279 from nextcloud/chore/analysis-github-token
workflows/analysis: Use GITHUB_TOKEN instead of GIT_TOKEN, and some cleanup
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/analysis/analysis-wrapper.sh53
-rwxr-xr-xscripts/analysis/getBranchBase.sh8
-rw-r--r--scripts/analysis/lint-up.rb21
-rwxr-xr-xscripts/checkIfRunDrone.sh8
-rwxr-xr-xscripts/deleteOldComments.sh8
-rw-r--r--scripts/lib.sh48
-rwxr-xr-xscripts/runAllScreenshotCombinations4
-rwxr-xr-xscripts/runCombinedTest.sh14
-rwxr-xr-xscripts/uploadArtifact.sh10
-rwxr-xr-xscripts/uploadReport.sh25
10 files changed, 112 insertions, 87 deletions
diff --git a/scripts/analysis/analysis-wrapper.sh b/scripts/analysis/analysis-wrapper.sh
index 6a071230e9..40d5ddf974 100755
--- a/scripts/analysis/analysis-wrapper.sh
+++ b/scripts/analysis/analysis-wrapper.sh
@@ -1,17 +1,16 @@
#!/usr/bin/env bash
-#1: GIT_USERNAME
-#2: GIT_TOKEN
-#3: BRANCH
-#4: LOG_USERNAME
-#5: LOG_PASSWORD
-#6: DRONE_BUILD_NUMBER
-#7: PULL_REQUEST_NUMBER
+BRANCH=$1
+LOG_USERNAME=$2
+LOG_PASSWORD=$3
+BUILD_NUMBER=$4
+PR_NUMBER=$5
+
stableBranch="master"
repository="android"
-ruby scripts/analysis/lint-up.rb $1 $2 $3
+ruby scripts/analysis/lint-up.rb
lintValue=$?
curl "https://www.kaminsky.me/nc-dev/$repository-findbugs/$stableBranch.xml" -o "/tmp/$stableBranch.xml"
@@ -23,37 +22,39 @@ spotbugsValue=$?
# 1: count was increased
# 2: count stayed the same
-echo "Branch: $3"
+source scripts/lib.sh
+
+echo "Branch: $BRANCH"
-if [ $3 = $stableBranch ]; then
+if [ "$BRANCH" = $stableBranch ]; then
echo "New spotbugs result for $stableBranch at: https://www.kaminsky.me/nc-dev/$repository-findbugs/$stableBranch.html"
- curl -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/$repository-findbugs/$stableBranch.html --upload-file app/build/reports/spotbugs/spotbugs.html
- curl 2>/dev/null -u "$4:$5" -X PUT "https://nextcloud.kaminsky.me/remote.php/webdav/$repository-findbugs/$stableBranch.xml" --upload-file app/build/reports/spotbugs/gplayDebug.xml
+ curl -u "${LOG_USERNAME}:${LOG_PASSWORD}" -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/$repository-findbugs/$stableBranch.html --upload-file app/build/reports/spotbugs/spotbugs.html
+ curl 2>/dev/null -u "${LOG_USERNAME}:${LOG_PASSWORD}" -X PUT "https://nextcloud.kaminsky.me/remote.php/webdav/$repository-findbugs/$stableBranch.xml" --upload-file app/build/reports/spotbugs/gplayDebug.xml
if [ $lintValue -ne 1 ]; then
echo "New lint result for $stableBranch at: https://www.kaminsky.me/nc-dev/$repository-lint/$stableBranch.html"
- curl -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/$repository-lint/$stableBranch.html --upload-file app/build/reports/lint/lint.html
+ curl -u "${LOG_USERNAME}:${LOG_PASSWORD}" -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/$repository-lint/$stableBranch.html --upload-file app/build/reports/lint/lint.html
exit 0
fi
else
- if [ -e $6 ]; then
+ if [ -e "${BUILD_NUMBER}" ]; then
6=$stableBranch"-"$(date +%F)
fi
- echo "New lint results at https://www.kaminsky.me/nc-dev/$repository-lint/$6.html"
- curl 2>/dev/null -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/$repository-lint/$6.html --upload-file app/build/reports/lint/lint.html
+ echo "New lint results at https://www.kaminsky.me/nc-dev/$repository-lint/${BUILD_NUMBER}.html"
+ curl 2>/dev/null -u "${LOG_USERNAME}:${LOG_PASSWORD}" -X PUT "https://nextcloud.kaminsky.me/remote.php/webdav/$repository-lint/${BUILD_NUMBER}.html" --upload-file app/build/reports/lint/lint.html
- echo "New spotbugs results at https://www.kaminsky.me/nc-dev/$repository-findbugs/$6.html"
- curl 2>/dev/null -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/$repository-findbugs/$6.html --upload-file app/build/reports/spotbugs/spotbugs.html
+ echo "New spotbugs results at https://www.kaminsky.me/nc-dev/$repository-findbugs/${BUILD_NUMBER}.html"
+ curl 2>/dev/null -u "${LOG_USERNAME}:${LOG_PASSWORD}" -X PUT "https://nextcloud.kaminsky.me/remote.php/webdav/$repository-findbugs/${BUILD_NUMBER}.html" --upload-file app/build/reports/spotbugs/spotbugs.html
# delete all old comments, starting with Codacy
- oldComments=$(curl 2>/dev/null -u $1:$2 -X GET https://api.github.com/repos/nextcloud/android/issues/$7/comments | jq '.[] | (.id |tostring) + "|" + (.user.login | test("nextcloud-android-bot") | tostring) + "|" + (.body | test("<h1>Codacy.*") | tostring)' | grep "true|true" | tr -d "\"" | cut -f1 -d"|")
+ oldComments=$(curl_gh -X GET "https://api.github.com/repos/nextcloud/$repository/issues/${PR_NUMBER}/comments" | jq '.[] | select((.user.login | contains("github-actions")) and (.body | test("<h1>Codacy.*"))) | .id')
- echo $oldComments | while read comment ; do
- curl 2>/dev/null -u $1:$2 -X DELETE https://api.github.com/repos/nextcloud/android/issues/comments/$comment
+ echo "$oldComments" | while read -r comment ; do
+ curl_gh -X DELETE "https://api.github.com/repos/nextcloud/$repository/issues/comments/$comment"
done
# check library, only if base branch is master
- baseBranch=$(scripts/analysis/getBranchBase.sh $1 $2 $7 | tr -d "\"")
+ baseBranch=$(scripts/analysis/getBranchBase.sh "${PR_NUMBER}" | tr -d "\"")
if [ $baseBranch = "master" -a $(grep "androidLibraryVersion = \"master-SNAPSHOT\"" build.gradle -c) -ne 1 ]; then
checkLibraryMessage="<h1>Android-library is not set to master branch in build.gradle</h1>"
checkLibrary=1
@@ -88,7 +89,7 @@ else
lintWarningNew=0
fi
- lintResultOld=$(curl 2>/dev/null https://raw.githubusercontent.com/nextcloud/android/$stableBranch/scripts/analysis/lint-results.txt)
+ lintResultOld=$(curl 2>/dev/null "https://raw.githubusercontent.com/nextcloud/$repository/$stableBranch/scripts/analysis/lint-results.txt")
lintErrorOld=$(echo $lintResultOld | grep "[0-9]* error" -o | cut -f1 -d" ")
if ( [ -z $lintErrorOld ] ); then
lintErrorOld=0
@@ -106,9 +107,9 @@ else
codacyResult=""
fi
- lintResult="<h1>Lint</h1><table width='500' cellpadding='5' cellspacing='2'><tr class='tablerow0'><td>Type</td><td><a href='https://www.kaminsky.me/nc-dev/"$repository"-lint/"$stableBranch".html'>$stableBranch</a></td><td><a href='https://www.kaminsky.me/nc-dev/"$repository"-lint/"$6".html'>PR</a></td></tr><tr class='tablerow1'><td>Warnings</td><td>"$lintWarningOld"</td><td>"$lintWarningNew"</td></tr><tr class='tablerow0'><td>Errors</td><td>"$lintErrorOld"</td><td>"$lintErrorNew"</td></tr></table>"
+ lintResult="<h1>Lint</h1><table width='500' cellpadding='5' cellspacing='2'><tr class='tablerow0'><td>Type</td><td><a href='https://www.kaminsky.me/nc-dev/$repository-lint/$stableBranch.html'>$stableBranch</a></td><td><a href='https://www.kaminsky.me/nc-dev/$repository-lint/${BUILD_NUMBER}.html'>PR</a></td></tr><tr class='tablerow1'><td>Warnings</td><td>$lintWarningOld</td><td>$lintWarningNew</td></tr><tr class='tablerow0'><td>Errors</td><td>$lintErrorOld</td><td>$lintErrorNew</td></tr></table>"
- spotbugsResult="<h1>SpotBugs</h1>$(scripts/analysis/spotbugsComparison.py "/tmp/$stableBranch.xml" app/build/reports/spotbugs/gplayDebug.xml --link-new "https://www.kaminsky.me/nc-dev/$repository-findbugs/$6.html" --link-base "https://www.kaminsky.me/nc-dev/$repository-findbugs/$stableBranch.html")"
+ spotbugsResult="<h1>SpotBugs</h1>$(scripts/analysis/spotbugsComparison.py "/tmp/$stableBranch.xml" app/build/reports/spotbugs/gplayDebug.xml --link-new "https://www.kaminsky.me/nc-dev/$repository-findbugs/${BUILD_NUMBER}.html" --link-base "https://www.kaminsky.me/nc-dev/$repository-findbugs/$stableBranch.html")"
if ( [ $lintValue -eq 1 ] ) ; then
lintMessage="<h1>Lint increased!</h1>"
@@ -131,7 +132,7 @@ else
fi
payload="{ \"body\" : \"$codacyResult $lintResult $spotbugsResult $checkLibraryMessage $lintMessage $spotbugsMessage $gplayLimitation $notNull\" }"
- curl -u "$1:$2" -X POST "https://api.github.com/repos/nextcloud/android/issues/$7/comments" -d "$payload"
+ curl_gh -X POST "https://api.github.com/repos/nextcloud/$repository/issues/${PR_NUMBER}/comments" -d "$payload"
if [ ! -z "$gplayLimitation" ]; then
exit 1
diff --git a/scripts/analysis/getBranchBase.sh b/scripts/analysis/getBranchBase.sh
index 9838cd7680..42acd1f10f 100755
--- a/scripts/analysis/getBranchBase.sh
+++ b/scripts/analysis/getBranchBase.sh
@@ -1,9 +1,11 @@
#!/bin/bash
-# $1: username, $2: password/token, $3: pull request number
+PR_NUMBER=$1
-if [ -z $3 ] ; then
+source scripts/lib.sh
+
+if [ -z "${PR_NUMBER}" ] ; then
echo "master";
else
- curl 2>/dev/null -u $1:$2 https://api.github.com/repos/nextcloud/android/pulls/$3 | jq .base.ref
+ curl_gh "https://api.github.com/repos/nextcloud/android/pulls/${PR_NUMBER}" | jq .base.ref
fi
diff --git a/scripts/analysis/lint-up.rb b/scripts/analysis/lint-up.rb
index 525273c175..c9d4864133 100644
--- a/scripts/analysis/lint-up.rb
+++ b/scripts/analysis/lint-up.rb
@@ -1,14 +1,14 @@
## Script from https://github.com/tir38/android-lint-entropy-reducer at 07.05.2017
# adapts to drone, use git username / token as parameter
+# TODO cleanup this script, it has a lot of unused stuff
+
+
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
puts "=================== starting Android Lint Entropy Reducer ===================="
-# get args
-git_user, git_token, git_branch = ARGV
-
# ======================== SETUP ============================
# User name for git commits made by this script.
@@ -169,25 +169,18 @@ end
# write new results to file (will overwrite existing, or create new)
File.write(previous_lint_report, "DO NOT TOUCH; GENERATED BY DRONE\n" + error_warning_string)
-# push changes to github (if this script is run locally, we don't want to overwrite git username and email, so save temporarily)
-previous_git_username, _ = Open3.capture2('git config user.name')
-previous_git_username = previous_git_username.strip
-
-previous_git_email, _ = Open3.capture3('git config user.email')
-previous_git_email = previous_git_email.strip
-
# update git user name and email for this script
-system ("git config --local user.name '" + git_user + "'")
-system ("git config --local user.email 'android@nextcloud.com'")
+system ("git config --local user.name 'github-actions'")
+system ("git config --local user.email 'github-actions@github.com'")
# add previous Lint result file to git
system ('git add ' + PREVIOUS_LINT_RESULTS_FILE)
# commit changes
-system({"GIT_COMMITTER_NAME" => git_user, "GIT_COMMITTER_EMAIL" => "android@nextcloud.com", "GIT_AUTHOR_EMAIL" => "android@nextcloud.com"}, 'git commit -sm "Analysis: update lint results to reflect reduced error/warning count"')
+system('git commit -sm "Analysis: update lint results to reflect reduced error/warning count"')
# push to origin
-system ('git push origin HEAD:' + git_branch)
+system ('git push')
puts "SUCCESS: count was reduced"
exit 0 # success
diff --git a/scripts/checkIfRunDrone.sh b/scripts/checkIfRunDrone.sh
index fab5ab7361..fadc475537 100755
--- a/scripts/checkIfRunDrone.sh
+++ b/scripts/checkIfRunDrone.sh
@@ -1,12 +1,14 @@
#!/bin/sh -e
-if [ -z $3 ] ; then
+PR_NUMBER=$1
+
+if [ -z "$PR_NUMBER" ] ; then
echo "Merge commit to master -> continue with CI"
exit 0
fi
-export BRANCH=$(scripts/analysis/getBranchBase.sh $1 $2 $3 | sed s'/"//'g)
-if [ $(git diff --name-only origin/$BRANCH | grep -cE "^app/src|screenshots|build.gradle|.drone.yml") -eq 0 ] ; then
+export BRANCH=$(scripts/analysis/getBranchBase.sh "$PR_NUMBER" | sed 's/"//g')
+if [ "$(git diff --name-only "origin/$BRANCH" | grep -cE "^app/src|screenshots|build.gradle|.drone.yml")" -eq 0 ] ; then
echo "No source files changed"
exit 1
else
diff --git a/scripts/deleteOldComments.sh b/scripts/deleteOldComments.sh
index 2b1901f3be..179bfec287 100755
--- a/scripts/deleteOldComments.sh
+++ b/scripts/deleteOldComments.sh
@@ -2,25 +2,25 @@
#1: BRANCH
#2: TYPE
#3: PR
-#4: GITHUB_TOKEN
BRANCH=$1
TYPE=$2
PR=$3
-GITHUB_TOKEN=$4
+
+source scripts/lib.sh
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|github-actions)") | tostring) + "|" + (.body | test([$TYPE]) | tostring)'| grep "true|true" | tr -d "\"" | cut -f1 -d"|")
+oldComments=$(curl_gh -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|github-actions)") | tostring) + "|" + (.body | test([$TYPE]) | tostring)'| grep "true|true" | tr -d "\"" | cut -f1 -d"|")
count=$(echo -n "$oldComments" | grep -c '^')
echo "Found $count old comments"
if [ "$count" -gt 0 ]; then
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
+ curl_gh -X DELETE https://api.github.com/repos/nextcloud/android/issues/comments/$comment
done
fi
diff --git a/scripts/lib.sh b/scripts/lib.sh
new file mode 100644
index 0000000000..e995473997
--- /dev/null
+++ b/scripts/lib.sh
@@ -0,0 +1,48 @@
+#!/usr/bin/env bash
+#
+# Nextcloud Android Library is available under MIT license
+#
+# @author Álvaro Brey Vilas
+# Copyright (C) 2022 Álvaro Brey Vilas
+# Copyright (C) 2022 Nextcloud GmbH
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+
+## This file is intended to be sourced by other scripts
+
+
+function err() {
+ echo >&2 "$@"
+}
+
+
+function curl_gh() {
+ if [[ -n "$GITHUB_TOKEN" ]]
+ then
+ curl \
+ --silent \
+ --header "Authorization: token $GITHUB_TOKEN" \
+ "$@"
+ else
+ err "WARNING: No GITHUB_TOKEN found. Skipping API call"
+ fi
+
+}
diff --git a/scripts/runAllScreenshotCombinations b/scripts/runAllScreenshotCombinations
index 1239b9e227..a2f26a32cc 100755
--- a/scripts/runAllScreenshotCombinations
+++ b/scripts/runAllScreenshotCombinations
@@ -42,9 +42,9 @@ do
-Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest \
-Pandroid.testInstrumentationRunnerArguments.COLOR="$color" \
-Pandroid.testInstrumentationRunnerArguments.DARKMODE="$darkMode" </dev/null > /dev/null \
- && scripts/deleteOldComments.sh "$1-$darkMode-$color" "Screenshot" "$4" "$GIT_TOKEN" \
+ && scripts/deleteOldComments.sh "$1-$darkMode-$color" "Screenshot" "$4" \
|| resultCode=1 && scripts/uploadReport.sh "$LOG_USERNAME" "$LOG_PASSWORD" "$4" \
- "$1-$darkMode-$color" "Screenshot" "$4" "$GIT_TOKEN"
+ "$1-$darkMode-$color" "Screenshot" "$4"
fi
done
diff --git a/scripts/runCombinedTest.sh b/scripts/runCombinedTest.sh
index 3b30f36312..80c8ac87da 100755
--- a/scripts/runCombinedTest.sh
+++ b/scripts/runCombinedTest.sh
@@ -1,13 +1,11 @@
#!/bin/bash
-GIT_USERNAME=$1
-GIT_TOKEN=$2
-DRONE_PULL_REQUEST=$3
-LOG_USERNAME=$4
-LOG_PASSWORD=$5
-DRONE_BUILD_NUMBER=$6
+DRONE_PULL_REQUEST=$1
+LOG_USERNAME=$2
+LOG_PASSWORD=$3
+DRONE_BUILD_NUMBER=$4
-scripts/deleteOldComments.sh "master" "IT" $DRONE_PULL_REQUEST $GIT_TOKEN
+scripts/deleteOldComments.sh "master" "IT" "$DRONE_PULL_REQUEST"
./gradlew assembleGplayDebugAndroidTest
@@ -19,7 +17,7 @@ scripts/wait_for_server.sh "server"
stat=$?
if [ ! $stat -eq 0 ]; then
- bash scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "master" "IT" $DRONE_PULL_REQUEST $GIT_TOKEN
+ bash scripts/uploadReport.sh "$LOG_USERNAME" "$LOG_PASSWORD" "$DRONE_BUILD_NUMBER" "master" "IT" "$DRONE_PULL_REQUEST"
fi
curl -Os https://uploader.codecov.io/latest/linux/codecov
diff --git a/scripts/uploadArtifact.sh b/scripts/uploadArtifact.sh
index d9a58e00d6..d4990a84e0 100755
--- a/scripts/uploadArtifact.sh
+++ b/scripts/uploadArtifact.sh
@@ -4,7 +4,6 @@
#2: LOG_PASSWORD
#3: DRONE_BUILD_NUMBER
#4: DRONE_PULL_REQUEST
-#5: GITHUB_TOKEN
DAV_URL=https://nextcloud.kaminsky.me/remote.php/webdav/android-artifacts/
PUBLIC_URL=https://www.kaminsky.me/nc-dev/android-artifacts
@@ -12,7 +11,8 @@ USER=$1
PASS=$2
BUILD=$3
PR=$4
-GITHUB_TOKEN=$5
+
+source scripts/lib.sh
if ! test -e app/build/outputs/apk/qa/debug/qa-debug-*.apk ; then
exit 1
@@ -20,10 +20,10 @@ fi
echo "Uploaded artifact to $DAV_URL/$BUILD.apk"
# delete all old comments, starting with "APK file:"
-oldComments=$(curl 2>/dev/null --header "authorization: Bearer $GITHUB_TOKEN" -X GET https://api.github.com/repos/nextcloud/android/issues/$PR/comments | jq '.[] | (.id |tostring) + "|" + (.user.login | test("github-actions") | tostring) + "|" + (.body | test("APK file:.*") | tostring)' | grep "true|true" | tr -d "\"" | cut -f1 -d"|")
+oldComments=$(curl_gh -X GET https://api.github.com/repos/nextcloud/android/issues/$PR/comments | jq '.[] | (.id |tostring) + "|" + (.user.login | test("github-actions") | tostring) + "|" + (.body | test("APK file:.*") | tostring)' | grep "true|true" | tr -d "\"" | cut -f1 -d"|")
echo $oldComments | while read comment ; do
- curl 2>/dev/null --header "authorization: Bearer $GITHUB_TOKEN" -X DELETE https://api.github.com/repos/nextcloud/android/issues/comments/$comment
+ curl_gh -X DELETE https://api.github.com/repos/nextcloud/android/issues/comments/$comment
done
apt-get -y install qrencode
@@ -32,4 +32,4 @@ qrencode -o $PR.png "$PUBLIC_URL/$BUILD.apk"
curl -u $USER:$PASS -X PUT $DAV_URL/$BUILD.apk --upload-file app/build/outputs/apk/qa/debug/qa-debug-*.apk
curl -u $USER:$PASS -X PUT $DAV_URL/$BUILD.png --upload-file $PR.png
-curl --header "authorization: Bearer $GITHUB_TOKEN" -X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments -d "{ \"body\" : \"APK file: $PUBLIC_URL/$BUILD.apk <br/><br/> ![qrcode]($PUBLIC_URL/$BUILD.png) <br/><br/>To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app. \" }"
+curl_gh -X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments -d "{ \"body\" : \"APK file: $PUBLIC_URL/$BUILD.apk <br/><br/> ![qrcode]($PUBLIC_URL/$BUILD.png) <br/><br/>To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app. \" }"
diff --git a/scripts/uploadReport.sh b/scripts/uploadReport.sh
index 2786eb12df..81538c1ca3 100755
--- a/scripts/uploadReport.sh
+++ b/scripts/uploadReport.sh
@@ -1,26 +1,7 @@
#!/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_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_gh > /dev/null 2>&1 -X DELETE https://api.github.com/repos/nextcloud/android/issues/comments/$comment
- done
-}
-
upload() {
- deleteOldComments
+ scripts/deleteOldComments.sh "$BRANCH" "$TYPE" "$PR"
cd $1
@@ -41,7 +22,6 @@ upload() {
#4: BRANCH (stable or master)
#5: TYPE (IT or Unit)
#6: DRONE_PULL_REQUEST
-#7: GITHUB_TOKEN
URL=https://nextcloud.kaminsky.me/remote.php/webdav/android-integrationTests
ID=$3
@@ -50,7 +30,8 @@ PASS=$2
BRANCH=$4
TYPE=$5
PR=$6
-GITHUB_TOKEN="$7"
+
+source scripts/lib.sh
REMOTE_FOLDER=$ID-$TYPE-$BRANCH-$(date +%H-%M)
BRANCH_TYPE=$BRANCH-$TYPE