Skip to content

Commit 8c4b00d

Browse files
authored
ASV custom build command and file-based benchmark triggers (#5776)
* Trigger benchmarks if lock files have changed. * Check for 'true' string not boolean * Temporarily disable other CI. * Limit branch actions to pull requests * Unified continue check. * Benchmarks temporary debug mode. * Demonstrate lock file trigger for benchmarks. * Demonstrate overnight mode. * Revert "Demonstrate overnight mode." This reverts commit fbb4ab7. * Revert "Demonstrate lock file trigger for benchmarks." This reverts commit 5522251. * Minor visual improvements. * Explanatory notes. * Revert "Benchmarks temporary debug mode." This reverts commit 8f097b1. * Revert "Temporarily disable other CI." This reverts commit 621a774. * Fix docs indentation. * Custom ASV build command using setup.py. * Remove ASV pin. * Don't trigger benchmarks when pyproject.toml changes. * More accurate name for files-changed step. * Don't have a continue output. * Remove confusing variable name clash. * Update What's New entry.
1 parent 6bc9adb commit 8c4b00d

File tree

6 files changed

+60
-18
lines changed

6 files changed

+60
-18
lines changed

.github/labeler.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
# Make sure any dependency changes are benchmarked (only changes to the locks
2-
# make a material difference - changes to the Conda YAML files are not
3-
# benchmarked).
1+
# benchmark_this automatically triggers the benchmark workflow when added by
2+
# a user. No triggering happens when GitHub Actions adds the label (this
3+
# avoids security vulnerabilities), so alternative triggers for the below
4+
# files are therefore included in workflows/benchmarks_run.yml. Automatic
5+
# labelling is still included here to make it easier to search pull requests,
6+
# and to reinforce the culture of using this label.
47
benchmark_this:
58
- changed-files:
6-
- any-glob-to-any-file: 'requirements/locks/*.lock'
9+
- any-glob-to-any-file: ['requirements/locks/*.lock', "setup.py"]

.github/pull_request_template.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@
77

88
---
99
[Consult Iris pull request check list]( https://scitools-iris.readthedocs.io/en/latest/developers_guide/contributing_pull_request_checklist.html)
10+
11+
---
12+
Add any of the below labels to trigger actions on this PR:
13+
14+
- https://github.com/SciTools/iris/labels/benchmark_this

.github/workflows/benchmarks_run.yml

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,46 @@ on:
1616
required: false
1717
type: string
1818
pull_request:
19-
types: [labeled]
19+
# Add the `labeled` type to the default list.
20+
types: [labeled, opened, synchronize, reopened]
2021

2122
jobs:
23+
pre-checks:
24+
runs-on: ubuntu-latest
25+
if: github.repository == 'SciTools/iris'
26+
outputs:
27+
overnight: ${{ steps.overnight.outputs.check }}
28+
branch: ${{ steps.branch.outputs.check }}
29+
steps:
30+
- uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 2
33+
- id: files-changed
34+
uses: marceloprado/has-changed-path@df1b7a3161b8fb9fd8c90403c66a9e66dfde50cb
35+
with:
36+
# SEE ALSO .github/labeler.yml .
37+
paths: requirements/locks/*.lock setup.py
38+
- id: overnight
39+
if: github.event_name != 'pull_request'
40+
run: echo "check=true" >> "$GITHUB_OUTPUT"
41+
- id: branch
42+
if: >
43+
github.event_name == 'pull_request'
44+
&&
45+
(
46+
steps.files-changed.outputs.changed == 'true'
47+
||
48+
github.event.label.name == 'benchmark_this'
49+
)
50+
run: echo "check=true" >> "$GITHUB_OUTPUT"
51+
52+
2253
benchmark:
23-
if: >
24-
github.repository == 'SciTools/iris' &&
25-
(github.event_name != 'pull_request' ||
26-
github.event.label.name == 'benchmark_this')
2754
runs-on: ubuntu-latest
55+
needs: pre-checks
56+
if: >
57+
needs.pre-checks.outputs.overnight == 'true' ||
58+
needs.pre-checks.outputs.branch == 'true'
2859
2960
env:
3061
IRIS_TEST_DATA_LOC_PATH: benchmarks
@@ -42,7 +73,7 @@ jobs:
4273

4374
- name: Install ASV & Nox
4475
run: |
45-
pip install "asv!=0.6.2" nox
76+
pip install asv nox
4677
4778
- name: Cache environment directories
4879
id: cache-env-dir
@@ -76,7 +107,7 @@ jobs:
76107
echo "OVERRIDE_TEST_DATA_REPOSITORY=${GITHUB_WORKSPACE}/${IRIS_TEST_DATA_PATH}/test_data" >> $GITHUB_ENV
77108
78109
- name: Benchmark this pull request
79-
if: ${{ github.event.label.name == 'benchmark_this' }}
110+
if: needs.pre-checks.outputs.branch == 'true'
80111
env:
81112
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82113
PR_NUMBER: ${{ github.event.number }}
@@ -85,7 +116,7 @@ jobs:
85116
86117
- name: Run overnight benchmarks
87118
id: overnight
88-
if: ${{ github.event_name != 'pull_request' }}
119+
if: needs.pre-checks.outputs.overnight == 'true'
89120
env:
90121
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91122
run: |

benchmarks/asv.conf.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
"environment_type": "conda-delegated",
77
"show_commit_url": "https://github.com/scitools/iris/commit/",
88
"branches": ["upstream/main"],
9+
"build_command": [
10+
"python setup.py build",
11+
"python -mpip wheel --no-deps -w {build_cache_dir} {build_dir}"
12+
],
913

1014
"benchmark_dir": "./benchmarks",
1115
"env_dir": ".asv/env",

benchmarks/bm_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def _gh_create_reports(commit_sha: str, results_full: str, results_shifts: str)
171171
performance_report = dedent(
172172
(
173173
"""
174-
### Performance Benchmark Report: {commit_sha}
174+
# :stopwatch: Performance Benchmark Report: {commit_sha}
175175
176176
<details>
177177
<summary>Performance shifts</summary>

docs/src/whatsnew/latest.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,10 @@ This document explains the changes made to Iris for this release
7272
💼 Internal
7373
===========
7474

75-
#. `@trexfeathers`_ used the `Pull Request Labeler Github action`_ to add the
76-
``benchmark_this`` label (:ref:`more info <on_demand_pr_benchmark>`) to
77-
pull requests that modify ``requirements/locks/*.lock`` files - ensuring
78-
that we know whether dependency changes will affect performance.
79-
(:pull:`5763`)
75+
#. `@trexfeathers`_ setup automatic benchmarking on pull requests that modify
76+
files likely to affect performance or performance testing. Such pull
77+
requests are also labelled using the `Pull Request Labeler Github action`_
78+
to increase visibility. (:pull:`5763`, :pull:`5776`)
8079

8180

8281
.. comment

0 commit comments

Comments
 (0)