/
/
/
1name: CodSpeed
2
3on:
4 push:
5 branches:
6 - stable
7 - dev
8 paths: &benchmark_paths
9 # helper functions exercised by the benchmarks
10 - "music_assistant/helpers/**"
11 # the benchmarks and toolchain itself
12 - "tests/benchmarks/**"
13 - ".github/workflows/codspeed.yml"
14 - "pyproject.toml"
15 - "requirements_all.txt"
16 pull_request:
17 branches:
18 - stable
19 - dev
20 paths: *benchmark_paths
21 # `workflow_dispatch` allows CodSpeed to trigger backtest
22 # performance analysis in order to generate initial data.
23 workflow_dispatch:
24
25permissions:
26 contents: read
27 id-token: write # for OpenID Connect authentication with CodSpeed
28
29# Keep urllib3-future from hijacking the urllib3 namespace (see pyproject.toml).
30env:
31 URLLIB3_NO_OVERRIDE: "1"
32
33jobs:
34 benchmarks:
35 name: Run benchmarks
36 runs-on: ubuntu-latest
37 timeout-minutes: 30
38 steps:
39 - name: Check out code from GitHub
40 uses: actions/checkout@v7
41
42 - name: Set up Python
43 # Pin an exact patch (not .python-version's "3.14") so the interpreter is
44 # identical across runs and CodSpeed's instruction counts stay comparable;
45 # check-latest is omitted so a new 3.14.x can't silently change the runtime.
46 uses: actions/[email protected]
47 with:
48 python-version: "3.14.6"
49
50 - name: Install uv
51 run: pip install uv
52
53 - name: Cache uv packages
54 uses: actions/cache@v6
55 with:
56 path: ~/.cache/uv
57 key: uv-${{ runner.os }}-${{ hashFiles('.python-version') }}-${{ hashFiles('requirements_all.txt', 'pyproject.toml') }}
58
59 - name: Install dependencies
60 # --index-strategy: allow PyPI packages when also using the PyTorch extra index
61 # https://docs.astral.sh/uv/pip/compatibility/#packages-that-exist-on-multiple-indexes
62 run: uv pip install --system --index-strategy unsafe-best-match . .[test] -r requirements_all.txt
63
64 - name: Run benchmarks
65 uses: CodSpeedHQ/action@4296e51e7041e24dadb86d1d6e8b9320d223dbe8 # v5.0.3
66 with:
67 mode: simulation
68 # tests/benchmarks/ holds only deterministic pure-function benchmarks, so their
69 # instruction counts are reproducible under simulation. Server-level / async
70 # scenarios are non-deterministic under instruction counting and are covered by
71 # the scripts/perf/ deep-dive suite instead.
72 run: pytest tests/benchmarks/ --codspeed
73