Improve performance comment #43
Workflow file for this run
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
# This workflow will install Python dependencies, run benchmarks with airspeed velocity (asv) | |
# and publish the results to a dashboard on GH Pages. | |
name: Run benchmarks with ASV | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
permissions: | |
contents: write | |
pull-requests: write | |
env: | |
ACTION_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
jobs: | |
run-asv: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
python -m pip install --upgrade pip | |
pip install asv virtualenv tabulate | |
- name: Checkout main branch of the repository | |
uses: actions/checkout@v3 | |
with: | |
ref: main | |
- name: Change to benchmarks | |
run: cd benchmarks | |
- name: Create ASV machine config file | |
run: asv machine --yes | |
- name: Run ASV for the main branch | |
run: asv run | |
- name: Generate dashboard HTML | |
if: ${{ github.event_name == 'push' }} | |
run: asv publish | |
- name: Deploy to Github pages | |
if: ${{ github.event_name == 'push' }} | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
folder: html | |
- name: Checkout the PR branch | |
if: ${{ github.event_name == 'pull_request' }} | |
run: | | |
git fetch origin $GITHUB_REF | |
git checkout FETCH_HEAD | |
- name: Run comparison of PR against main branch | |
if: ${{ github.event_name == 'pull_request' }} | |
run: | | |
asv run | |
asv compare main FETCH_HEAD --sort ratio | tee output | |
python format.py | |
echo "\nFull logs: $ACTION_URL" >> output | |
- name: Publish comment to PR | |
if: ${{ github.event_name == 'pull_request' }} | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const fs = require('fs'); | |
const comment = fs.readFileSync('output', 'utf-8'); | |
const { data } = await github.rest.issues.createComment({ | |
...context.repo, | |
issue_number: context.issue.number, | |
body: comment, | |
}); | |
console.log("Comment published:", data.html_url); |