Skip to content

Commit ba72f5e

Browse files
authored
CI: Add ASV Bot (#42911)
1 parent dfbebd7 commit ba72f5e

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

.github/workflows/asv-bot.yml

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: "ASV Bot"
2+
3+
on:
4+
issue_comment: # Pull requests are issues
5+
types:
6+
- created
7+
8+
env:
9+
ENV_FILE: environment.yml
10+
COMMENT: ${{github.event.comment.body}}
11+
12+
jobs:
13+
autotune:
14+
name: "Run benchmarks"
15+
# TODO: Support more benchmarking options later, against different branches, against self, etc
16+
if: startsWith(github.event.comment.body, '@github-actions benchmark')
17+
runs-on: ubuntu-latest
18+
defaults:
19+
run:
20+
shell: bash -l {0}
21+
22+
concurrency:
23+
# Set concurrency to prevent abuse(full runs are ~5.5 hours !!!)
24+
# each user can only run one concurrent benchmark bot at a time
25+
# We don't cancel in progress jobs, but if you want to benchmark multiple PRs, you're gonna have
26+
# to wait
27+
group: ${{ github.actor }}-asv
28+
cancel-in-progress: false
29+
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v2
33+
with:
34+
fetch-depth: 0
35+
36+
- name: Cache conda
37+
uses: actions/cache@v2
38+
with:
39+
path: ~/conda_pkgs_dir
40+
key: ${{ runner.os }}-conda-${{ hashFiles('${{ env.ENV_FILE }}') }}
41+
42+
# Although asv sets up its own env, deps are still needed
43+
# during discovery process
44+
- uses: conda-incubator/setup-miniconda@v2
45+
with:
46+
activate-environment: pandas-dev
47+
channel-priority: strict
48+
environment-file: ${{ env.ENV_FILE }}
49+
use-only-tar-bz2: true
50+
51+
- name: Run benchmarks
52+
id: bench
53+
continue-on-error: true # This is a fake failure, asv will exit code 1 for regressions
54+
run: |
55+
# extracting the regex, see https://stackoverflow.com/a/36798723
56+
REGEX=$(echo "$COMMENT" | sed -n "s/^.*-b\s*\(\S*\).*$/\1/p")
57+
cd asv_bench
58+
asv check -E existing
59+
git remote add upstream https://github.com/pandas-dev/pandas.git
60+
git fetch upstream
61+
asv machine --yes
62+
asv continuous -f 1.1 -b $REGEX upstream/master HEAD
63+
echo 'BENCH_OUTPUT<<EOF' >> $GITHUB_ENV
64+
asv compare -f 1.1 upstream/master HEAD >> $GITHUB_ENV
65+
echo 'EOF' >> $GITHUB_ENV
66+
echo "REGEX=$REGEX" >> $GITHUB_ENV
67+
68+
- uses: actions/github-script@v4
69+
env:
70+
BENCH_OUTPUT: ${{env.BENCH_OUTPUT}}
71+
REGEX: ${{env.REGEX}}
72+
with:
73+
script: |
74+
const ENV_VARS = process.env
75+
const run_url = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`
76+
github.issues.createComment({
77+
issue_number: context.issue.number,
78+
owner: context.repo.owner,
79+
repo: context.repo.repo,
80+
body: '\nBenchmarks completed. View runner logs here.' + run_url + '\nRegex used: '+ 'regex ' + ENV_VARS["REGEX"] + '\n' + ENV_VARS["BENCH_OUTPUT"]
81+
})

0 commit comments

Comments
 (0)