Skip to content

Commit

Permalink
Use a dedicated workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Oct 10, 2023
1 parent 60d66c7 commit 3249459
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 20 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/codspeed.yml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 0 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 13 additions & 10 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"duckdb-engine",
"pytest",
"pytest-benchmark",
"pytest-codspeed",
"pytest-durations",
"pytest-snapshot",
"pyarrow",
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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.*"

Expand Down

0 comments on commit 3249459

Please sign in to comment.