Skip to content

Commit bcd5d25

Browse files
authored
CI: Consolidate more comment command workflows (#52693)
1 parent 3aa9873 commit bcd5d25

File tree

2 files changed

+67
-80
lines changed

2 files changed

+67
-80
lines changed

.github/workflows/asv-bot.yml

-78
This file was deleted.

.github/workflows/comment-commands.yml

+67-2
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,83 @@ permissions:
1111
jobs:
1212
issue_assign:
1313
runs-on: ubuntu-22.04
14+
if: (!github.event.issue.pull_request) && github.event.comment.body == 'take'
15+
concurrency:
16+
group: ${{ github.actor }}-issue-assign
1417
steps:
15-
- if: (!github.event.issue.pull_request) && github.event.comment.body == 'take'
1618
run: |
1719
echo "Assigning issue ${{ github.event.issue.number }} to ${{ github.event.comment.user.login }}"
1820
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -d '{"assignees": ["${{ github.event.comment.user.login }}"]}' https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/assignees
1921
preview_docs:
2022
runs-on: ubuntu-22.04
23+
if: github.event.issue.pull_request && github.event.comment.body == '/preview'
24+
concurrency:
25+
group: ${{ github.actor }}-preview-docs
2126
steps:
22-
- if: github.event.issue.pull_request && github.event.comment.body == '/preview'
2327
run: |
2428
if curl --output /dev/null --silent --head --fail "https://pandas.pydata.org/preview/${{ github.event.issue.number }}/"; then
2529
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -d '{"body": "Website preview of this PR available at: https://pandas.pydata.org/preview/${{ github.event.issue.number }}/"}' https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments
2630
else
2731
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -d '{"body": "No preview found for PR #${{ github.event.issue.number }}. Did the docs build complete?"}' https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments
2832
fi
33+
asv_run:
34+
runs-on: ubuntu-22.04
35+
# TODO: Support more benchmarking options later, against different branches, against self, etc
36+
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '@github-actions benchmark')
37+
defaults:
38+
run:
39+
shell: bash -el {0}
40+
env:
41+
ENV_FILE: environment.yml
42+
COMMENT: ${{github.event.comment.body}}
43+
44+
concurrency:
45+
# Set concurrency to prevent abuse(full runs are ~5.5 hours !!!)
46+
# each user can only run one concurrent benchmark bot at a time
47+
# We don't cancel in progress jobs, but if you want to benchmark multiple PRs, you're gonna have
48+
# to wait
49+
group: ${{ github.actor }}-asv
50+
cancel-in-progress: false
51+
52+
steps:
53+
- name: Checkout
54+
uses: actions/checkout@v3
55+
with:
56+
fetch-depth: 0
57+
58+
# Although asv sets up its own env, deps are still needed
59+
# during discovery process
60+
- name: Set up Conda
61+
uses: ./.github/actions/setup-conda
62+
63+
- name: Run benchmarks
64+
id: bench
65+
continue-on-error: true # asv will exit code 1 for regressions
66+
run: |
67+
# extracting the regex, see https://stackoverflow.com/a/36798723
68+
REGEX=$(echo "$COMMENT" | sed -n "s/^.*-b\s*\(\S*\).*$/\1/p")
69+
cd asv_bench
70+
asv check -E existing
71+
git remote add upstream https://github.com/pandas-dev/pandas.git
72+
git fetch upstream
73+
asv machine --yes
74+
asv continuous -f 1.1 -b $REGEX upstream/main HEAD
75+
echo 'BENCH_OUTPUT<<EOF' >> $GITHUB_ENV
76+
asv compare -f 1.1 upstream/main HEAD >> $GITHUB_ENV
77+
echo 'EOF' >> $GITHUB_ENV
78+
echo "REGEX=$REGEX" >> $GITHUB_ENV
79+
80+
- uses: actions/github-script@v6
81+
env:
82+
BENCH_OUTPUT: ${{env.BENCH_OUTPUT}}
83+
REGEX: ${{env.REGEX}}
84+
with:
85+
script: |
86+
const ENV_VARS = process.env
87+
const run_url = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`
88+
github.rest.issues.createComment({
89+
issue_number: context.issue.number,
90+
owner: context.repo.owner,
91+
repo: context.repo.repo,
92+
body: '\nBenchmarks completed. View runner logs here.' + run_url + '\nRegex used: '+ 'regex ' + ENV_VARS["REGEX"] + '\n' + ENV_VARS["BENCH_OUTPUT"]
93+
})

0 commit comments

Comments
 (0)