-
Notifications
You must be signed in to change notification settings - Fork 151
77 lines (72 loc) · 2.43 KB
/
codspeed.yml
File metadata and controls
77 lines (72 loc) · 2.43 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
name: codspeed-benchmarks
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
concurrency:
group: codspeed-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: read
jobs:
preflight:
runs-on: ubuntu-latest
outputs:
enabled: ${{ steps.check.outputs.enabled }}
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
with:
persist-credentials: false
- id: check
env:
CODSPEED_TOKEN: ${{ secrets.CODSPEED_TOKEN }}
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
if [ -z "${CODSPEED_TOKEN:-}" ]; then
echo "enabled=false" >> "$GITHUB_OUTPUT"
exit 0
fi
if [ "${{ github.event_name }}" = "pull_request" ]; then
changed_files="$(gh pr diff "$PR_NUMBER" --name-only)" || {
echo "Failed to fetch PR diff" >&2
exit 1
}
if ! grep -qE '^(fastapi_code_generator/|tests/|pyproject\.toml$|uv\.lock$|tox\.ini$)' <<<"$changed_files"; then
echo "enabled=false" >> "$GITHUB_OUTPUT"
exit 0
fi
fi
if [ ! -f tests/main/test_performance.py ]; then
echo "enabled=false" >> "$GITHUB_OUTPUT"
exit 0
fi
if ! grep -qE '^\s*benchmark\s*=\s*\[' pyproject.toml; then
echo "enabled=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "enabled=true" >> "$GITHUB_OUTPUT"
benchmarks:
needs: preflight
if: needs.preflight.outputs.enabled == 'true'
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
with:
persist-credentials: false
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: "3.14.2"
- name: Install the latest version of uv
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
- name: Install dependencies
run: uv sync --all-extras --group benchmark
- name: Run benchmarks
uses: CodSpeedHQ/action@db35df748deb45fdef0960669f57d627c1956c30 # v4
with:
token: ${{ secrets.CODSPEED_TOKEN }}
run: .venv/bin/pytest tests/main/test_performance.py --codspeed
mode: walltime