Skip to content

Initial query wrapping #16

Initial query wrapping

Initial query wrapping #16

Workflow file for this run

# This workflow will run benchmarks with airspeed velocity (asv) for pull requests.
# It will compare the performance of the main branch with the performance of the merge
# with the new changes. It then publishes a comment with this assessment by triggering
# the publish-benchmarks-pr workflow.
# Based on https://securitylab.github.com/research/github-actions-preventing-pwn-requests/.
name: Run benchmarks for PR
on:
pull_request:
branches: [ main ]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
PYTHON_VERSION: "3.10"
WORKING_DIR: ${{ github.workspace }}/benchmarks
ARTIFACTS_DIR: ${{ github.workspace }}/artifacts
jobs:
setup-python:
runs-on: ubuntu-latest
steps:
- name: Cache Python ${{ env.PYTHON_VERSION }}
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: python-${{ env.PYTHON_VERSION }}
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
asv-pr:
runs-on: ubuntu-latest
needs: setup-python
defaults:
run:
working-directory: ${{ env.WORKING_DIR }}
steps:
- name: Checkout PR branch of the repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Display Workflow Run Information
run: |
echo "Workflow Run ID: ${{ github.run_id }}"
- name: Cache Python ${{ env.PYTHON_VERSION }}
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: python-${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
sudo apt-get update
python -m pip install --upgrade pip
pip install asv==0.6.1 virtualenv tabulate lf-asv-formatter
- name: Make artifacts directory
run: mkdir -p ${{ env.ARTIFACTS_DIR }}
- name: Save pull request number
run: echo ${{ github.event.pull_request.number }} > ${{ env.ARTIFACTS_DIR }}/pr
- name: Get current job logs URL
uses: Tiryoh/gha-jobid-action@v1
id: jobs
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
job_name: ${{ github.job }}
- name: Create ASV machine config file
run: asv machine --machine gh-runner --yes
- name: Save comparison of PR against main branch
run: |
git remote add upstream https://github.com/${{ github.repository }}.git
git fetch upstream
asv continuous upstream/main HEAD --verbose || true
asv compare upstream/main HEAD --sort ratio --verbose | tee output
python -m lf_asv_formatter --asv_version "$(echo asv --version)"
printf "\n\nClick [here]($STEP_URL) to view all benchmarks." >> output
mv output ${{ env.ARTIFACTS_DIR }}
env:
STEP_URL: "${{ steps.jobs.outputs.html_url }}#step:11:1"
- name: Upload artifacts (PR number and benchmarks output)
uses: actions/upload-artifact@v4
with:
name: benchmark-artifacts
path: ${{ env.ARTIFACTS_DIR }}