-
-
Notifications
You must be signed in to change notification settings - Fork 765
86 lines (74 loc) · 2.76 KB
/
benchmark_on_push.yml
File metadata and controls
86 lines (74 loc) · 2.76 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
79
80
81
82
83
84
85
86
name: Run benchmarks on push
on:
push:
branches: [main]
permissions: {}
concurrency:
# Cancel intermediate builds always
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
PYBAMM_DISABLE_TELEMETRY: "true"
jobs:
benchmarks:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Set up Python 3.13
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: 3.13
- name: Install Linux system dependencies
run: |
sudo apt-get update
sudo apt install gfortran gcc libopenblas-dev
- uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
with:
version: "latest"
enable-cache: true
- name: Install python dependencies
run: uv pip install --system asv
- name: Fetch base branch
run: |
# This workflow also runs for merge commits
# on main. In this case, we don't want to be
# fetching the main branch.
current_branch=$(git rev-parse --abbrev-ref HEAD)
# This workflow should also run on forks; hence,
# we should fetch the upstream main branch.
git remote add upstream https://github.com/pybamm-team/PyBaMM/
if [ $current_branch != "main" ]; then
git fetch upstream main:main
fi
- name: Run benchmarks
run: |
asv machine --machine "GitHubRunner"
# Get IDs of branch and PR commits
BASE_COMMIT=$(git rev-parse main)
HEAD_COMMIT=$(git rev-parse HEAD)
echo $BASE_COMMIT | tee commits_to_compare.txt
echo $HEAD_COMMIT | tee -a commits_to_compare.txt
asv run HASHFILE:commits_to_compare.txt --m "GitHubRunner" --show-stderr -v
- name: Compare commits' benchmark results
run: |
BASE_COMMIT=$(head -1 commits_to_compare.txt)
HEAD_COMMIT=$(tail -1 commits_to_compare.txt)
echo "SUMMARY OF CHANGES"
echo "=================="
asv compare $BASE_COMMIT $HEAD_COMMIT | tee compare_result.txt
# Make sure grep returns error code 0 even if code 1 is
# returned because no match is found
REGRESSIONS=$({ grep "+" compare_result.txt || test $? = 1; })
if [ ! -z "$REGRESSIONS" ]; \
then \
echo "REGRESSIONS FOUND"; \
echo "================="; \
echo "$REGRESSIONS"; \
echo "================="; \
printf "Found %d regression(s)\n" $(echo "$REGRESSIONS" | wc -l); \
exit 1; \
fi