-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This reporter does following: - Publish html tests results to github pages - Publish comment with summary and url link to test results - When posting comments, previous comment is deleted Also introducing github action to delete all tests results older than 7 days.
- Loading branch information
Showing
4 changed files
with
191 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Delete old playwright reports | ||
|
||
on: | ||
schedule: | ||
# Run every Monday 2:30 at night | ||
- cron: "30 2 * * 1" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
delete_old_folders: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: gh-pages | ||
fetch-depth: 0 | ||
|
||
- name: Delete all folders older than 7 days | ||
run: | | ||
current_time=$(date +%s) | ||
for dir in `find ./ -maxdepth 1 -type d -name '20*'`; do | ||
dir_creation_time=$(git log -1 --format='%at' "$dir") | ||
time_diff=$((current_time - dir_creation_time)) | ||
# If the directory is older than 7 days | ||
if [ "$time_diff" -gt 604800 ]; then | ||
echo "Deleting $dir" | ||
rm -rf "$dir" | ||
else | ||
echo "Keeping $dir" | ||
fi | ||
done | ||
- name: Commit all removed folders | ||
uses: stefanzweifel/git-auto-commit-action@v5 | ||
with: | ||
branch: gh-pages | ||
commit_message: Delete folders older than 7 days |
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,68 @@ | ||
import type { | ||
Reporter, FullConfig, Suite, TestCase, TestResult, FullResult | ||
} from '@playwright/test/reporter'; | ||
|
||
class MyReporter implements Reporter { | ||
suite!: Suite | ||
|
||
onBegin(config: FullConfig, suite: Suite) { | ||
this.suite = suite; | ||
} | ||
|
||
onEnd(result: FullResult) { | ||
let passed = 0; | ||
let failed = 0; | ||
let flaky = 0; | ||
let skipped = 0; | ||
let internal_error = false; | ||
|
||
this.suite.suites.forEach((project) => { | ||
project.allTests().forEach((test) => { | ||
if (test.results[0].status === "passed") | ||
passed += 1; | ||
else if (test.results[0].status === "skipped") | ||
skipped += 1; | ||
else if (test.retries === 0) { | ||
if (test.results[0].status === "failed") | ||
failed += 1; | ||
else | ||
internal_error = true; | ||
} else if (test.retries > 0) { | ||
if (test.retries + 1 === test.results.length) { | ||
if (test.results[test.retries].status === "passed") | ||
flaky += 1; | ||
else if (test.results[test.retries].status === "failed") | ||
failed += 1; | ||
else | ||
internal_error = true; | ||
} else if (test.results[test.results.length - 1].status === "passed") | ||
flaky += 1; | ||
else | ||
internal_error = true; | ||
} | ||
}) | ||
}); | ||
|
||
if (internal_error) { | ||
console.log("Failed to parse test results!") | ||
return; | ||
} | ||
|
||
let skipped_msg = ""; | ||
if (skipped > 0) | ||
skipped_msg = `${skipped} skipped`; | ||
|
||
let flaky_msg = ""; | ||
if (flaky > 0) | ||
flaky_msg = `${flaky} flaky`; | ||
|
||
let msg = "" | ||
if (failed > 0) | ||
msg = `❌ ${failed} failed test(s)`; | ||
else | ||
msg = `✅ ${passed} passed test(s)`; | ||
|
||
console.log([msg, flaky_msg, skipped_msg].filter(Boolean).join(", ")); | ||
} | ||
} | ||
export default MyReporter; |
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