From aacbc7b2eba626ebba467d476bb0e9c4e1f01ca9 Mon Sep 17 00:00:00 2001 From: Yifan Chen Date: Mon, 7 Sep 2026 01:55:07 -0700 Subject: [PATCH] test: run hermetic user examples in CI Signed-off-by: Yifan Chen Generated-by: OpenAI Codex --- .github/workflows/test.yml | 7 ++++++- examples/_tests.py | 42 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 examples/_tests.py diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 047b35039..2773a3eae 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -119,7 +119,12 @@ jobs: # free-threaded build and re-pick the system 3.12 (see install step). uv run --python "$PWD/.venv/bin/python" --no-project pytest -v --import-mode=importlib - # FFI + TPC-H examples only need to run once; gate to abi3 entries. + # User, FFI, and TPC-H examples only need to run once; gate to abi3 entries. + - name: Run hermetic user examples + if: matrix.wheel-tag == 'abi3' + run: | + uv run --python "$PWD/.venv/bin/python" --no-project pytest examples/_tests.py + - name: FFI unit tests if: matrix.wheel-tag == 'abi3' run: | diff --git a/examples/_tests.py b/examples/_tests.py new file mode 100644 index 000000000..0a2ffd424 --- /dev/null +++ b/examples/_tests.py @@ -0,0 +1,42 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +"""Run the top-level examples that require no external resources.""" + +import subprocess +import sys +from pathlib import Path + +import pytest + +EXAMPLES = ( + "array-operations.py", + "create-context.py", + "query-pyarrow-data.py", + "python-udf.py", +) + + +@pytest.mark.parametrize("example", EXAMPLES) +def test_example_runs(example: str) -> None: + """Run one hermetic user example with the installed DataFusion package.""" + examples_dir = Path(__file__).parent + subprocess.run( # noqa: S603 -- `example` is selected from the module allowlist. + [sys.executable, examples_dir / example], + check=True, + cwd=examples_dir.parent, + )