diff --git a/.github/workflows/codspeed.yml b/.github/workflows/codspeed.yml new file mode 100644 index 000000000..dea3f6e23 --- /dev/null +++ b/.github/workflows/codspeed.yml @@ -0,0 +1,28 @@ +name: codspeed-benchmarks + +on: + push: + branches: + - "main" # or "master" + pull_request: + # `workflow_dispatch` allows CodSpeed to trigger backtest + # performance analysis in order to generate initial data. + workflow_dispatch: + +jobs: + benchmarks: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v3 + with: + python-version: "3.7" + + - name: Install dependencies + run: pip install -r robyn/test-requirements.txt + + - name: Run benchmarks + uses: CodSpeedHQ/action@v1 + with: + token: ${{ secrets.CODSPEED_TOKEN }} + run: pytest integration_tests/test_benchmarks.py --codspeed diff --git a/integration_tests/test_benchmarks.py b/integration_tests/test_benchmarks.py new file mode 100644 index 000000000..e18b80e2b --- /dev/null +++ b/integration_tests/test_benchmarks.py @@ -0,0 +1,15 @@ +import pytest + +from helpers.http_methods_helpers import get + + +@pytest.mark.benchmark +def test_get_sync_benchmark(session): + r = get("/sync/param/1") + assert r.text == "1" + + +@pytest.mark.benchmark +def test_get_async_benchmark(session): + r = get("/async/param/1") + assert r.text == "1" diff --git a/robyn/test-requirements.txt b/robyn/test-requirements.txt index fdade8978..c8cae068b 100644 --- a/robyn/test-requirements.txt +++ b/robyn/test-requirements.txt @@ -2,3 +2,4 @@ requests==2.28.2 pytest==7.2.1 websocket-client==1.5.0 +pytest-codspeed