Skip to content

feat: introduce new --timings flag to read test duration hints - #68

Merged
aslushnikov merged 7 commits into
mainfrom
new-timigns
Jul 1, 2026
Merged

aslushnikov merged 7 commits into
mainfrom
new-timigns

Conversation

@aslushnikov

Copy link
Copy Markdown
Contributor

The new --timings flag for the flakiness-playwright-shard binary
allows reading duration hints from a previous Flakiness Report, if
necessary.

The new `--timings` flag for the `flakiness-playwright-shard` binary
allows reading duration hints from a previous Flakiness Report, if
necessary.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2db02a5ae0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/playwright-test.ts Outdated
Comment on lines +232 to +234
const maxDuration = test.attempts.reduce((acc, attempt) => Math.max(acc, attempt.duration ?? 0), 0);
// We never accept that a test can be executed "for free": we assign at least
const predictedDuration = Math.max(envDuration ?? maxDuration, 1);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve default weight for missing duration hints

When the durations report/timings file contains a matching test but no usable attempt.duration (for example, the Durations API has no history for that test/env, or all attempts are skipped/missing durations), maxDuration is 0 and this stores a 1ms prediction. That bypasses the DEFAULT_DURATION fallback in sharding.ts, so partial timing data treats unknown tests as effectively free instead of using the default weight, which can heavily skew mixed known/unknown shards.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 931367b5d8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/playwright-test.ts Outdated
// and otherwise use an average duration.
const envDuration = test.attempts.find(attempt => durationsReport.environments[attempt.environmentIdx ?? 0]?.name === envName)?.duration;
// We fallback to the max of the test durations across environments.
const maxDuration = test.attempts.reduce((acc, attempt) => Math.max(acc, attempt.duration ?? 0), 0);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep other projects off unmatched timings

When a timings file has a duration for this test only in a different current environment, such as a file produced with --project=slow and then reused while sharding fast or all projects, envDuration is undefined for the fast test case but this fallback still takes the slow attempt. That records a prediction for the fast project instead of leaving it absent for the default weight, so partial per-project timings can make one environment inherit another environment's duration and skew the balanced split.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 43d1144f0f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/playwright-test.ts Outdated
// For each test case, we want to find the best timing approximation.
// We either try to find the environment with the same name (these should be unique),
// and otherwise use an average duration.
const envDuration = test.attempts.find(attempt => durationsReport.environments[attempt.environmentIdx ?? 0]?.name === envName)?.duration;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Aggregate same-env attempts from timings files

When --timings points at a normal report that contains retries for a test, there can be multiple attempts for the same environment, but this find uses only the first one and ignores the rest. If the first attempt was a quick failure and the retry was the slow run (or vice versa), the generated shard gets a misleading duration even though the timings file has the actual retry data; aggregate matching attempts (for example max or sum) before setting the prediction.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e10f94f2e9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/playwright-test.ts
// and otherwise use a max duration.
const envDuration = envName ? durationsPerEnv.get(envName) : undefined;
// We fallback to the max of the test durations across environments.
durationPredictions.set(testCase, envDuration ?? maxDuration);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid multiplying repeated timing attempts per test case

When a timings file comes from a suite using repeatEach, the report can contain multiple attempts for the same FK test/environment while the current list run also maps that FK id to multiple TestCases. Because the code sums all attempts per environment and then assigns that summed value to every mapped test case here, two 1s repeats are weighted as 4s instead of the 2s historical total, and larger repeat counts can make that test group dominate otherwise balanced shards.

Useful? React with 👍 / 👎.

@aslushnikov
aslushnikov merged commit fa2a038 into main Jul 1, 2026
9 of 10 checks passed
@aslushnikov
aslushnikov deleted the new-timigns branch July 1, 2026 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant