Skip to content

Commit de1e9c9

Browse files
CopilotSkn0tt
andcommitted
Move shard warning before fatal errors and simplify GHA constructor
Co-authored-by: Skn0tt <14912729+Skn0tt@users.noreply.github.com>
1 parent dc5bce2 commit de1e9c9

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

packages/playwright/src/reporters/markdown.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ class MarkdownReporter implements Reporter {
5151
async onEnd(result: FullResult) {
5252
const summary = this._generateSummary();
5353
const lines: string[] = [];
54+
if (this._options.shardDurationThreshold && result.shards) {
55+
for (const shard of result.shards) {
56+
if (shard.duration > this._options.shardDurationThreshold) {
57+
const shardLabel = shard.shardIndex !== undefined ? `Shard ${shard.shardIndex}` : 'Shard';
58+
const durationMins = Math.round(shard.duration / 60000);
59+
const thresholdMins = Math.round(this._options.shardDurationThreshold / 60000);
60+
lines.push(`:warning: **Warning: ${shardLabel} took ${durationMins} minutes, exceeding the ${thresholdMins} minute threshold.**`);
61+
lines.push(``);
62+
}
63+
}
64+
}
5465
if (this._fatalErrors.length)
5566
lines.push(`**${this._fatalErrors.length} fatal errors, not part of any test**`);
5667
if (summary.unexpected.length) {
@@ -76,18 +87,6 @@ class MarkdownReporter implements Reporter {
7687
lines.push(`**${summary.expected} passed${skipped}${didNotRun}**`);
7788
lines.push(``);
7889

79-
if (this._options.shardDurationThreshold && result.shards) {
80-
for (const shard of result.shards) {
81-
if (shard.duration > this._options.shardDurationThreshold) {
82-
const shardLabel = shard.shardIndex !== undefined ? `Shard ${shard.shardIndex}` : 'Shard';
83-
const durationMins = Math.round(shard.duration / 60000);
84-
const thresholdMins = Math.round(this._options.shardDurationThreshold / 60000);
85-
lines.push(`:warning: **Warning: ${shardLabel} took ${durationMins} minutes, exceeding the ${thresholdMins} minute threshold.**`);
86-
lines.push(``);
87-
}
88-
}
89-
}
90-
9190
await this.publishReport(lines.join('\n'));
9291
}
9392

tests/config/ghaMarkdownReporter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ function getGithubToken() {
3434
const octokit = getOctokit(getGithubToken());
3535

3636
class GHAMarkdownReporter extends MarkdownReporter {
37-
constructor(options: { configDir: string, outputFile?: string, shardDurationThreshold?: number }) {
38-
super({ ...options, shardDurationThreshold: options.shardDurationThreshold ?? 25 * 60 * 1000 });
37+
constructor(options: { configDir: string, outputFile?: string }) {
38+
super({ ...options, shardDurationThreshold: 25 * 60 * 1000 });
3939
}
4040

4141
override async publishReport(report: string) {

0 commit comments

Comments
 (0)