From 32494594749229e6f2b200d6ffaf016b2967adf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez=20Mondrag=C3=B3n?= Date: Tue, 10 Oct 2023 17:38:01 -0600 Subject: [PATCH] Use a dedicated workflow --- .github/workflows/codspeed.yml | 43 ++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 8 ------- noxfile.py | 23 ++++++++++-------- poetry.lock | 2 +- pyproject.toml | 4 +++- 5 files changed, 60 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/codspeed.yml diff --git a/.github/workflows/codspeed.yml b/.github/workflows/codspeed.yml new file mode 100644 index 0000000000..7a5ca602b8 --- /dev/null +++ b/.github/workflows/codspeed.yml @@ -0,0 +1,43 @@ +name: codspeed + +on: + push: + branches: + - "main" + 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: + - name: Check out the repository + uses: actions/checkout@v4.1.0 + + - name: Install Poetry + env: + PIP_CONSTRAINT: .github/workflows/constraints.txt + run: | + pipx install poetry + poetry --version + + - name: Setup Python 3.11 + uses: actions/setup-python@v4.7.1 + with: + python-version: 3.11 + architecture: x64 + cache: 'poetry' + + - name: Configure poetry + run: poetry config virtualenvs.create false + + - name: Install project and dependencies + run: poetry install --only dev --only benchmark -vvv + + - name: Run benchmarks + uses: CodSpeedHQ/action@v1 + with: + token: ${{ secrets.CODSPEED_TOKEN }} + run: pytest tests/ --codspeed diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e9440c1d0c..22c23a554b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -89,19 +89,11 @@ jobs: nox --version - name: Run Nox - if: always() && (matrix.session != 'benches') env: SQLALCHEMY_VERSION: ${{ matrix.sqlalchemy }} run: | nox --python=${{ matrix.python-version }} - - name: Run Nox - uses: CodSpeedHQ/action@v1 - if: always() && (matrix.session == 'benches') - with: - token: ${{ secrets.CODSPEED_TOKEN }} - run: nox -v --python=${{ matrix.python-version }} - - name: Upload coverage data if: always() && (matrix.session == 'tests') uses: actions/upload-artifact@v3.1.2 diff --git a/noxfile.py b/noxfile.py index 85b9a03838..7495e05920 100644 --- a/noxfile.py +++ b/noxfile.py @@ -45,7 +45,6 @@ "duckdb-engine", "pytest", "pytest-benchmark", - "pytest-codspeed", "pytest-durations", "pytest-snapshot", "pyarrow", @@ -121,15 +120,19 @@ def benches(session: Session) -> None: """Run benchmarks.""" session.install(".[s3]") session.install(*test_dependencies) - - if session.posargs: - args = [*session.posargs] - elif GH_ACTIONS_ENV_VAR in os.environ: - args = ["--codspeed"] - else: - args = ["--benchmark-only", "--benchmark-json=output.json"] - - session.run("pytest", *args) + sqlalchemy_version = os.environ.get("SQLALCHEMY_VERSION") + if sqlalchemy_version: + # Bypass nox-poetry use of --constraint so we can install a version of + # SQLAlchemy that doesn't match what's in poetry.lock. + session.poetry.session.install( # type: ignore[attr-defined] + f"sqlalchemy=={sqlalchemy_version}", + ) + session.run( + "pytest", + "--benchmark-only", + "--benchmark-json=output.json", + *session.posargs, + ) @session(python=main_python_version) diff --git a/poetry.lock b/poetry.lock index 739d498664..af808ce328 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2477,4 +2477,4 @@ testing = ["pytest", "pytest-durations"] [metadata] lock-version = "2.0" python-versions = ">=3.7.1,<4" -content-hash = "71ece1e0192526834ea98411a6b0ecfb3b82e747cf6cddc933794e55e576cd3e" +content-hash = "7151732c048586777ce5c0026388b8ea5c9faff71b883483248a3769e36795de" diff --git a/pyproject.toml b/pyproject.toml index 0c112147fe..5867ed61ca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -110,7 +110,6 @@ numpy = [ ] pyarrow = ">=11,<13" pytest-benchmark = "^4.0.0" -pytest-codspeed = "^2.2.0" pytest-snapshot = ">=0.9.0" requests-mock = ">=1.10.0" time-machine = ">=2.10.0" @@ -122,6 +121,9 @@ types-simplejson = ">=3.18.0" types-PyYAML = ">=6.0.12" xdoctest = ">=1.1.1" +[tool.poetry.group.benchmark.dependencies] +pytest-codspeed = "^2.2.0" + [tool.black] exclude = ".*simpleeval.*"