From a84a2aeb331ca7a77e464fed8606a0347eaf0c00 Mon Sep 17 00:00:00 2001 From: Pablo Criado-Perez Date: Wed, 19 Feb 2025 11:47:57 +0100 Subject: [PATCH 1/6] add timeout to jobs (#1556) --- .github/workflows/python-app.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 2b0012d20..658baafff 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -16,6 +16,7 @@ permissions: jobs: lint: runs-on: ubuntu-latest + timeout-minutes: 5 steps: - uses: actions/checkout@v4 - name: Set up Python @@ -33,6 +34,7 @@ jobs: build: needs: lint runs-on: ubuntu-22.04 + timeout-minutes: 20 env: PROXY: "http://51.83.140.52:16301" TEST_TESTNET: "true" @@ -74,6 +76,7 @@ jobs: needs: build if: ${{ always() }} runs-on: ubuntu-latest + timeout-minutes: 5 steps: - name: Coveralls Finished uses: coverallsapp/github-action@v2 From 75fe302b2f5395c05dfa73241c4c135495ca7767 Mon Sep 17 00:00:00 2001 From: Pablo Date: Sat, 22 Feb 2025 01:15:55 -0600 Subject: [PATCH 2/6] codspeed --- .github/workflows/python-app.yml | 19 ++++++++++++++++++- test-requirements.txt | 1 + tests/test_ws_api.py | 6 ++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 658baafff..cefef1782 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -72,7 +72,7 @@ jobs: with: flag-name: run-${{ join(matrix.*, '-') }} parallel: true - finish: + coveralls: needs: build if: ${{ always() }} runs-on: ubuntu-latest @@ -82,3 +82,20 @@ jobs: uses: coverallsapp/github-action@v2 with: parallel-finished: true + benchmarks: + name: Run benchmarks + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.9" + + - name: Install dependencies + run: pip install -r test-requirements.txt + + - name: Run benchmarks + uses: CodSpeedHQ/action@v3 + with: + token: ${{ secrets.CODSPEED_TOKEN }} + run: pytest tests/ --codspeed diff --git a/test-requirements.txt b/test-requirements.txt index ec3e381ae..69fc0996f 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -4,6 +4,7 @@ pytest-asyncio pytest-cov pytest-xdist pytest-rerunfailures +pytest-codspeed requests-mock tox setuptools diff --git a/tests/test_ws_api.py b/tests/test_ws_api.py index 20a098875..435e8904b 100644 --- a/tests/test_ws_api.py +++ b/tests/test_ws_api.py @@ -14,6 +14,12 @@ async def test_ws_api_public_endpoint(clientAsync): """Test normal order book request""" order_book = await clientAsync.ws_get_order_book(symbol="BTCUSDT") assert_ob(order_book) + + +@pytest.mark.asyncio +async def test_benchmark_ws_api_order_book(clientAsync, benchmark): + """Test normal order book request""" + await benchmark(clientAsync.ws_get_order_book, symbol="BTCUSDT") @pytest.mark.asyncio From 66d150eabba8b1be731cd2cfac624dfb3c8f1efd Mon Sep 17 00:00:00 2001 From: Pablo Date: Sat, 22 Feb 2025 01:18:59 -0600 Subject: [PATCH 3/6] fix yaml --- .github/workflows/python-app.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index cefef1782..0fbaa73b9 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -82,7 +82,7 @@ jobs: uses: coverallsapp/github-action@v2 with: parallel-finished: true - benchmarks: + benchmarks: name: Run benchmarks runs-on: ubuntu-latest steps: From 370c457583102e7b2057c545aa09e42c2ff6f491 Mon Sep 17 00:00:00 2001 From: Pablo Date: Sat, 22 Feb 2025 01:20:57 -0600 Subject: [PATCH 4/6] fix dependencies --- .github/workflows/python-app.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 0fbaa73b9..a651dfba5 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -92,7 +92,11 @@ jobs: python-version: "3.9" - name: Install dependencies - run: pip install -r test-requirements.txt + run: | + python -m pip install --upgrade pip + pip install pytest pytest-cov pyright tox + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + if [ -f test-requirements.txt ]; then pip install -r test-requirements.txt; fi - name: Run benchmarks uses: CodSpeedHQ/action@v3 From b554b23f38bbd8a27bed0cd636c03f60dac2e59d Mon Sep 17 00:00:00 2001 From: Pablo Date: Sat, 22 Feb 2025 01:29:07 -0600 Subject: [PATCH 5/6] modify action --- .github/workflows/python-app.yml | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index a651dfba5..618e41bc4 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -65,6 +65,11 @@ jobs: if [ -f test-requirements.txt ]; then pip install -r test-requirements.txt; fi - name: Type check with pyright run: pyright + - name: Run benchmarks + uses: CodSpeedHQ/action@v3 + with: + token: ${{ secrets.CODSPEED_TOKEN }} + run: pytest tests/ --codspeed - name: Test with tox run: tox -e py - name: Coveralls Parallel @@ -82,24 +87,3 @@ jobs: uses: coverallsapp/github-action@v2 with: parallel-finished: true - benchmarks: - name: Run benchmarks - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: "3.9" - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install pytest pytest-cov pyright tox - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - if [ -f test-requirements.txt ]; then pip install -r test-requirements.txt; fi - - - name: Run benchmarks - uses: CodSpeedHQ/action@v3 - with: - token: ${{ secrets.CODSPEED_TOKEN }} - run: pytest tests/ --codspeed From ecd8f9f1dbf813b96e4f7937c68bc10b9c0e918f Mon Sep 17 00:00:00 2001 From: Pablo Date: Sun, 23 Feb 2025 22:03:15 -0600 Subject: [PATCH 6/6] run only on python 3.12 --- .github/workflows/python-app.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 618e41bc4..1c08ee39b 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -66,6 +66,7 @@ jobs: - name: Type check with pyright run: pyright - name: Run benchmarks + if: ${{ matrix.python == '3.12' }} uses: CodSpeedHQ/action@v3 with: token: ${{ secrets.CODSPEED_TOKEN }}