Skip to content

Commit

Permalink
ci: add tests for the queries of TPC-H (#899)
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaiasGutierrezCruz authored Sep 4, 2024
1 parent 1007352 commit 9eb5f46
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/check_tpch_queries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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 requirements-dev.txt --system
- name: local-install
run: uv pip install -e . --system
- 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
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
tqdm
covdefaults
duckdb
pandas
Expand Down
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}"

0 comments on commit 9eb5f46

Please sign in to comment.