Skip to content

Performance regression tests from refs/pull/235/merge #30

Performance regression tests from refs/pull/235/merge

Performance regression tests from refs/pull/235/merge #30

name: Performance regression tests
on:
pull_request:
branches: [main]
workflow_dispatch:
permissions:
contents: write
actions: write
pull-requests: write
run-name: Performance regression tests from ${{ github.ref }}
jobs:
benchmarking:
name: Benchmarking
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest]
python: ["3.10"]
defaults:
run:
shell: bash
steps:
- name: Set up Python 3.x
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-pip-wheels
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- uses: actions/checkout@v4
with:
ref: main
- name: Install dependancies
run: poetry install --sync
- name: Benchmarking on main
run: poetry run pytest benchmarks/run.py --benchmark-only --benchmark-save="benchmark"
- uses: actions/checkout@v4
with:
clean: false
- name: Install dependancies
run:
poetry install --sync
- name: Benchmarking on branch
run: poetry run pytest benchmarks/run.py --benchmark-only --benchmark-save="benchmark" --benchmark-compare --benchmark-compare-fail=min:50%
- name: Generate report
id: generate-report
if: always()
shell: bash
run: |
poetry run python benchmarks/generate_report.py "benchmark" ".benchmarks/summary.md"
SUMMARY=$(cat .benchmarks/summary.md)
echo "$SUMMARY" >> $GITHUB_STEP_SUMMARY
{
echo 'markdown-summary<<EOF'
echo "$SUMMARY"
echo EOF
} >> "$GITHUB_OUTPUT"
- name: Update PR
if: github.event_name == 'pull_request' && always()
uses: actions/github-script@v7
env:
SUMMARY: ${{ steps.generate-report.outputs.markdown-summary }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const maxGitHubBodyCharacters = 65536;
const output = process.env.SUMMARY + `
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Workflow: \`${{ github.workflow }}\`*`;
const {data: comments} = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.number,
})
const botComment = comments.find(
comment => comment.user.id === 41898282 &&
comment.body.includes("Performance Regression Tests")
)
if (context.payload.pull_request.head.repo.full_name !== 'oqc-community/qat') {
console.log('Not attempting to write comment on fork.');
} else {
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: output
})
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.number,
body: output
})
}
}