Repository navigation
78 lines (66 loc) · 2.9 KB
/
Copy pathbenchmark.yml
File metadata and controls
78 lines (66 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
### Inspired from https://github.com/scikit-image/scikit-image/blob/main/.github/workflows/benchmarks.yml
name: Benchmark PR
on:
pull_request:
types: [labeled, synchronize]
permissions:
contents: read
jobs:
## This code below is to make sure a new commit on a PR with the label
## retriggers the benchmark, otherwise the label needs to be removed and
## applied again to run the benchmark.
check:
runs-on: ubuntu-latest
outputs:
result: ${{ steps.check.outputs.result }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
name: Check for benchmark label and new commit
id: check
with:
script: |
const { owner, repo, number: pull_number } = context.issue;
// Check for label
const { data: pullRequest } = await github.rest.pulls.get({ owner, repo, pull_number });
if (!pullRequest.labels.some(({ name }) => name === 'run:benchmark')) {
return false;
}
// Check for repo name and organization name
const { data: repository } = await github.rest.repos.get({ owner, repo });
return repository.name === 'networkx' && repository.owner.login === 'networkx';
benchmark:
needs: check
if: ${{ needs.check.outputs.result == 'true' }}
# if: contains(github.event.pull_request.labels.*.name, 'run:benchmark') || ${{ github.event.label.name == 'run:benchmark' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- uses: prefix-dev/setup-pixi@ad1da6449d9e506fd127fd67ab2d054a769f6a94 # v0.11.2
with:
environments: benchmark
- name: Run benchmarks
id: benchmark
env:
PULL_REQUEST_BASE_LABEL: ${{ github.event.pull_request.base.label }}
PULL_REQUEST_HEAD_LABEL: ${{ github.event.pull_request.head.label }}
run: |
set -euxo pipefail
echo "Baseline: ${{ github.event.pull_request.base.sha }} (${PULL_REQUEST_BASE_LABEL})"
echo "Contender: ${GITHUB_SHA} (${PULL_REQUEST_HEAD_LABEL})"
pixi run -e benchmark benchmark-continuous \
${{ github.event.pull_request.base.sha }} ${GITHUB_SHA} \
| sed "/Traceback \|failed$\|PERFORMANCE DECREASED/ s/^/::error::/" \
| tee benchmarks/benchmarks.log
if grep "Traceback \|failed$\|PERFORMANCE DECREASED" benchmarks/benchmarks.log > /dev/null ; then
exit 1
fi
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: always()
with:
name: asv-benchmark-results-${{ runner.os }}
path: benchmarks/benchmarks.log