-
Notifications
You must be signed in to change notification settings - Fork 32
107 lines (93 loc) · 3.53 KB
/
asv-benchmarking-pr.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
name: ASV Benchmarking (PR)
on:
pull_request:
types: [opened, reopened, synchronize, labeled]
workflow_dispatch:
jobs:
benchmark:
if: ${{ contains(github.event.pull_request.labels.*.name, 'run-benchmark') && github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }}
name: Linux
runs-on: ubuntu-latest
env:
ASV_DIR: "./benchmarks"
CONDA_ENV_FILE: ci/environment.yml
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Conda environment
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ${{env.CONDA_ENV_FILE}}
cache-environment: true
environment-name: uxarray_build
cache-environment-key: "${{runner.os}}-${{runner.arch}}-py${{env.PYTHON_VERSION}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}-benchmark"
create-args: >-
asv
build
mamba
- name: Run Benchmarks
shell: bash -l {0}
id: benchmark
run: |
set -x
# ID this runner
asv machine --yes
echo "Baseline: ${{ github.event.pull_request.base.sha }} (${{ github.event.pull_request.base.label }})"
echo "Contender: ${GITHUB_SHA} (${{ github.event.pull_request.head.label }})"
# Run benchmarks for current commit against base
ASV_OPTIONS="--split --show-stderr"
asv continuous $ASV_OPTIONS ${{ github.event.pull_request.base.sha }} ${GITHUB_SHA}
# Save compare results
asv compare --split ${{ github.event.pull_request.base.sha }} ${GITHUB_SHA} > asv_compare_results.txt
working-directory: ${{ env.ASV_DIR }}
- uses: actions/upload-artifact@v4
if: always()
with:
name: asv-benchmark-results-${{ runner.os }}
path: |
${{ env.ASV_DIR }}/results
${{ env.ASV_DIR }}/asv_compare_results.txt
- name: Post or update result comment
id: comment
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const compareResults = fs.readFileSync('${{ env.ASV_DIR }}/asv_compare_results.txt', 'utf8');
const { owner, repo } = context.repo;
const issue_number = context.issue.number;
// Customize the comment content with your action results
const newComment = `
## ASV Benchmarking
<details>
<summary>Benchmark Comparison Results</summary>
${compareResults}
</details>
`;
// Fetch existing comments on the PR
const { data: comments } = await github.rest.issues.listComments({
owner,
repo,
issue_number,
});
// Find if there is an existing comment by this action
const botComment = comments.find(comment => comment.user.login === 'github-actions[bot]');
if (botComment) {
// Update the existing comment
await github.rest.issues.updateComment({
owner,
repo,
comment_id: botComment.id,
body: newComment,
});
} else {
// Create a new comment
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body: newComment,
});
}