Skip to content

Commit

Permalink
add script for showing playwright report
Browse files Browse the repository at this point in the history
  • Loading branch information
JoCa96 committed Sep 17, 2024
1 parent 706e8a2 commit 36aea48
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"lint:ci:all": "pnpm run lint:all --format @microsoft/eslint-formatter-sarif --output-file eslint-results.sarif",
"publint:all": "pnpm -r --parallel --aggregate-output exec publint",
"prepare": "simple-git-hooks",
"gh:show-report": "./scripts/show-last-test-report.sh",
"preinstall": "npx only-allow pnpm"
},
"devDependencies": {
Expand Down
25 changes: 25 additions & 0 deletions scripts/show-last-test-report.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env sh

# check if gh cli is installed
if ! command -v gh &>/dev/null; then
echo "gh CLI is not installed. Please install it first: https://github.com/cli/cli#installation"
exit 1
fi

# Create temporary directory
TMP_DIR=$(mktemp -d)

# Create shell trap to clean up temporary directory
function cleanup {
rm -r ${TMP_DIR}
}
trap cleanup EXIT

# query the id of the last failed run for the current branch
GH_LAST_RUN_ID=$(gh run list -s failure -b $(git branch --show-current) --json "createdAt,databaseId" --jq "sort_by(.createdAt) | last.databaseId")

# download report
gh run download $GH_LAST_RUN_ID -D $TMP_DIR -p "html-report--attempt-1"

# show report
(cd $TMP_DIR/html-report--attempt-1/packages/sit-onyx && pnpm dlx playwright show-report)

0 comments on commit 36aea48

Please sign in to comment.