-
Notifications
You must be signed in to change notification settings - Fork 546
ci: add test duration tracking workflow #4290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
hsuan-lun-chiang
wants to merge
7
commits into
main
Choose a base branch
from
ci/test-duration-tracking
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+138
−0
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4473112
Phase 1: Extract test durations to JUnit XML
hsuan-lun-chiang b32cb5a
Phase 2 & 3: Add workflow and script to track test performance regres…
hsuan-lun-chiang 92f5b6b
Refactor tracking job directly into main CI pipeline so PRs can test …
hsuan-lun-chiang 3898548
Use actions/cache for benchmark data storage
hsuan-lun-chiang 390bb68
Updated CI Pipeline for GCS-backed Durations
hsuan-lun-chiang dec2070
ci: allow baseline upload to GCS bucket from any branch for testing
hsuan-lun-chiang ee796e8
ci: fix track_performance job permission by running in cloud-sdk cont…
hsuan-lun-chiang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -195,6 +195,7 @@ jobs: | |
| -v \ | ||
| -m "${FINAL_PYTEST_MARKER}" \ | ||
| --durations=0 \ | ||
| --junitxml=test-results-${INPUTS_DEVICE_TYPE}-${INPUTS_WORKER_GROUP}.xml \ | ||
| $PYTEST_COV_ARGS \ | ||
| $SPLIT_ARGS \ | ||
| ${INPUTS_PYTEST_EXTRA_ARGS} | ||
|
|
@@ -227,3 +228,10 @@ jobs: | |
| # If scheduled, upload to scheduled flag only. If PR, upload to regular flag only. | ||
| flags: ${{ inputs.is_scheduled_run == 'true' && 'scheduled' || 'regular' }} | ||
| verbose: true | ||
| - name: Upload Test Results XML | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: test-results-${{ inputs.device_type }}-${{ inputs.worker_group }} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should append For download, we should download files of the same run_id. Can we also add the expiration time of these temporary files, such as: |
||
| path: test-results-*.xml | ||
| if-no-files-found: ignore | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| import xml.etree.ElementTree as ET | ||
| import glob | ||
| import json | ||
| import sys | ||
| import os | ||
|
|
||
| def main(): | ||
| if len(sys.argv) < 3: | ||
| print("Usage: python parse_junit_to_benchmark.py <xml_dir> <output_json>") | ||
| sys.exit(1) | ||
|
|
||
| xml_dir = sys.argv[1] | ||
| output_json = sys.argv[2] | ||
|
|
||
| benchmarks = [] | ||
| total_times_by_device = {} | ||
|
|
||
| xml_files = glob.glob(os.path.join(xml_dir, "*.xml")) | ||
| for xml_file in xml_files: | ||
| basename = os.path.basename(xml_file) | ||
| # e.g., test-results-tpu-1.xml -> device = tpu | ||
| device = "unknown" | ||
| parts = basename.replace(".xml", "").split("-") | ||
| if len(parts) >= 3: | ||
| device = parts[2] | ||
|
|
||
| try: | ||
| tree = ET.parse(xml_file) | ||
| except Exception as e: | ||
| print(f"Error parsing {xml_file}: {e}") | ||
| continue | ||
|
|
||
| root = tree.getroot() | ||
|
|
||
| for testsuite in root.iter('testsuite'): | ||
| for testcase in testsuite.iter('testcase'): | ||
| name = testcase.get('name') | ||
| classname = testcase.get('classname') | ||
| time_val = float(testcase.get('time', 0.0)) | ||
|
|
||
| # Prefix with device to distinguish test times on different hardware | ||
| full_name = f"[{device.upper()}] {classname}::{name}" | ||
|
|
||
| benchmarks.append({ | ||
| "name": full_name, | ||
| "unit": "sec", | ||
| "value": time_val | ||
| }) | ||
|
|
||
| total_times_by_device[device] = total_times_by_device.get(device, 0.0) + time_val | ||
|
|
||
| for device, total_time in total_times_by_device.items(): | ||
| benchmarks.append({ | ||
| "name": f"Total {device.upper()} Test Suite Time", | ||
| "unit": "sec", | ||
| "value": total_time | ||
| }) | ||
|
|
||
| with open(output_json, "w") as f: | ||
| json.dump(benchmarks, f, indent=2) | ||
|
|
||
| print(f"Parsed {len(xml_files)} XML files and extracted {len(benchmarks)} duration metrics.") | ||
|
|
||
| if __name__ == "__main__": | ||
| main() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use gh-pages to store the benchmark data? github-action-benchmark can generate a index.html so we can see the interactive chart of the benchmark history.