-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
SWC-6624: store Playwright reports with traces in S3 when e2e workflow runs in Sage repo
- Loading branch information
Showing
5 changed files
with
168 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/bash | ||
|
||
# View Playwright report stored in GitHub | ||
# ./view_github_report.sh [github-repo-owner] [github-run-id] | ||
# | ||
|
||
# Abort script on errors and unbound variables | ||
# https://bertvv.github.io/cheat-sheets/Bash.html | ||
set -o errexit # abort on nonzero exitstatus | ||
set -o nounset # abort on unbound variable | ||
set -o pipefail # don't hide errors within pipes | ||
|
||
# Set variables | ||
SCRIPT_PATH="$(cd "$(dirname "${0}")"; echo $(pwd))" | ||
REPO_PATH="$(dirname ${SCRIPT_PATH})" | ||
REPO_NAME="$(basename ${REPO_PATH})" | ||
BLOB_DIR="${REPO_PATH}/blob-report/" | ||
REPORT_DIR="${REPO_PATH}/playwright-report/" | ||
|
||
# Get parameters from user | ||
if [ "$#" -lt 2 ]; then | ||
echo "Usage: $0 [github-repo-owner] [github-run-id]" | ||
echo "* github-repo-owner: GitHub repo owner" | ||
echo "* github-run-id: GitHub Run ID of report to view" | ||
exit | ||
fi | ||
REPO_OWNER="${1}" | ||
RUN_ID="${2}" | ||
|
||
# Delete previous report files | ||
for file in $(find "${BLOB_DIR}" -type f) $(find "${REPORT_DIR}" -type f); do | ||
[ -f "${file}" ] && echo "delete: ${file}" && rm "${file}" | ||
done | ||
|
||
# Get workflow artifact id and name | ||
ARTIFACT=$(gh api \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
"/repos/${REPO_OWNER}/${REPO_NAME}/actions/runs/${RUN_ID}/artifacts" \ | ||
| jq '.artifacts[] | select(.name | contains("html-report")) | {id, name}') | ||
ARTIFACT_ID=$(echo "${ARTIFACT}" | jq '.id') | ||
ARTIFACT_NAME=$(echo "${ARTIFACT}" | jq -r '.name') | ||
|
||
# Download workflow artifact | ||
ARTIFACT_ENDPOINT="/repos/${REPO_OWNER}/${REPO_NAME}/actions/artifacts/${ARTIFACT_ID}/zip" | ||
ARTIFACT_ZIP="${BLOB_DIR}/${ARTIFACT_NAME}.zip" | ||
echo "download: ${ARTIFACT_ENDPOINT} to ${ARTIFACT_ZIP}" | ||
gh api \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
"${ARTIFACT_ENDPOINT}" > "${ARTIFACT_ZIP}" | ||
|
||
# Unzip file | ||
unzip "${ARTIFACT_ZIP}" -d "${REPORT_DIR}" | ||
|
||
# Show report | ||
yarn e2e:report |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
|
||
# View Playwright report stored in S3 | ||
# ./view_s3_report.sh [aws-sso-profile-name] [github-run-id] [optional-run-attempt-number] | ||
# | ||
|
||
# Abort script on errors and unbound variables | ||
# https://bertvv.github.io/cheat-sheets/Bash.html | ||
set -o errexit # abort on nonzero exitstatus | ||
set -o nounset # abort on unbound variable | ||
set -o pipefail # don't hide errors within pipes | ||
|
||
# Set variables | ||
BUCKET_NAME="e2e-reports-bucket-bucket-1p1qz6p48t4uy" | ||
SCRIPT_PATH="$(cd "$(dirname "${0}")"; echo $(pwd))" | ||
REPO_PATH="$(dirname ${SCRIPT_PATH})" | ||
REPO_NAME="$(basename ${REPO_PATH})" | ||
BLOB_DIR="${REPO_PATH}/blob-report/" | ||
|
||
# Get parameters from user | ||
if [ "$#" -lt 2 ]; then | ||
echo "Usage: $0 [aws-sso-profile-name] [github-run-id] [optional-run-attempt-number]" | ||
echo "* aws-sso-profile-name: AWS SSO profile name, e.g. Developer-{number}" | ||
echo "* github-run-id: GitHub Run ID of report to view" | ||
echo "* optional-run-attempt-number: (optional) Run attempt number. Defaults to 1." | ||
exit | ||
fi | ||
PROFILE="${1}" | ||
RUN_ID="${2}" | ||
RUN_ATTEMPT="${3:-1}" | ||
|
||
# Sync blob reports | ||
aws s3 sync \ | ||
s3://"${BUCKET_NAME}"/"${REPO_NAME}-${RUN_ID}-${RUN_ATTEMPT}"/ \ | ||
"${BLOB_DIR}" \ | ||
--profile "${PROFILE}" \ | ||
--delete | ||
|
||
# Merge blob reports, then serve as HTML report | ||
yarn e2e:report:blob |