Skip to content

feat: draw retry attempts on the thread they record - #351

Merged
Ma11hewThomas merged 1 commit into
ctrf-io:mainfrom
alexshamrai:feature/timeline-attempt-thread
Nov 27, 2026
Merged

Ma11hewThomas merged 1 commit into
ctrf-io:mainfrom
alexshamrai:feature/timeline-attempt-thread

Conversation

@alexshamrai

@alexshamrai alexshamrai commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Closes #334

CTRF 0.3.0 adds an optional threadId to retryAttempts entries (ctrf-io/ctrf#86), so each earlier attempt of a retried test can record the thread or worker that ran it. The timeline now draws each run before a retry on that thread, instead of guessing.

What changes

  • Attempts that record a thread are drawn on it, laid out with that thread's final results. If one overlaps another test there, the thread is split into rows, as final results already are. The spec doesn't promise one test at a time per worker.
  • Attempts that record no thread keep today's placement: on their test's thread where it was free, otherwise in the "Runs before a retry" row. That row and its note now cover only these attempts.
  • Earlier results of a test that ran again (several runs in one report) always recorded their thread, so they're laid out the same way instead of being moved to "Runs before a retry".
  • A thread that only ran failed attempts, such as a worker replaced after a failure, gets its own row and counts as a thread.
  • Reports without attempt threadId render exactly as before. For the current sample report, and for the second example below without the field, main and this branch produce identical timeline data.

Examples

Both charts in each example come from the same CTRF report, rendered by the timeline code on main and on this branch. Numbers on bars point to the test timings table, which is left out here.

🟩 passed · 🟥 failed · 🟨 failed, then retried (dashed) · ♦️ failed too fast for a bar · 0:00 = 2026-01-01 08:00:00.000 UTC

The self-test sample

In ctrf-reports/timeline/ctrf-report.json, "should reset the password by email" failed on worker-3, then passed on worker-0. This PR adds "threadId": "worker-3" to its failed attempt and moves the sample to CTRF 0.3.0.

Before: the failed attempt (yellow, dashed) is drawn in a gap on worker-0, which then reads 99% busy.

---
config:
  gantt:
    displayMode: compact
    useWidth: 1000
    leftPadding: 79
    rightPadding: 40
  themeCSS: ".taskText.critText0,.taskText.critText1,.taskText.critText2,.taskText.critText3{fill:#ffffff !important}.active0,.active1,.active2,.active3{stroke-dasharray:4 2}"
  themeVariables:
    taskBkgColor: '#4ac26b'
    taskBorderColor: '#1a7f37'
    critBkgColor: '#cf222e'
    critBorderColor: '#82071e'
    activeTaskBkgColor: '#eac54f'
    activeTaskBorderColor: '#9a6700'
    doneTaskBkgColor: '#afb8c1'
    doneTaskBorderColor: '#6e7781'
    taskTextColor: '#1f2328'
    taskTextDarkColor: '#1f2328'
    sectionBkgColor: '#8c959f'
    sectionBkgColor2: '#8c959f'
    vertLineColor: '#8c959f'
---
gantt
accTitle: Test execution timeline
accDescr: 16 tests and 1 run before a retry on 4 threads over 34.2s, 2 failed. The slowest test is should generate the sales report (26.0s on worker-2). The last to finish is should export orders as CSV on worker-0, at 0:34.200.
dateFormat D HH:mm:ss.SSS
axisFormat %-M:%S
todayMarker off
section ​worker-0
​ :16 00:00:00.000, 0ms
​should log in w… :16 00:00:00.000, 4200ms
​should lock the account… :16 00:00:04.300, 6100ms
​1 :active, 16 00:00:10.500, 2600ms
​2 :16 00:00:13.200, 1900ms
​should show the order history :16 00:00:15.200, 15800ms
​should exp… :16 00:00:31.100, 3100ms
​ :16 00:00:34.200, 0ms
section ​worker-1
​should register a new user :16 00:00:00.000, 9434ms
​ :crit, milestone, 16 00:00:09.900, 0ms
​should apply a dis… :16 00:00:10.366, 4784ms
​should pay with a saved card :crit, 16 00:00:15.300, 7700ms
​3 :16 00:00:23.100, 2400ms
section ​worker-2
​4 :16 00:00:00.000, 1200ms
​5 :16 00:00:01.300, 800ms
​should generate the sales report :16 00:00:02.200, 26000ms
section ​worker-3
​should sear… :16 00:00:00.000, 3400ms
​should fil… :16 00:00:03.500, 2900ms
​6 :16 00:00:06.500, 2100ms
Loading

After: the attempt is on worker-3, after "should sort by rating", and worker-0 shows its real idle time.

---
config:
  gantt:
    displayMode: compact
    useWidth: 1000
    leftPadding: 79
    rightPadding: 40
  themeCSS: ".taskText.critText0,.taskText.critText1,.taskText.critText2,.taskText.critText3{fill:#ffffff !important}.active0,.active1,.active2,.active3{stroke-dasharray:4 2}"
  themeVariables:
    taskBkgColor: '#4ac26b'
    taskBorderColor: '#1a7f37'
    critBkgColor: '#cf222e'
    critBorderColor: '#82071e'
    activeTaskBkgColor: '#eac54f'
    activeTaskBorderColor: '#9a6700'
    doneTaskBkgColor: '#afb8c1'
    doneTaskBorderColor: '#6e7781'
    taskTextColor: '#1f2328'
    taskTextDarkColor: '#1f2328'
    sectionBkgColor: '#8c959f'
    sectionBkgColor2: '#8c959f'
    vertLineColor: '#8c959f'
---
gantt
accTitle: Test execution timeline
accDescr: 16 tests and 1 run before a retry on 4 threads over 34.2s, 2 failed. The slowest test is should generate the sales report (26.0s on worker-2). The last to finish is should export orders as CSV on worker-0, at 0:34.200.
dateFormat D HH:mm:ss.SSS
axisFormat %-M:%S
todayMarker off
section ​worker-0
​ :16 00:00:00.000, 0ms
​should log in w… :16 00:00:00.000, 4200ms
​should lock the account… :16 00:00:04.300, 6100ms
​1 :16 00:00:13.200, 1900ms
​should show the order history :16 00:00:15.200, 15800ms
​should exp… :16 00:00:31.100, 3100ms
​ :16 00:00:34.200, 0ms
section ​worker-1
​should register a new user :16 00:00:00.000, 9434ms
​ :crit, milestone, 16 00:00:09.900, 0ms
​should apply a dis… :16 00:00:10.366, 4784ms
​should pay with a saved card :crit, 16 00:00:15.300, 7700ms
​2 :16 00:00:23.100, 2400ms
section ​worker-2
​3 :16 00:00:00.000, 1200ms
​4 :16 00:00:01.300, 800ms
​should generate the sales report :16 00:00:02.200, 26000ms
section ​worker-3
​should sear… :16 00:00:00.000, 3400ms
​should fil… :16 00:00:03.500, 2900ms
​5 :16 00:00:06.500, 2100ms
​6 :active, 16 00:00:10.500, 2600ms
Loading
Thread Runs before a retry Idle Utilization
worker-0 1 → 0 500ms → 3.1s 99% → 91%
worker-3 0 → 1 25.8s → 23.2s 25% → 32%

Retries that moved to another worker

"should pay with a saved card" failed on worker-2 right after "should empty the cart", then passed on worker-0. "should suggest products while typing" failed on worker-3, which was replaced by worker-4, where the retry passed.

Before: the saved-card attempt overlaps tests on worker-0, so it gets a row of its own, and worker-2 looks idle after "should empty the cart". The suggestions attempt is drawn on worker-4 before that worker started. The report adds this note:

1 run before a retry overlaps other tests on its thread (such runs do not record where they ran), so it is shown in a lane of its own.

---
config:
  gantt:
    displayMode: compact
    useWidth: 1000
    leftPadding: 142
    rightPadding: 40
  themeCSS: ".taskText.critText0,.taskText.critText1,.taskText.critText2,.taskText.critText3{fill:#ffffff !important}.active0,.active1,.active2,.active3{stroke-dasharray:4 2}"
  themeVariables:
    taskBkgColor: '#4ac26b'
    taskBorderColor: '#1a7f37'
    critBkgColor: '#cf222e'
    critBorderColor: '#82071e'
    activeTaskBkgColor: '#eac54f'
    activeTaskBorderColor: '#9a6700'
    doneTaskBkgColor: '#afb8c1'
    doneTaskBorderColor: '#6e7781'
    taskTextColor: '#1f2328'
    taskTextDarkColor: '#1f2328'
    sectionBkgColor: '#8c959f'
    sectionBkgColor2: '#8c959f'
    vertLineColor: '#8c959f'
---
gantt
accTitle: Test execution timeline
accDescr: 15 tests and 2 runs before a retry on 5 threads and 1 more lane over 14.3s, 0 failed. The slowest test is should register a new user (6.0s on worker-1). The last to finish is should send the receipt on worker-4, at 0:14.300.
dateFormat D HH:mm:ss.SSS
axisFormat %-M:%S
todayMarker off
section ​worker-0
​ :16 00:00:00.000, 0ms
​should log in with valid credentials :16 00:00:00.000, 4200ms
​should update the profile :16 00:00:04.300, 4700ms
​should pay with a saved card :16 00:00:09.100, 3500ms
​1 :16 00:00:12.700, 1300ms
​ :16 00:00:14.300, 0ms
section ​worker-1
​should register a new user :16 00:00:00.000, 6000ms
​should search by product name :16 00:00:06.100, 3400ms
​should filter by price :16 00:00:09.600, 2400ms
​should sort by rat… :16 00:00:12.100, 2100ms
section ​worker-2
​should empty the cart :16 00:00:00.000, 2900ms
​should keep the cart after… :16 00:00:07.500, 2900ms
​should apply a discount code :16 00:00:10.500, 3600ms
section ​worker-3
​should show the order history :16 00:00:00.000, 4900ms
section ​worker-4
​should sugg… :active, 16 00:00:05.000, 1500ms
​2 :16 00:00:06.700, 1300ms
​should export orders as CSV :16 00:00:08.100, 3700ms
​should send the rece… :16 00:00:11.900, 2400ms
section ​Runs before a retry
​should pay with a saved card (attempt 1) :active, 16 00:00:02.950, 4450ms
Loading

After: both attempts are on the workers that ran them, and the extra row and its note are gone. The failed saved-card attempt now sits next to the test that ran just before it on the same worker.

---
config:
  gantt:
    displayMode: compact
    useWidth: 1000
    leftPadding: 79
    rightPadding: 40
  themeCSS: ".taskText.critText0,.taskText.critText1,.taskText.critText2,.taskText.critText3{fill:#ffffff !important}.active0,.active1,.active2,.active3{stroke-dasharray:4 2}"
  themeVariables:
    taskBkgColor: '#4ac26b'
    taskBorderColor: '#1a7f37'
    critBkgColor: '#cf222e'
    critBorderColor: '#82071e'
    activeTaskBkgColor: '#eac54f'
    activeTaskBorderColor: '#9a6700'
    doneTaskBkgColor: '#afb8c1'
    doneTaskBorderColor: '#6e7781'
    taskTextColor: '#1f2328'
    taskTextDarkColor: '#1f2328'
    sectionBkgColor: '#8c959f'
    sectionBkgColor2: '#8c959f'
    vertLineColor: '#8c959f'
---
gantt
accTitle: Test execution timeline
accDescr: 15 tests and 2 runs before a retry on 5 threads over 14.3s, 0 failed. The slowest test is should register a new user (6.0s on worker-1). The last to finish is should send the receipt on worker-4, at 0:14.300.
dateFormat D HH:mm:ss.SSS
axisFormat %-M:%S
todayMarker off
section ​worker-0
​ :16 00:00:00.000, 0ms
​should log in with valid credentials :16 00:00:00.000, 4200ms
​should update the profile :16 00:00:04.300, 4700ms
​should pay with a saved card :16 00:00:09.100, 3500ms
​should log… :16 00:00:12.700, 1300ms
​ :16 00:00:14.300, 0ms
section ​worker-1
​should register a new user :16 00:00:00.000, 6000ms
​should search by product name :16 00:00:06.100, 3400ms
​should filter by price :16 00:00:09.600, 2400ms
​should sort by rating :16 00:00:12.100, 2100ms
section ​worker-2
​should empty the cart :16 00:00:00.000, 2900ms
​should pay with a saved card (attempt 1) :active, 16 00:00:02.950, 4450ms
​should keep the cart after r… :16 00:00:07.500, 2900ms
​should apply a discount code :16 00:00:10.500, 3600ms
section ​worker-3
​should show the order history :16 00:00:00.000, 4900ms
​should sugge… :active, 16 00:00:05.000, 1500ms
section ​worker-4
​should sug… :16 00:00:06.700, 1300ms
​should export orders as CSV :16 00:00:08.100, 3700ms
​should send the receipt :16 00:00:11.900, 2400ms
Loading
Thread Runs before a retry Idle Utilization
worker-2 0 → 1 4.9s → 450ms 66% → 97%
worker-3 0 → 1 9.4s → 7.9s 34% → 45%
worker-4 1 → 0 5.4s → 6.9s 62% → 52%
Runs before a retry (row removed) 1 → – 9.8s → – 31% → –

How to review

  • src/ctrf/timeline/collect.ts:
    • readTests reads attempt.threadId, cleaned up like a test's.
    • collectTimeline marks attempts without one as inheritedThread.
    • arrange() lays out everything that records its thread together, and passes only inherited attempts to placeAttempts().
  • src/ctrf/timeline/types.ts: TimelineExecution.inheritedThread.
  • docs/report-showcase.md (the retries bullet) and the CHANGELOG under Unreleased.
  • dist/ is rebuilt, and differs from main's build only by this change.

Testing

  • 7 new tests in __tests__/ctrf/timeline.test.ts ("runs before a retry that record their thread"), each written first and seen failing. They cover:
    • an attempt drawn on its recorded thread, not in a gap on its test's thread;
    • a thread that only ran attempts;
    • splitting a thread on overlap;
    • attempts with and without a thread in one test;
    • cleaning up thread values (spaces, numbers, blanks);
    • earlier-run results staying on their thread;
    • the note counting only attempts without a thread.
  • npm test: 358 passed. npm run build:check and Biome are clean.
  • The updated sample validates as CTRF 0.3.0 with ctrf 0.6.0. The action self-test's timeline job renders it.

CTRF 0.3.0 lets a retryAttempts entry record the thread or worker that
ran it. The timeline now draws each run before a retry on that thread,
packed with the thread's final results, so a thread whose tests overlap
is split into lanes as for final results. Runs that record no thread
keep today's placement on their test's thread, and only they can end up
in the "Runs before a retry" lane. Earlier results of a test that ran
again record their thread too and are packed the same way.

The self-test sample moves to CTRF 0.3.0 and records the worker of its
failed attempt.

Closes ctrf-io#334
@alexshamrai

Copy link
Copy Markdown
Contributor Author

@Ma11hewThomas this is the follow-up to ctrf-io/ctrf#86: the timeline now uses the attempt threadId from CTRF 0.3.0. Could you please take a look when you have time? Thanks in advance!

@Ma11hewThomas
Ma11hewThomas merged commit dcad93c into ctrf-io:main Nov 27, 2026
23 checks passed
@Ma11hewThomas

Copy link
Copy Markdown
Contributor

Thank you again! To be included in next release

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.

Timeline: draw earlier retry attempts on the thread that ran them (retryAttempts[].threadId)

2 participants