Skip to content

Run benchmarks

Run benchmarks #80

# Use ASV to check for performance regressions, either:
# - In the last 24 hours' commits.
# - Introduced by this pull request.
name: benchmarks-run
run-name: Run benchmarks
on:
schedule:
# Runs every day at 23:00.
- cron: "0 23 * * *"
workflow_dispatch:
inputs:
first_commit:
description: "First commit to benchmark (see bm_runner.py > Overnight)."
required: false
type: string
pull_request:
types: [labeled]
jobs:
benchmark:
if: >
github.repository == 'SciTools/iris' &&
(github.event_name != 'pull_request' ||
github.event.label.name == 'benchmark_this')
runs-on: ubuntu-latest
env:
IRIS_TEST_DATA_LOC_PATH: benchmarks
IRIS_TEST_DATA_PATH: benchmarks/iris-test-data
IRIS_TEST_DATA_VERSION: "2.19"
# Lets us manually bump the cache to rebuild
ENV_CACHE_BUILD: "0"
TEST_DATA_CACHE_BUILD: "2"
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install ASV & Nox
run: |
pip install asv nox
- name: Cache environment directories
id: cache-env-dir
uses: actions/cache@v3
with:
path: |
.nox
benchmarks/.asv/env
$CONDA/pkgs
key: ${{ runner.os }}-${{ hashFiles('requirements/') }}-${{ env.ENV_CACHE_BUILD }}
- name: Cache test data directory
id: cache-test-data
uses: actions/cache@v3
with:
path: |
${{ env.IRIS_TEST_DATA_PATH }}
key:
test-data-${{ env.IRIS_TEST_DATA_VERSION }}-${{ env.TEST_DATA_CACHE_BUILD }}
- name: Fetch the test data
if: steps.cache-test-data.outputs.cache-hit != 'true'
run: |
wget --quiet https://github.com/SciTools/iris-test-data/archive/v${IRIS_TEST_DATA_VERSION}.zip -O iris-test-data.zip
unzip -q iris-test-data.zip
mkdir --parents ${GITHUB_WORKSPACE}/${IRIS_TEST_DATA_LOC_PATH}
mv iris-test-data-${IRIS_TEST_DATA_VERSION} ${GITHUB_WORKSPACE}/${IRIS_TEST_DATA_PATH}
- name: Set test data var
run: |
echo "OVERRIDE_TEST_DATA_REPOSITORY=${GITHUB_WORKSPACE}/${IRIS_TEST_DATA_PATH}/test_data" >> $GITHUB_ENV
- name: Benchmark this pull request
if: ${{ github.event.label.name == 'benchmark_this' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.number }}
run: |
python benchmarks/bm_runner.py branch origin/${{ github.base_ref }}
- name: Run overnight benchmarks
id: overnight
if: ${{ github.event_name != 'pull_request' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
first_commit=${{ inputs.first_commit }}
if [ "$first_commit" == "" ]
then
first_commit=$(git log --after="$(date -d "1 day ago" +"%Y-%m-%d") 23:00:00" --pretty=format:"%h" | tail -n 1)
fi
if [ "$first_commit" != "" ]
then
python benchmarks/bm_runner.py overnight $first_commit
fi
- name: Warn of failure
if: >
failure() &&
steps.overnight.outcome == 'failure'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
title="Overnight benchmark workflow failed: \`${{ github.run_id }}\`"
body="Generated by GHA run [\`${{github.run_id}}\`](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}})"
gh issue create --title "$title" --body "$body" --label "Bot" --label "Type: Performance" --repo $GITHUB_REPOSITORY
- name: Upload any benchmark reports
if: success() || steps.overnight.outcome == 'failure'
uses: actions/upload-artifact@v3
with:
name: benchmark_reports
path: .github/workflows/benchmark_reports
- name: Archive asv results
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: asv-raw-results
path: benchmarks/.asv/results