From 5b978a5100cad6772996e6f2af91417e0ad9251b Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Thu, 2 Mar 2023 09:56:01 +0545 Subject: [PATCH] add github comment step in e2e pipeline 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 36c58078f03..cd68785f469 100644 --- a/.drone.star +++ b/.drone.star @@ -1148,7 +1148,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 [] @@ -1181,7 +1182,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": { @@ -1202,19 +1203,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", }, @@ -1233,6 +1233,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 settingsUITests(ctx, storage = "ocis", accounts_hash_difficulty = 4): early_fail = config["settingsUITests"]["earlyFail"] if "earlyFail" in config["settingsUITests"] else False