From 7793a3ead307885e7d4eeb7161f5ffbb75aedca1 Mon Sep 17 00:00:00 2001 From: Tomas Kral Date: Tue, 12 Mar 2024 15:28:01 +0100 Subject: [PATCH] E2E: upload Playwright report and add view report link to PR (#1068) * chore(ci): upload Playwright report and add view report link to PR * Update functions.sh chore(ci): fix link to Playwright report in GitHub comment --- .ibm/pipelines/functions.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.ibm/pipelines/functions.sh b/.ibm/pipelines/functions.sh index 244e1fcac..1ee9789f8 100644 --- a/.ibm/pipelines/functions.sh +++ b/.ibm/pipelines/functions.sh @@ -11,11 +11,23 @@ save_logs() { RESULT="$3" ansi2html <"/tmp/${LOGFILE}" >"/tmp/${LOGFILE}.html" - + # Create a tarball of the playwright-report directory + tar -czvf /tmp/${LOGFILE}-report.tar.gz playwright-report/ + CRN=$(ibmcloud resource service-instance ${IBM_COS} --output json | jq -r .[0].guid) ibmcloud cos config crn --crn "${CRN}" ibmcloud cos upload --bucket "${IBM_BUCKET}" --key "${LOGFILE}.html" --file "/tmp/${LOGFILE}.html" --content-type "text/html; charset=UTF-8" - + ibmcloud cos upload --bucket "${IBM_BUCKET}" --key "${LOGFILE}-report.tar.gz" --file "/tmp/${LOGFILE}-report.tar.gz" --content-type "application/gzip" + + # Loop through each file in the e2e-tests/playwright-report directory + find playwright-report -type f | while read FILE; do + # Extract the file path relative to the directory to maintain the structure in COS + RELATIVE_PATH=${FILE#$DIRECTORY_TO_UPLOAD} + # Upload the file + ibmcloud cos upload --bucket "${IBM_BUCKET}" --key "${LOGFILE}-report/${RELATIVE_PATH}" --file "${FILE}" + done + + BASE_URL="https://s3.${IBM_REGION}.cloud-object-storage.appdomain.cloud/${IBM_BUCKET}" if [[ $RESULT == "0" ]]; then STATUS="successfully" @@ -26,6 +38,8 @@ save_logs() { cat <