Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add tests for the queries of TPC-H #899

Merged
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/check_tpch_queries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Tests for TPCH Queries

on:
pull_request:
types: [labeled]

jobs:
validate-queries:
if: ${{ github.event.label.name == 'full-test' }}
strategy:
matrix:
python-version: ["3.12"]
os: [ubuntu-latest]

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: install-reqs
run: uv pip install --upgrade -r tpch/requirements-tpch.txt --system
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of this, would we first do pip install -e . so that we install Narwhals locally and use that? then, if a PR introduces anything which affects the tpc-h queries, we'll know right away

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! c:

- name: generate-data
run: cd tpch && python generate_data.py
- name: tpch-tests
run: python -m unittest discover -s 'tpch/tests'
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ lint.ignore = [

[tool.ruff.lint.per-file-ignores]
"tests/*" = ["S101"]
"tpch/tests/*" = ["S101"]
"utils/*" = ["S311", "PTH123"]
"tpch/execute/*" = ["T201"]

Expand Down
7 changes: 7 additions & 0 deletions tpch/requirements-tpch.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
duckdb
pyarrow
polars
pandas
dask[dataframe]
tqdm
narwhals
Empty file added tpch/tests/__init__.py
Empty file.
29 changes: 29 additions & 0 deletions tpch/tests/test_queries.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import os
import subprocess
import sys
import unittest
from pathlib import Path


class TestQueries(unittest.TestCase):
def test_execute_scripts(self) -> None:
root = Path(__file__).resolve().parent.parent
# directory containing all the queries
execute_dir = root / "execute"

env = os.environ.copy()
env["PYTHONPATH"] = str(root)

for script_path in execute_dir.glob("q[1-9]*.py"):
result = subprocess.run( # noqa: S603
[sys.executable, str(script_path)],
capture_output=True,
text=True,
env=env,
cwd=root,
check=False,
shell=False,
)
assert (
result.returncode == 0
), f"Script {script_path} failed with error: {result.stderr}"
Loading