Skip to content

Commit 8f79c0b

Browse files
authored
Merge pull request #210 from octoenergy/start-storing-benchmarks-data
Start storing benchmarks data
2 parents d774727 + 28923e1 commit 8f79c0b

File tree

2 files changed

+121
-0
lines changed

2 files changed

+121
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Collect benchmarks
2+
3+
on:
4+
workflow_run:
5+
workflows: [ "Run benchmarks main" ]
6+
types:
7+
- completed
8+
9+
# `concurrency` used to ensure that only one instance of this workflow runs at one time.
10+
# This is important since concurrent workflows would operate on the same files.
11+
concurrency:
12+
group: ${{ github.workflow }}
13+
14+
jobs:
15+
collect_benchmarks:
16+
name: Collect benchmarks
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout benchmarks-data branch
20+
uses: actions/checkout@v4
21+
with:
22+
ref: benchmarks-data
23+
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v5
26+
27+
- name: Collect benchmarks
28+
run: uv run scripts/collect_benchmarks.py -i 'uncollected/*.csv' -o benchmarks.csv
29+
30+
- name: Remove now collected benchmarks
31+
run: rm uncollected/*.csv
32+
33+
- name: Add and commit
34+
run: |
35+
git config user.name github-actions
36+
git config user.email [email protected]
37+
38+
git add --all
39+
git commit -m "Collect benchmarks"
40+
41+
# Retry below incase another workflow pushed to the benchmarks-data branch since we checked it out.
42+
# Unlikely but technically possible...
43+
# There won't be a merge conflict since this workflow is the only workflow touching benchmarks.csv
44+
# and this workflow uses `concurrency`.
45+
scripts/push_with_retry.sh 5
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Run benchmarks main
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
run_benchmarks:
10+
name: Run benchmarks
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout main branch
14+
uses: actions/checkout@v4
15+
with:
16+
ref: main
17+
18+
- name: Setup python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: '3.9'
22+
23+
- name: Install dependencies
24+
run: make install
25+
26+
- name: Run benchmarks
27+
run: pytest --benchmark-only --benchmark-json benchmarks.json
28+
29+
- name: Upload artifact - benchmarks JSON
30+
uses: actions/upload-artifact@v4
31+
with:
32+
name: benchmarks_json
33+
path: benchmarks.json
34+
# Short retention. Only needed short term to share with the `extract_benchmarks` job.
35+
retention-days: 1
36+
37+
extract_benchmarks:
38+
name: Extract benchmarks
39+
runs-on: ubuntu-latest
40+
needs: [ run_benchmarks ]
41+
steps:
42+
- name: Checkout benchmarks-data branch
43+
uses: actions/checkout@v4
44+
with:
45+
ref: benchmarks-data
46+
47+
- name: Install uv
48+
uses: astral-sh/setup-uv@v5
49+
50+
- name: Download artifact - benchmarks JSON
51+
uses: actions/download-artifact@v4
52+
with:
53+
name: benchmarks_json
54+
55+
- name: Extract benchmarks
56+
run: |
57+
uv run scripts/extract_benchmarks.py \
58+
-i benchmarks.json \
59+
-o "uncollected/$(uuidgen).csv" \
60+
-t ubuntu-latest
61+
62+
- name: Remove benchmarks JSON
63+
run: rm benchmarks.json
64+
65+
- name: Add and commit benchmarks data
66+
run: |
67+
git config user.name github-actions
68+
git config user.email [email protected]
69+
70+
git add --all
71+
git commit -m "Add uncollected benchmarks"
72+
73+
# Retry below incase another workflow pushed to the benchmarks-data branch since we checked it out.
74+
# Unlikely but technically possible...
75+
# There won't be a merge conflict since we used a UUID as the file name.
76+
scripts/push_with_retry.sh 5

0 commit comments

Comments
 (0)