From 22422541b84b73a4b29d6fd8eb8c015c25188b26 Mon Sep 17 00:00:00 2001 From: Sawjan Gurung Date: Fri, 3 Mar 2023 09:33:14 +0545 Subject: [PATCH] add github comment step in e2e pipeline (#5703) fix comment file path cache tracing to ocis sub path --- .drone.star | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/.drone.star b/.drone.star index 489444440f..59de8e5891 100644 --- a/.drone.star +++ b/.drone.star @@ -1144,7 +1144,8 @@ def e2eTests(ctx): ocisServer("ocis", 4, []) + \ e2e_test_ocis + \ uploadTracingResult(ctx) + \ - publishTracingResult(ctx, "e2e test") + buildTracingComment() + \ + e2eGithubComment() if ("skip-e2e" in ctx.build.title.lower()): return [] @@ -1177,7 +1178,7 @@ def uploadTracingResult(ctx): "path_style": True, "source": "webTestRunner/reports/e2e/playwright/tracing/**/*", "strip_prefix": "webTestRunner/reports/e2e/playwright/tracing", - "target": "${DRONE_BUILD_NUMBER}/tracing", + "target": "/${DRONE_REPO}/${DRONE_BUILD_NUMBER}/tracing", }, "environment": { "AWS_ACCESS_KEY_ID": { @@ -1198,19 +1199,18 @@ def uploadTracingResult(ctx): }, }] -def publishTracingResult(ctx, suite): +def buildTracingComment(): return [{ - "name": "publish-tracing-result", + "name": "build-tracing-comment", "image": OC_UBUNTU, "commands": [ "cd %s/reports/e2e/playwright/tracing/" % dirs["web"], 'echo "
:boom: To see the trace, please open the link in the console ...\\n\\n

\\n\\n" >> comments.file', - 'for f in *.zip; do echo "#### npx playwright show-trace $CACHE_ENDPOINT/$CACHE_BUCKET/${DRONE_BUILD_NUMBER}/tracing/$f \n" >> comments.file; done', + 'for f in *.zip; do echo "#### npx playwright show-trace $CACHE_ENDPOINT/$CACHE_BUCKET/${DRONE_REPO}/${DRONE_BUILD_NUMBER}/tracing/$f \n" >> comments.file; done', 'echo "\n

" >> comments.file', "more comments.file", ], "environment": { - "TEST_CONTEXT": suite, "CACHE_ENDPOINT": { "from_secret": "cache_public_s3_server", }, @@ -1229,6 +1229,34 @@ def publishTracingResult(ctx, suite): }, }] +def e2eGithubComment(): + prefix = "E2E tests failed: ${DRONE_BUILD_LINK}/${DRONE_JOB_NUMBER}${DRONE_STAGE_NUMBER}/1" + return [{ + "name": "github-comment", + "image": THEGEEKLAB_DRONE_GITHUB_COMMENT, + "pull": "if-not-exists", + "settings": { + "message": "%s/reports/e2e/playwright/tracing/comments.file" % dirs["web"], + "key": "pr-${DRONE_PULL_REQUEST}", + "update": "true", + "api_key": { + "from_secret": "github_token", + }, + }, + "commands": [ + "cd %s/reports/e2e/playwright/tracing/" % dirs["web"], + "if [ -s comments.file ]; then echo '%s' | cat - comments.file > temp && mv temp comments.file && /bin/drone-github-comment; fi" % prefix, + ], + "when": { + "status": [ + "failure", + ], + "event": [ + "pull_request", + ], + }, + }] + def failEarly(ctx, early_fail): """failEarly sends posts a comment about the failed pipeline to the github pr and then kills all pipelines of the current build