Skip to content

add weekly test timings refresh workflow#1587

Open
saishreeeee wants to merge 7 commits into
databricks:mainfrom
saishreeeee:PECOBLR-3574
Open

add weekly test timings refresh workflow#1587
saishreeeee wants to merge 7 commits into
databricks:mainfrom
saishreeeee:PECOBLR-3574

Conversation

@saishreeeee

@saishreeeee saishreeeee commented Jul 13, 2026

Copy link
Copy Markdown

Resolves #

Description

Automates the weekly refresh of .github/test_timings.json so integration shard balancing doesn't drift stale. Adds a scheduled Refresh Test Timings workflow that regenerates timings from the last few distinct-SHA green integration runs and opens a human-reviewed PR (never auto-merged) when timings change.

The merge decision lives in the tested regenerate_timings.py, not in workflow YAML, and is per test file: new files are added, existing files are rewritten only when they move >10% (keeps run-to-run noise out), and a >60% move on a non-trivial file is flagged for manual review instead of auto-opening a PR. Per-file means the logic never needs to know shard counts.

Checklist

  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
    Ran it locally end-to-end against the live repo:

python scripts/regenerate_timings.py --num-runs 3
--output /tmp/new_timings.json --old .github/test_timings.json --drift-out /tmp/drift.json

Caught and fixed 3 issues:

  1. Crashed on artifact-less runs — scheduled runs with no PR targets upload zero test-log artifacts. Discovery now only picks runs with non-expired artifacts; download soft-skips a run with none.
  2. SHA-dedup dropped the usable run — an artifact-less newer run shadowed an older sibling with the same SHA that had artifacts. Now a SHA is marked "seen" only once a run is accepted.
  3. Manual-review false positive — test_grants.py (~0.007s) tripped the >60% flag on a 38ms swing. Added a 2s floor so a big % on a sub-second file isn't flagged.
    Note: only 1 run is currently within the 7-day retention window, so it aggregated a median-of-1 and drift looked large; with ≥3 runs weekly this stabilizes.
  • I have updated the CHANGELOG.md and added information about my change to the "dbt-databricks next" section.
  • [Optional] I have run /dbt-databricks-pr-ready (AI agent skill in .claude/skills/) and addressed its merge-readiness feedback

@saishreeeee saishreeeee marked this pull request as ready for review July 14, 2026 05:15

@sd-db sd-db left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Have added some comments. Additionally please look to run the workflow locally to confirm it is working as expected. One issue I feel in the overall design is that the 10% drift check should probably be at a test file level and not a profile level. Ideally I feel 1.) for new tests files add the new value 2.) for existing test files only update if delta > 10%

Agree on the fact that if delta is ever > 60% we should raise for manual review

Comment thread .github/ISSUE_TEMPLATE/release.md Outdated
Comment thread .github/workflows/integration.yml Outdated
Comment thread scripts/shard_assign.py Outdated
Comment thread scripts/regenerate_timings.py Outdated
def total_wall_by_profile(doc: dict[str, dict[str, float]]) -> dict[str, float]:
"""Total per-profile wall seconds (sum of every file's time).

This is the drift signal the weekly refresh workflow gates on. Crucially it

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: make the comment terse

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We have repeated the same info multiple times on the timings being independent of shard count. We should follow DRY and keep this in a single place

# 1. Runs scripts/regenerate_timings.py to rebuild timings from the last few
# distinct-SHA green integration.yml runs (median per-file wall time), and
# in the same tested script computes per-profile total-wall drift vs the
# current file. Total wall time is independent of shard count, so the drift

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit:

#     decision never duplicates integration.yml's (dynamically computed) shard
#     counts — a manual regen gets the identical numbers.

No need add detailed info here in the comments

Comment thread scripts/regenerate_timings.py Outdated
) -> dict[str, float]:
"""Per-profile percent change in total wall time from old to new timings.

Measured as an absolute percentage (direction-agnostic — a human reviews

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: no need for the added explanation here. Also adding a new profile is a very very rare case

Comment thread .github/workflows/refresh-test-timings.yml Outdated
required: false
default: "3"
type: string
force:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we can remove this flag, if we want to force a PR we can do this manually

# instead of opening a PR with potentially bad data.
# 3. PRs are never auto-merged — bad timings degrade balancing silently, so a
# human always reviews the before/after numbers in the PR body.
name: Refresh Test Timings

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We need to ensure that this can only run on main. We should not open PRs/refresh timings on branch code

This is the automatable, all-profiles-at-once front end to
`refresh_timings.py` (which aggregates one profile from one run's junit XMLs).
It discovers recent green `integration.yml` runs, downloads every profile's
per-shard junit artifacts, and writes the **median** per-file wall time across

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's look to add tests

@github-actions

Copy link
Copy Markdown

Coverage report

This PR does not seem to contain any modification to coverable code.

@saishreeeee saishreeeee requested a review from sd-db July 15, 2026 08:53
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.

2 participants