Skip to content

Commit 2e6797a

Browse files
committed
feat: create benchmark worflow and write to summaryy
1 parent dd0a13a commit 2e6797a

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
lines changed

.github/workflows/benchmark.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Benchmark Hooks
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
benchmark:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout code
11+
uses: actions/checkout@v2
12+
13+
- name: Set up Python
14+
uses: actions/setup-python@v2
15+
with:
16+
python-version: '3.8'
17+
18+
- name: Install dependencies
19+
run: |
20+
python -m pip install --upgrade pip
21+
pip install pre-commit
22+
23+
- name: Run benchmarks
24+
run: |
25+
python testing/benchmark_hooks.py

.pre-commit-config.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ repos:
99
- id: check-yaml
1010
- id: check-toml
1111
- id: requirements-txt-fixer
12-
- repo: https://github.com/asottile/pyupgrade
13-
rev: v3.20.0
14-
hooks:
15-
- id: pyupgrade
1612
- repo: https://github.com/astral-sh/ruff-pre-commit
1713
rev: v0.12.11
1814
hooks:

testing/benchmark_hooks.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- Target files: testing/main.c (or adjust as needed)
1414
"""
1515

16+
import os
1617
import subprocess
1718
import time
1819
import statistics
@@ -131,6 +132,17 @@ def report(results):
131132
f.write(line + "\n")
132133
print(f"\nResults saved to {RESULTS_FILE}")
133134

135+
# Write to GitHub Actions summary if available
136+
summary_path = os.environ.get("GITHUB_STEP_SUMMARY")
137+
if summary_path:
138+
with open(summary_path, "a") as f:
139+
f.write("## Benchmark Results\n\n")
140+
f.write(header_row + "\n")
141+
f.write("-+-".join("-" * w for w in col_widths) + "\n")
142+
for line in lines:
143+
f.write(line + "\n")
144+
f.write("\n")
145+
134146

135147
def main():
136148
git_clone()

0 commit comments

Comments
 (0)