Skip to content

Commit 51ec78b

Browse files
committed
setup codspeed pt 2
1 parent ea00790 commit 51ec78b

File tree

5 files changed

+30
-103
lines changed

5 files changed

+30
-103
lines changed

.github/actions/run_benchmark/action.yml

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,11 @@ inputs:
1717
description: 'Additional pytest arguments'
1818
required: false
1919
default: ''
20-
alert_threshold:
21-
description: 'Alert threshold percentage'
22-
required: false
23-
default: '101%'
2420
codecov_token:
2521
description: 'Token for uploading to codecov'
2622
required: false
27-
github_token:
28-
description: 'GitHub token'
23+
codspeed_token:
24+
description: 'Token for uploading to codspeed'
2925
required: false
3026

3127
runs:
@@ -34,31 +30,12 @@ runs:
3430
- name: Make benchmark directory
3531
shell: bash
3632
run: mkdir -p build/test-results/test
37-
38-
- uses: ./.github/actions/run_pytest
33+
- name: Run benchmarks
34+
uses: CodSpeedHQ/action@v3
3935
with:
40-
test_path: ${{ inputs.test_path }}
41-
timeout: ${{ inputs.timeout }}
42-
suite_name: ${{ inputs.suite_name }}
43-
extra_args: >-
44-
--benchmark-json build/test-results/test/benchmark-data.json
45-
${{ inputs.extra_args }}
46-
--benchmark-only
47-
--dist=no
48-
codecov_token: ${{ inputs.codecov_token }}
49-
50-
- uses: actions/cache@v4
36+
token: ${{ inputs.codspeed_token }}
37+
run: uv run pytest ${{ inputs.test_path }} ${{ inputs.extra_args }} -o junit_suite_name=${{ inputs.suite_name }}
38+
- uses: ./.github/actions/report
5139
with:
52-
path: ./cache
53-
key: ${{ runner.os }}-benchmark
54-
55-
- uses: benchmark-action/github-action-benchmark@v1
56-
with:
57-
name: Python Benchmark with pytest-benchmark
58-
tool: pytest
59-
output-file-path: build/test-results/test/benchmark-data.json
60-
external-data-json-path: ./cache/benchmark-data.json
61-
alert-threshold: ${{ inputs.alert_threshold }}
62-
comment-on-alert: true
63-
fail-on-alert: true
64-
github-token: ${{ inputs.github_token }}
40+
flag: no-flag
41+
codecov_token: ${{ inputs.codecov_token }}

.github/workflows/unit-tests.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ jobs:
1717
- uses: actions/checkout@v4
1818
- name: Setup backend
1919
uses: ./.github/actions/setup-backend
20+
2021
- name: Run benchmark tests
2122
uses: ./.github/actions/run_benchmark
2223
with:
2324
test_path: tests/benchmark
2425
timeout: 5
2526
codecov_token: ${{ secrets.CODECOV_TOKEN }}
26-
github_token: ${{ secrets.GITHUB_TOKEN }}
27+
codspeed_token: ${{ secrets.CODSPEED_TOKEN }}
2728
unit-tests:
2829
# changing the following value will significantly affect github's cost. Be careful and consult with the team before changing it.
2930
runs-on: ubuntu-latest-32
@@ -97,7 +98,7 @@ jobs:
9798
test_path: tests/integration/codemod/test_parse.py
9899
timeout: 15
99100
codecov_token: ${{ secrets.CODECOV_TOKEN }}
100-
github_token: ${{ secrets.GITHUB_TOKEN }}
101+
codspeed_token: ${{ secrets.CODSPEED_TOKEN }}
101102
- name: Notify parse tests failure
102103
uses: slackapi/slack-github-action@v2.0.0
103104
if: failure() && github.event_name == 'push' && false

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ dev-dependencies = [
140140
"black>=24.8.0",
141141
"isort>=5.13.2",
142142
"emoji>=2.14.0",
143-
"pytest-benchmark[histogram]>=5.1.0",
144143
"loguru>=0.7.3",
144+
"pytest-codspeed>=3.2.0",
145145
]
146146
keyring-provider = "subprocess"
147147
#extra-index-url = ["https://aws@codegen-922078275900.d.codeartifact.us-east-1.amazonaws.com/pypi/codegen/simple/"]

tests/benchmark/codegen/sdk/codebase/test_reset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ def reset_codebase(codebase: Codebase):
3131
def test_codebase_reset_stress_test(extension: str, tmp_path, benchmark):
3232
def setup():
3333
codebase, _ = setup_codebase(NUM_FILES, extension, tmp_path)
34-
return ((codebase,), {})
34+
return codebase
3535

36-
benchmark.pedantic(reset_codebase, setup=setup)
36+
benchmark(lambda: reset_codebase(setup()))
3737

3838

3939
@pytest.mark.skip("Skipping this test for now")

uv.lock

Lines changed: 15 additions & 66 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)