Run benchmarks nightly job #298
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 run daily at 06:45. | |
# It will run benchmarks with airspeed velocity (asv) | |
# and compare performance with the previous nightly build. | |
name: Run benchmarks nightly job | |
on: | |
schedule: | |
- cron: 45 6 * * * | |
workflow_dispatch: | |
env: | |
PYTHON_VERSION: "3.10" | |
WORKING_DIR: ${{ github.workspace }}/benchmarks | |
NIGHTLY_HASH_FILE: nightly-hash | |
jobs: | |
asv-nightly: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ${{ env.WORKING_DIR }} | |
steps: | |
- name: Checkout main branch of the repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- 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 }}" | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
python -m pip install --upgrade pip | |
pip install asv==0.6.1 virtualenv | |
- name: Configure git | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
- name: Create ASV machine config file | |
run: asv machine --machine gh-runner --yes | |
- name: Fetch previous results from the "benchmarks" branch | |
run: | | |
if git ls-remote --exit-code origin benchmarks > /dev/null 2>&1; then | |
git merge origin/benchmarks \ | |
--allow-unrelated-histories \ | |
--no-commit | |
mv ../_results . | |
fi | |
- name: Get nightly dates under comparison | |
id: nightly-dates | |
run: | | |
echo "yesterday=$(date -d yesterday +'%Y-%m-%d')" >> $GITHUB_OUTPUT | |
echo "today=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | |
- name: Use last nightly commit hash from cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.WORKING_DIR }} | |
key: nightly-results-${{ steps.nightly-dates.outputs.yesterday }} | |
- name: Run comparison of main against last nightly build | |
run: | | |
HASH_FILE=${{ env.NIGHTLY_HASH_FILE }} | |
CURRENT_HASH=${{ github.sha }} | |
if [ -f $HASH_FILE ]; then | |
PREV_HASH=$(cat $HASH_FILE) | |
asv continuous $PREV_HASH $CURRENT_HASH --verbose || true | |
asv compare $PREV_HASH $CURRENT_HASH --sort ratio --verbose | |
fi | |
echo $CURRENT_HASH > $HASH_FILE | |
- name: Update last nightly hash in cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.WORKING_DIR }} | |
key: nightly-results-${{ steps.nightly-dates.outputs.today }} |