Issue 883 #28
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Comment on PR with Benchmarks | |
on: | |
pull_request: | |
branches: [main] | |
permissions: | |
contents: read # Read access for repository contents | |
pull-requests: write # Write access for pull requests | |
env: | |
PYTHON_VERSION: "3.10" | |
WORKING_DIR: ${{ github.workspace }}/benchmarks | |
ARTIFACTS_DIR: ${{ github.workspace }}/artifacts | |
jobs: | |
benchmark: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install asv | |
- name: Create ASV machine config file | |
run: asv machine --machine gh-runner --yes --config benchmarks/asv.conf.json | |
- name: Save comparison of PR against main branch | |
run: | | |
# adapted from pandas asv_pr.yml | |
# extracting the regex, see https://stackoverflow.com/a/36798723 | |
REGEX=$(echo "$COMMENT" | sed -n "s/^.*-b\s*\(\S*\).*$/\1/p") | |
asv check -E existing | |
git remote add upstream ${{ vars.TARGET_REPO }} | |
git fetch upstream | |
asv machine --yes | |
asv continuous -f 1.1 -b $REGEX upstream/main HEAD | |
echo 'BENCH_OUTPUT<<EOF' >> $GITHUB_ENV | |
asv compare -f 1.1 upstream/main HEAD >> $GITHUB_ENV | |
echo 'EOF' >> $GITHUB_ENV | |
echo "REGEX=$REGEX" >> $GITHUB_ENV | |
- uses: actions/github-script@v7 | |
env: | |
BENCH_OUTPUT: ${{env.BENCH_OUTPUT}} | |
REGEX: ${{env.REGEX}} | |
with: | |
script: | | |
const ENV_VARS = process.env | |
const run_url = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}` | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: '\nBenchmarks completed. View runner logs here.' + run_url + '\nRegex used: '+ 'regex ' + ENV_VARS["REGEX"] + '\n' + ENV_VARS["BENCH_OUTPUT"] | |
}) |