Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

Run walltime benchmarks on PRs only when compression code changes (#8227)

Adrian45dcb7d6c11c
diff --git a/.github/workflows/codspeed-walltime.yml b/.github/workflows/codspeed-walltime.yml
new file mode 100644
index 000000000..daf2c1992
--- /dev/null
+++ b/.github/workflows/codspeed-walltime.yml
@@ -0,0 +1,70 @@
+---
+name: codspeed-walltime
+
+on:
+ push:
+ branches:
+ - master
+ pull_request:
+ types: [opened, synchronize, reopened, closed]
+ paths:
+ - scrapy/downloadermiddlewares/httpcompression.py
+ - scrapy/utils/_compression.py
+ - tests/benchmarks/__init__.py
+ - tests/benchmarks/conftest.py
+ - tests/benchmarks/test_httpcompression.py
+ - .github/workflows/codspeed-walltime.yml
+ - tox.ini
+ workflow_dispatch:
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
+ cancel-in-progress: true
+
+permissions: {}
+
+jobs:
+ benchmark-walltime:
+ # Only benchmarks marked "walltime" (ones where a real concurrency
+ # win can't be shown by instruction counting) run here, on
+ # CodSpeed's dedicated, minutes-limited macro runner, and only for
+ # pull requests that change what they measure; codspeed.yml runs
+ # every benchmark in simulation mode, on a regular GitHub-hosted
+ # runner.
+ if: github.event.action != 'closed'
+ runs-on: codspeed-macro
+ env:
+ UV_PYTHON_PREFERENCE: only-system
+ permissions:
+ contents: read
+ id-token: write # OIDC authentication with CodSpeed
+
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+
+ - name: Set up Python 3.14
+ uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
+ with:
+ python-version: '3.14'
+
+ - name: Set up uv
+ uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
+ with:
+ cache-dependency-glob: |
+ pyproject.toml
+ tox.ini
+
+ - name: Install dependencies
+ run: |
+ uv tool install --with tox-uv tox
+ tox -n -e benchmark
+ - name: Run benchmarks
+ uses: CodSpeedHQ/action@373d6868929f444bc08d901fd0eb0ad52a8875ea # v5.2.1
+ with:
+ mode: walltime
+ # No benchmark is walltime-marked on some branches (e.g.
+ # this one), which would otherwise fail the step.
+ allow-empty: true
+ run: tox -e benchmark -- tests/benchmarks -m walltime
diff --git a/.github/workflows/codspeed.yml b/.github/workflows/codspeed.yml
index 5f09c4961..9d9334c48 100644
--- a/.github/workflows/codspeed.yml
+++ b/.github/workflows/codspeed.yml
@@ -60,46 +60,3 @@ jobs:
with:
mode: simulation
run: tox -e benchmark
-
- benchmark-walltime:
- # Only benchmarks marked "walltime" (ones where a real concurrency
- # win can't be shown by instruction counting) run here, on
- # CodSpeed's dedicated, minutes-limited macro runner; everything
- # else runs above, on a regular GitHub-hosted runner.
- if: github.event.action != 'closed'
- runs-on: codspeed-macro
- env:
- UV_PYTHON_PREFERENCE: only-system
- permissions:
- contents: read
- id-token: write # OIDC authentication with CodSpeed
-
- steps:
- - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- with:
- persist-credentials: false
-
- - name: Set up Python 3.14
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
- with:
- python-version: '3.14'
-
- - name: Set up uv
- uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
- with:
- cache-dependency-glob: |
- pyproject.toml
- tox.ini
-
- - name: Install dependencies
- run: |
- uv tool install --with tox-uv tox
- tox -n -e benchmark
- - name: Run benchmarks
- uses: CodSpeedHQ/action@373d6868929f444bc08d901fd0eb0ad52a8875ea # v5.2.1
- with:
- mode: walltime
- # No benchmark is walltime-marked on some branches (e.g.
- # this one), which would otherwise fail the step.
- allow-empty: true
- run: tox -e benchmark -- tests/benchmarks -m walltime