-
-
Notifications
You must be signed in to change notification settings - Fork 405
197 lines (167 loc) · 6.42 KB
/
benchmarks.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
name: benchmarks
on:
push:
branches:
- master
pull_request_target:
branches:
- master
types:
- opened
- reopened
- synchronize
- labeled # benchmarks label required
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash -l {0}
jobs:
build:
if: github.repository_owner == 'tardis-sn' &&
(github.event_name == 'push' ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'pull_request_target' &&
contains(github.event.pull_request.labels.*.name, 'benchmarks')))
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
if: github.event_name != 'pull_request_target'
with:
fetch-depth: 0
- name: Checkout pull/${{ github.event.number }}
uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
fetch-depth: 0
if: github.event_name == 'pull_request_target'
- name: Restore Atom Data
uses: actions/cache/restore@v4
id: atom-data-restore
with:
path: benchmarks/data/kurucz_cd23_chianti_H_He.h5
key: atom-data
- name: Download Atom Data
if: steps.atom-data-restore.outputs.cache-hit != 'true'
run: |
REPO_URL="https://dev.azure.com/tardis-sn/TARDIS/_apis/git/repositories/tardis-refdata"
wget -q "$REPO_URL/items?path=atom_data/kurucz_cd23_chianti_H_He.h5&versionType=branch&version=master&resolveLfs=true" -O benchmarks/data/kurucz_cd23_chianti_H_He.h5
- name: Save Atom Data
uses: actions/cache/save@v4
if: ${{ steps.atom-data-restore.outputs.cache-hit != 'true' && always() || false }}
id: atom-data-cache-save
with:
path: benchmarks/data/kurucz_cd23_chianti_H_He.h5
key: atom-data
- name: Setup Mamba
uses: mamba-org/setup-micromamba@v1
with:
environment-name: benchmark
init-shell: >-
bash
create-args: >-
python
asv
mamba
- name: Install asv
run: pip install asv
- name: Accept all asv questions
run: asv machine --yes
- name: Run benchmarks for last 5 commits if not PR
if: github.event_name != 'pull_request_target'
run: |
git log -n 5 --pretty=format:"%H" >> tag_commits.txt
asv run HASHFILE:tag_commits.txt | tee asv-output.log
if grep -q failed asv-output.log; then
echo "Some benchmarks have failed!"
exit 1
fi
- name: Generate Graphs and HTML
if: github.event_name != 'pull_request_target'
run: asv publish
- name: Delete env files
if: github.event_name != 'pull_request_target'
run: rm -r .asv/env
- name: Push results to results repository
if: github.event_name != 'pull_request_target'
continue-on-error: true
uses: cpina/github-action-push-to-another-repository@main
env:
API_TOKEN_GITHUB: ${{ secrets.BOT_TOKEN }}
with:
source-directory: .asv
destination-github-username: tardis-sn
destination-repository-name: tardis-benchmarks
user-email: [email protected]
target-branch: main
target-directory: .asv
- name: Compare HEAD with master if PR
if: github.event_name == 'pull_request_target'
continue-on-error: true # TODO: step failed sporadically while testing
run: |
asv continuous ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | tee asv-cont-output.log
if grep -q failed asv-cont-output.log; then
echo "Some benchmarks have errors!"
exit 1
fi
- name: Compare Master and PR head
run: asv compare ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | tee asv-compare-output.log
- name: Compare Master and PR head but only show changed results
run: asv compare ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} --only-changed | tee asv-compare-changed-output.log
- name: Benchmarks compare output
id: asv_pr_vs_master
uses: juliangruber/[email protected]
with:
path: asv-compare-output.log
- name: Benchmarks compare only changed output
id: asv_pr_vs_master_changed
uses: juliangruber/[email protected]
with:
path: asv-compare-changed-output.log
- name: Find Comment
if: always() && github.event_name == 'pull_request_target'
uses: peter-evans/find-comment@v1
id: fc
with:
issue-number: ${{ github.event.number }}
body-includes: I ran benchmarks as you asked
- name: Post comment
if: github.event_name == 'pull_request_target'
uses: peter-evans/create-or-update-comment@v2
with:
token: ${{ secrets.BOT_TOKEN }}
issue-number: ${{ github.event.number }}
comment-id: ${{ steps.fc.outputs.comment-id }}
edit-mode: replace
body: |
*\*beep\* \*bop\**
Hi human,
I ran benchmarks as you asked comparing master (${{ github.event.pull_request.base.sha }}) and the latest commit (${{ github.event.pull_request.head.sha }}).
Here are the logs produced by ASV.
Results can also be downloaded as artifacts [**here**](${{ env.URL }}).
Significantly changed benchmarks:
<details>
```diff
${{ steps.asv_pr_vs_master_changed.outputs.content }}
```
</details>
All benchmarks:
<details>
```diff
${{ steps.asv_pr_vs_master.outputs.content }}
```
</details>
env:
URL: https://github.com/${{ github.repository_owner }}/${{ github.event.repository.name }}/actions/runs/${{ github.run_id }}?check_suite_focus=true
- name: Save results artifact
uses: actions/upload-artifact@v4
if: always()
with:
name: asv-benchmark-results-${{ runner.os }}
path: |
.asv/results
asv-cont-output.log
asv-compare-output.log
asv-compare-changed-output.log