From f25dc8b7c62589b401163dd22952d50d167a1f22 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Tue, 29 Jun 2021 12:43:13 +0545 Subject: [PATCH 1/8] Process comments for passedOnRetry in a separate file --- .drone.star | 61 +++++++++++++++++++++++++++-------------- .gitignore | 1 + tests/acceptance/run.sh | 8 +++--- 3 files changed, 45 insertions(+), 25 deletions(-) diff --git a/.drone.star b/.drone.star index 786c564423d..da08c7f5471 100644 --- a/.drone.star +++ b/.drone.star @@ -2455,31 +2455,50 @@ def buildGithubCommentForBuildStopped(suite): def githubComment(alternateSuiteName): prefix = "Results for %s ${DRONE_BUILD_LINK}/${DRONE_JOB_NUMBER}${DRONE_STAGE_NUMBER}/1" % alternateSuiteName - return [{ - "name": "github-comment", - "image": "jmccann/drone-github-comment:1", - "pull": "if-not-exists", - "settings": { - "message_file": "%s/comments.file" % dir["web"], - }, - "environment": { - "GITHUB_TOKEN": { - "from_secret": "github_token", + return [ + { + "name": "copy-passedOnRetry", + "image": "owncloud/ubuntu:20.04", + "pull": "always", + "commands": [ + "if [ -f %s/passedOnRetry.file ]; then cat passedOnRetry.file >> %s/comments.file; fi" % (dir["web"], dir["web"]), + ], + "when": { + "status": [ + "success", + "failure", + ], + "event": [ + "pull_request", + ], }, }, - "commands": [ - "if [ -s /var/www/owncloud/web/comments.file ]; then echo '%s' | cat - comments.file > temp && mv temp comments.file && /bin/drone-github-comment; fi" % prefix, - ], - "when": { - "status": [ - "success", - "failure", - ], - "event": [ - "pull_request", + { + "name": "github-comment", + "image": "jmccann/drone-github-comment:1", + "pull": "if-not-exists", + "settings": { + "message_file": "%s/comments.file" % dir["web"], + }, + "environment": { + "GITHUB_TOKEN": { + "from_secret": "github_token", + }, + }, + "commands": [ + "if [ -s /var/www/owncloud/web/comments.file ]; then echo '%s' | cat - comments.file > temp && mv temp comments.file && /bin/drone-github-comment; fi" % prefix, ], + "when": { + "status": [ + "success", + "failure", + ], + "event": [ + "pull_request", + ], + }, }, - }] + ] def example_deploys(ctx): latest_configs = [ diff --git a/.gitignore b/.gitignore index 0637dcf6eda..e86f81fdcab 100644 --- a/.gitignore +++ b/.gitignore @@ -39,6 +39,7 @@ tests/testing-app # acceptance test artifacts logfile.txt comments.file +passedOnRetry.file # drone CI is in .drone.star, do not let someone accidentally commit a local .drone.yml .drone.yml diff --git a/tests/acceptance/run.sh b/tests/acceptance/run.sh index 19734618fe4..cec15c151b2 100755 --- a/tests/acceptance/run.sh +++ b/tests/acceptance/run.sh @@ -4,9 +4,9 @@ SCRIPT_PATH=$(dirname "$0") SCRIPT_PATH=$( cd "${SCRIPT_PATH}" && pwd ) # normalized and made absolute FEATURES_DIR="${SCRIPT_PATH}/features" -COMMENTS_FILE="${COMMENTS_FILE:-comments.file}" +PASSED_ON_RETRY_FILE="${PASSED_ON_RETRY_FILE:-passedOnRetry.file}" -rm -rf logfile.txt "$COMMENTS_FILE" +rm -rf logfile.txt "$PASSED_ON_RETRY_FILE" echo 'run.sh: running acceptance-tests-drone' @@ -240,9 +240,9 @@ if [ ${#SINGLE_FAILED_SCENARIOS[@]} -ne 0 ] then echo "" echo "" - echo "The following scenarios passed on retry:" | tee -a "$COMMENTS_FILE" + echo "The following scenarios passed on retry:" | tee -a "$PASSED_ON_RETRY_FILE" echo "-------------------------------" - for KEY in "${!SINGLE_FAILED_SCENARIOS[@]}"; do echo "- $KEY" | tee -a "$COMMENTS_FILE"; done + for KEY in "${!SINGLE_FAILED_SCENARIOS[@]}"; do echo "- $KEY" | tee -a "$PASSED_ON_RETRY_FILE"; done echo "-------------------------------" fi From d2e28f4d083d742847bcb0d7527b8fb79dbf2eaf Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Tue, 29 Jun 2021 18:43:22 +0545 Subject: [PATCH 2/8] Add a step to notify slack about passed-on-retry --- .drone.star | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.drone.star b/.drone.star index da08c7f5471..625b3ce715f 100644 --- a/.drone.star +++ b/.drone.star @@ -2473,6 +2473,30 @@ def githubComment(alternateSuiteName): ], }, }, + { + "name": "notify-passedOnRetry", + "image": "plugins/slack:1", + "pull": "always", + "settings": { + "webhook": { + "from_secret": config["rocketchat"]["from_secret"], + }, + "channel": config["rocketchat"]["channel"], + "template": "there were scenarios that passed-on-retry", + }, + "commands": [ + "if [ -f %s/passedOnRetry.file ]; then /bin/drone-slack; fi" % dir["web"], + ], + "when": { + "status": [ + "success", + "failure", + ], + "event": [ + "pull_request", + ], + }, + }, { "name": "github-comment", "image": "jmccann/drone-github-comment:1", From 3c68d491185b7a368da4605b352d97539d59e4eb Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Fri, 2 Jul 2021 16:55:01 +0545 Subject: [PATCH 3/8] get slack notify template from passedOnRetry.file --- .drone.star | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.drone.star b/.drone.star index 625b3ce715f..53da34035c6 100644 --- a/.drone.star +++ b/.drone.star @@ -2482,11 +2482,8 @@ def githubComment(alternateSuiteName): "from_secret": config["rocketchat"]["from_secret"], }, "channel": config["rocketchat"]["channel"], - "template": "there were scenarios that passed-on-retry", + "template": "file:/%s/passedOnRetry.file", }, - "commands": [ - "if [ -f %s/passedOnRetry.file ]; then /bin/drone-slack; fi" % dir["web"], - ], "when": { "status": [ "success", From 1ac5db2c3f377a0aa5483d64a04b880ff5bd7779 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Fri, 2 Jul 2021 17:10:41 +0545 Subject: [PATCH 4/8] actually put in the dir path to passedOnRetry.file --- .drone.star | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.star b/.drone.star index 53da34035c6..3803ee2608c 100644 --- a/.drone.star +++ b/.drone.star @@ -2482,7 +2482,7 @@ def githubComment(alternateSuiteName): "from_secret": config["rocketchat"]["from_secret"], }, "channel": config["rocketchat"]["channel"], - "template": "file:/%s/passedOnRetry.file", + "template": "file:/%s/passedOnRetry.file" % dir["web"], }, "when": { "status": [ From ce79ae12d922296ee3d6c9177f67cc6874f7d40c Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Fri, 2 Jul 2021 17:41:55 +0545 Subject: [PATCH 5/8] fix leading slash --- .drone.star | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.star b/.drone.star index 3803ee2608c..7876ffafbc8 100644 --- a/.drone.star +++ b/.drone.star @@ -2482,7 +2482,7 @@ def githubComment(alternateSuiteName): "from_secret": config["rocketchat"]["from_secret"], }, "channel": config["rocketchat"]["channel"], - "template": "file:/%s/passedOnRetry.file" % dir["web"], + "template": "file:%s/passedOnRetry.file" % dir["web"], }, "when": { "status": [ From 13d285c38095c8e35659615e3077a324a6e17e0b Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Fri, 2 Jul 2021 18:13:38 +0545 Subject: [PATCH 6/8] Add drone link to rocketChat notify --- .drone.star | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.drone.star b/.drone.star index 7876ffafbc8..5c7c8934116 100644 --- a/.drone.star +++ b/.drone.star @@ -2461,7 +2461,8 @@ def githubComment(alternateSuiteName): "image": "owncloud/ubuntu:20.04", "pull": "always", "commands": [ - "if [ -f %s/passedOnRetry.file ]; then cat passedOnRetry.file >> %s/comments.file; fi" % (dir["web"], dir["web"]), + "if [ -s %s/passedOnRetry.file ]; then cat %s/passedOnRetry.file >> %s/comments.file; fi" % (dir["web"], dir["web"], dir["web"]), + "if [ -s %s/passedOnRetry.file ]; then echo '%s' | cat - %s/passedOnRetry.file > %s/rocketChat.file; fi" % (dir["web"], prefix, dir["web"], dir["web"]), ], "when": { "status": [ @@ -2482,7 +2483,7 @@ def githubComment(alternateSuiteName): "from_secret": config["rocketchat"]["from_secret"], }, "channel": config["rocketchat"]["channel"], - "template": "file:%s/passedOnRetry.file" % dir["web"], + "template": "file:%s/rocketChat.file" % dir["web"], }, "when": { "status": [ From 687f5487f8f6f35816c0c59feb1d452962a526b7 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Fri, 2 Jul 2021 18:58:37 +0545 Subject: [PATCH 7/8] Fix bold for RocketChat --- .drone.star | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.drone.star b/.drone.star index 5c7c8934116..89bcce8779d 100644 --- a/.drone.star +++ b/.drone.star @@ -2454,7 +2454,8 @@ def buildGithubCommentForBuildStopped(suite): }] def githubComment(alternateSuiteName): - prefix = "Results for %s ${DRONE_BUILD_LINK}/${DRONE_JOB_NUMBER}${DRONE_STAGE_NUMBER}/1" % alternateSuiteName + prefixGitHub = "Results for %s ${DRONE_BUILD_LINK}/${DRONE_JOB_NUMBER}${DRONE_STAGE_NUMBER}/1" % alternateSuiteName + prefixRocketChat = "Results for *%s* ${DRONE_BUILD_LINK}/${DRONE_JOB_NUMBER}${DRONE_STAGE_NUMBER}/1" % alternateSuiteName return [ { "name": "copy-passedOnRetry", @@ -2462,7 +2463,7 @@ def githubComment(alternateSuiteName): "pull": "always", "commands": [ "if [ -s %s/passedOnRetry.file ]; then cat %s/passedOnRetry.file >> %s/comments.file; fi" % (dir["web"], dir["web"], dir["web"]), - "if [ -s %s/passedOnRetry.file ]; then echo '%s' | cat - %s/passedOnRetry.file > %s/rocketChat.file; fi" % (dir["web"], prefix, dir["web"], dir["web"]), + "if [ -s %s/passedOnRetry.file ]; then echo '%s' | cat - %s/passedOnRetry.file > %s/rocketChat.file; fi" % (dir["web"], prefixRocketChat, dir["web"], dir["web"]), ], "when": { "status": [ @@ -2508,7 +2509,7 @@ def githubComment(alternateSuiteName): }, }, "commands": [ - "if [ -s /var/www/owncloud/web/comments.file ]; then echo '%s' | cat - comments.file > temp && mv temp comments.file && /bin/drone-github-comment; fi" % prefix, + "if [ -s /var/www/owncloud/web/comments.file ]; then echo '%s' | cat - comments.file > temp && mv temp comments.file && /bin/drone-github-comment; fi" % prefixGitHub, ], "when": { "status": [ From c8eac5b5764f931a485ca91dc57be75563c947d2 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Fri, 2 Jul 2021 19:52:29 +0545 Subject: [PATCH 8/8] make an empty rocketChat.file --- .drone.star | 1 + 1 file changed, 1 insertion(+) diff --git a/.drone.star b/.drone.star index 89bcce8779d..1398efbf052 100644 --- a/.drone.star +++ b/.drone.star @@ -2462,6 +2462,7 @@ def githubComment(alternateSuiteName): "image": "owncloud/ubuntu:20.04", "pull": "always", "commands": [ + "touch %s/rocketChat.file" % dir["web"], "if [ -s %s/passedOnRetry.file ]; then cat %s/passedOnRetry.file >> %s/comments.file; fi" % (dir["web"], dir["web"], dir["web"]), "if [ -s %s/passedOnRetry.file ]; then echo '%s' | cat - %s/passedOnRetry.file > %s/rocketChat.file; fi" % (dir["web"], prefixRocketChat, dir["web"], dir["web"]), ],