Skip to content

Conversation

@TylerJang27
Copy link
Collaborator

@TylerJang27 TylerJang27 commented Jan 27, 2026

Adds started_at, finished_at, attempt_number, and label as test run-level information in the internal.bin file. We need the bazel information to be serialized because it is sometimes more accurate than the times reported by JUnit reporters. Leaving the conversion to be handled during ingestion, but it should be testCase.bazel_run_information?.started_at ?? testCase.started_at.

More info in thread

For a JUnit.xml like:

<testsuites>
<testsuite name="suite_name" timestamp="2026-01-13T04:48:08" tests="0" file="file_path" time="204.494" failures="1">
  <testcase name="case_name" time="0.000" classname="class_name">
      <failure message="failure_message" type="type_name" system_out="system_out" system_err="system_err">
  failure_text
    </failure>
  </testcase>
</testsuite>
</testsuites>

we end up with an internal.bin like:

{
  "test_results": [
    {
      "test_case_runs": [
        {
          "id": "",
          "name": "case_name",
          "classname": "class_name",
          "file": "file_path",
          "parent_name": "suite_name",
          "line": 25,
          "status": 1,
          "attempt_number": 0,
          "started_at": "2026-01-13T04:48:08.000Z",
          "finished_at": "2026-01-13T04:50:23.916Z",
          "status_output_message": "",
          "is_quarantined": false,
          "codeowners": [],
          "attempt_index": null,
          "line_number": {
            "number": 25
          },
          "test_output": null,
          "test_runner_information": {
            "BazelRunInformation": {
              "label": "//bazel_label",
              "attempt_number": 0,
              "started_at": "2026-01-13T04:50:22.996Z",
              "finished_at": "2026-01-13T04:50:24.011Z"
            }
          }
        },
...
]}]}

I also broke up bindings.rs because it was painfully long. I've called out the specific changes that I've made in that directory.

@trunk-io
Copy link

trunk-io bot commented Jan 27, 2026

😎 Merged successfully - details.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Unchanged, just moved

Only minor change is pub(crate) on the extra field

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Unchanged, just moved

All the testing that was in bindings.rs got relocated here for now

Comment on lines +17 to +32
struct TimestampWrapper {
datetime: chrono::DateTime<chrono::Utc>,
timestamp: i64,
timestamp_micros: i64,
}

impl From<prost_wkt_types::Timestamp> for TimestampWrapper {
fn from(value: prost_wkt_types::Timestamp) -> Self {
let datetime = chrono::DateTime::from(value.clone());
TimestampWrapper {
datetime,
timestamp: datetime.timestamp(),
timestamp_micros: datetime.timestamp_micros(),
}
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

new in order to commonize some of the date parsing

Comment on lines +59 to +64
let started_at = started_at.unwrap_or_default();
let started_at_wrapper = TimestampWrapper::from(started_at);
let time = (chrono::DateTime::from(finished_at.unwrap_or_default())
- started_at_wrapper.datetime)
.to_std()
.unwrap_or_default();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

tweaked/commonized

Comment on lines +157 to +174
bazel_run_information: match test_runner_information {
Some(proto::test_context::test_run::test_case_run::TestRunnerInformation::BazelRunInformation(
bazel_run_information,
)) => {
let started_at_wrapper = TimestampWrapper::from(bazel_run_information.started_at.unwrap_or_default());
let finished_at_wrapper = TimestampWrapper::from(bazel_run_information.finished_at.unwrap_or_default());

Some(BindingsBazelRunInformation {
label: bazel_run_information.label,
attempt_number: bazel_run_information.attempt_number,
started_at: Some(started_at_wrapper.timestamp),
started_at_micros: Some(started_at_wrapper.timestamp_micros),
finished_at: Some(finished_at_wrapper.timestamp),
finished_at_micros: Some(finished_at_wrapper.timestamp_micros),
})
},
_ => None,
},
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

new

Comment on lines +209 to +216
pub struct BindingsBazelRunInformation {
pub label: String,
pub attempt_number: i32,
pub started_at: Option<i64>,
pub started_at_micros: Option<i64>,
pub finished_at: Option<i64>,
pub finished_at_micros: Option<i64>,
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

new. Please advise on the typings for this, not sure what best practice is for timestamp stuff. I mainly was just cargo culting the prior timestamp stuff in each context

@codecov-commenter
Copy link

codecov-commenter commented Jan 27, 2026

Codecov Report

❌ Patch coverage is 89.71193% with 125 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.53%. Comparing base (1b4b82f) to head (529e44b).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
context/src/junit/bindings/test_case.rs 85.63% 54 Missing ⚠️
context/src/junit/bindings/report.rs 94.55% 29 Missing ⚠️
context/src/junit/bindings/suite.rs 82.53% 22 Missing ⚠️
context/src/junit/bindings/validation.rs 68.75% 20 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1006      +/-   ##
==========================================
+ Coverage   81.19%   81.53%   +0.34%     
==========================================
  Files          66       69       +3     
  Lines       14326    14468     +142     
==========================================
+ Hits        11632    11797     +165     
+ Misses       2694     2671      -23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@TylerJang27 TylerJang27 marked this pull request as ready for review January 27, 2026 22:42
@trunk-io
Copy link

trunk-io bot commented Jan 28, 2026

Static BadgeStatic BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

Co-authored-by: max-trunk <max@trunk.io>
Signed-off-by: Tyler Jang <tyler@trunk.io>
@trunk-staging-io
Copy link

trunk-staging-io bot commented Jan 29, 2026

Static BadgeStatic BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

@trunk-io trunk-io bot merged commit 45a1483 into main Jan 29, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants