Skip to content

A job's times contain its steps, and a group iterates in queue order - #418

Merged
Paebbels merged 2 commits into
devfrom
claude/github-model-times
Sep 19, 2026
Merged

Paebbels merged 2 commits into
devfrom
claude/github-model-times

Conversation

@pytooling-claude

@pytooling-claude pytooling-claude Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

Note

Comes out of the review of #403, where you asked three times whether a helper of the tracing reader belongs on the data model. It does - all three are facts about GitHub's data, not about tracing - so they move here, and #403 is rebased onto this and loses them.

pyTooling.Tracing.CI.GitHub was computing two things the model can answer itself: the order a group's contents were queued in, and the times a job's timespans have to span. Both would have to be recomputed by every other consumer of the model - a renderer, a report, a second reader - and both are things GitHub's payloads say, not things tracing needs.

Changes

  • ⚠️ A job's times contain its steps. GitHub reports a job's times and its steps' times independently and in whole seconds, so a step is sometimes reported as starting before, or completing after, the job holding it:

    job   "Build"     started 10:01:10   completed 10:05:00
    step  "Checkout"  started 10:01:05   completed 10:05:20     <- outside its job
    

    Job.CreatedAt, Job.StartedAt and Job.CompletedAt report the widened times now. The job is the timespan that stretches, because the step really did run when it says it did - the alternative, clamping the step, throws away a fact to keep another one.

    A group's times follow, because JobGroup and Workflow aggregate the jobs' times, so nothing else changes to make a tree consistent. A job that hasn't completed still reports no completion, however far its steps got.

  • ⚠️ A group's times span what it holds. JobGroup.CreatedAt, StartedAt and CompletedAt aggregate over what the group holds - its jobs, and for a Workflow the matrices and called workflows below it as well - computed once over iter(self). Workflow needed three overrides and 77 lines of hand-written aggregation to say that, and has none.

    A Pipeline is the one group reporting times of its own, so it is the one with two sets: ContentsCreatedAt, ContentsStartedAt and ContentsCompletedAt span what the run holds, beside the run's own times. They differ, because a job may be queued before the run reports itself created - which is exactly how a trace knows it has to widen.

  • ⚠️ A group iterates what it holds in the order it was queued. JobGroup.__iter__ yielded the jobs in GitHub's listing order and Workflow.__iter__ yielded jobs, then matrices, then called workflows - so a called workflow whose jobs ran first still came last. Both order by CreatedAt now, jobs and nested groups alike.

    The sort is stable, so elements reporting no time keep the order GitHub listed them in, and they sort behind everything that reports one.

Unit Tests

  • tests/unit/CI/GitHub.py gains two classes, 9 testcases:
    • Times - a step starting before its job, a step completing after it, a job created after its first step started, a job whose steps are consistent (nothing widens), a running job whose step completed (no completion), and a group covering the widened times.
    • Ordering - jobs ordered by queue time, a called workflow taking its first job's place rather than a place behind every job, and an element without a time sorting last while keeping GitHub's order.

Documentation

  • doc/CI/GitHub.rst states both rules where it already explains that neither a called workflow nor a matrix reports times of its own.
  • doc/News.rst lists them in the pyTooling.CI block.

Related Issues and Pull-Requests

@pytooling-claude pytooling-claude Bot added CI: GitHub GitHub Actions / Workflows Documentation Improvements or additions to documentation Enhancement New feature or request Unit Tests labels Sep 19, 2026
@codacy-production

codacy-production Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 1 minor

Alerts:
⚠ 1 issue (≤ 0 issues of at least minor severity)

Results:
1 new issue

Category Results
Documentation 1 minor

View in Codacy

🟢 Metrics 18 complexity · 0 duplication

Metric Results
Complexity 18
Duplication 0

View in Codacy

🟢 Coverage 97.92% diff coverage · +0.05% coverage variation

Metric Results
Coverage variation ✅ +0.05% coverage variation
Diff coverage ✅ 97.92% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (354928f) 14013 11995 85.60%
Head commit (c92f6b1) 14014 (+1) 12003 (+8) 85.65% (+0.05%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#418) 48 47 97.92%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Comment thread pyTooling/CI/GitHub.py Resolved
Comment thread pyTooling/CI/GitHub.py Resolved
Comment thread pyTooling/CI/GitHub.py Resolved
Review of pull-request #403 asked three times whether a helper of the
tracing reader belongs on the data model. It does: all three are facts
about GitHub's data, not about tracing, and every other consumer of the
model would have to recompute them.

* **A job's times contain its steps.** GitHub reports a job's times and
  its steps' times independently and in whole seconds, so a step is
  sometimes reported as starting before, or completing after, the job
  holding it. The job is the timespan that stretches - the step really
  did run when it says it did - so 'Job.CreatedAt', 'StartedAt' and
  'CompletedAt' report the widened times. A job that hasn't completed
  still reports no completion, however far its steps got.
* **A group iterates what it holds in the order it was queued**, jobs and
  nested groups alike, instead of jobs first and called workflows last.
  So a called workflow takes the place its first job was queued at. The
  sort is stable, so elements reporting no time keep the order GitHub
  listed them in. A flavour says what it holds in '_Contents'; the
  ordering is written once, in 'JobGroup.__iter__'.
* **A group's times span what it holds**, so 'Workflow' loses the three
  overrides that aggregated jobs, matrices and called workflows by hand.
  A 'Pipeline' is the one group reporting times of its own, so it is the
  one with two sets: 'Contents{Created,Started,Completed}At' beside the
  run's own times. They differ, because a job may be queued before the
  run reports itself created.

Twelve testcases: a step starting before and completing after its job, a
job created after its first step started, a job whose steps are
consistent, a running job whose step completed, a group covering the
widened times, a run keeping its own times beside its contents', a
workflow having only the one set, a group holding a running element, and
the three ordering cases.

Co-Authored-By: Patrick Lehmann <Paebbels@gmail.com>
@Paebbels
Paebbels force-pushed the claude/github-model-times branch from ec0611c to 82ad1be Compare September 19, 2026 22:59
Comment thread pyTooling/CI/GitHub.py Resolved
Comment thread pyTooling/CI/GitHub.py Resolved
Comment thread pyTooling/CI/GitHub.py Resolved
Co-authored-by: Patrick Lehmann <Paebbels@gmail.com>
@Paebbels
Paebbels merged commit 3680e03 into dev Sep 19, 2026
6 of 7 checks passed
@Paebbels
Paebbels deleted the claude/github-model-times branch September 19, 2026 23:13
@pytooling-claude pytooling-claude Bot mentioned this pull request Sep 19, 2026
@pytooling-claude pytooling-claude Bot added this to the v10.0 milestone Sep 19, 2026
This was referenced Oct 12, 2026
This was referenced Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI: GitHub GitHub Actions / Workflows Documentation Improvements or additions to documentation Enhancement New feature or request Unit Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants