Skip to content

Commit

Permalink
Add ASAN/UBSAN build to CI (#397)
Browse files Browse the repository at this point in the history
  • Loading branch information
WillAyd authored Jan 30, 2025
1 parent e9d8bba commit c1344d8
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
Checks: '-*,cppcoreguidelines-*,-cppcoreguidelines-pro-type-union-access'
CheckOptions:
- key: cppcoreguidelines-avoid-do-while.IgnoreMacros
value: true
21 changes: 21 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,24 @@ jobs:
env:
CIBW_TEST_REQUIRES: pytest pytest-xdist[psutil] pandas>=2.0.0 polars narwhals
MACOSX_DEPLOYMENT_TARGET: "11.0"

test_sanitizers:
name: ASAN/UBSAN test
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4

# Used to host cibuildwheel
- uses: actions/setup-python@v3
- name: Install dependencies
run: python -m pip install nanobind pytest pandas polars narwhals pytest-xdist[psutil] pyarrow
- name: Build library
run: |
cmake -S . -B build -DPANTAB_USE_SANITIZERS=ON -DCMAKE_BUILD_TYPE=RelWithDebugInfo
cmake --build build
- name: Test library
env:
ASAN_OPTIONS: "detect_leaks=0"
run: |
cd build/src
LD_PRELOAD="$(gcc -print-file-name=libasan.so)" python -m pytest -m "not skip_asan" -s ../../tests/
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)

if (MSVC)
else()
add_compile_options(-Wall -Wextra -Werror)
add_compile_options(-Wall -Wextra)
endif()

find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ testpaths = ["tests"]
addopts = [
"--import-mode=importlib",
]
markers = [
"skip_asan: tests that are known to fail with ASAN",
]

[tool.mypy]
[[tool.mypy.overrides]]
Expand All @@ -66,6 +69,7 @@ known_first_party = "pantab"
[tool.cibuildwheel]
build = "cp39-*64 cp310-*64 cp311-*64 cp312-*64 cp313-*64"
skip = "*musllinux*"
manylinux-x86_64-image = "manylinux_2_28"

test-command = "python -m pytest -n auto {project}/tests"
test-requires = [
Expand Down
1 change: 1 addition & 0 deletions tests/test_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ def test_reader_accepts_process_params(tmp_hyper):
pt.frames_from_hyper(tmp_hyper, process_params=params)


@pytest.mark.skip_asan
def test_reader_invalid_process_params_raises(tmp_hyper):
frame = pd.DataFrame(list(range(10)), columns=["nums"]).astype("int8")
pt.frame_to_hyper(frame, tmp_hyper, table="test")
Expand Down
6 changes: 6 additions & 0 deletions tests/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def test_bad_table_mode_raises(frame, tmp_hyper):
pt.frames_to_hyper({"a": frame}, tmp_hyper, table_mode="x")


@pytest.mark.skip_asan
@pytest.mark.parametrize(
"new_dtype,hyper_type_name",
[(nw.Int64, "BIGINT"), (nw.Float64, "DOUBLE PRECISION")],
Expand Down Expand Up @@ -51,6 +52,7 @@ def test_append_mode_raises_column_dtype_mismatch(
)


@pytest.mark.skip_asan
def test_append_mode_raises_ncolumns_mismatch(frame, tmp_hyper, table_name, compat):
pt.frame_to_hyper(
frame,
Expand Down Expand Up @@ -173,6 +175,7 @@ def test_string_type_to_existing_varchar(frame, tmp_hyper, compat):
pt.frame_to_hyper(frame, tmp_hyper, table=table_name, table_mode="a")


@pytest.mark.skip_asan
def test_failed_write_doesnt_overwrite_file(
frame, tmp_hyper, monkeypatch, table_mode, compat
):
Expand Down Expand Up @@ -266,6 +269,7 @@ def test_atomic_keyword_does_not_copy_or_move(
mocked_move.assert_not_called()


@pytest.mark.skip_asan
def test_duplicate_columns_raises(tmp_hyper):
frame = pd.DataFrame([[1, 1]], columns=[1, 1])
msg = r"Duplicate column names found: \[1, 1\]"
Expand All @@ -276,6 +280,7 @@ def test_duplicate_columns_raises(tmp_hyper):
pt.frames_to_hyper({"test": frame}, tmp_hyper)


@pytest.mark.skip_asan
def test_unsupported_dtype_raises(tmp_hyper):
frame = pd.DataFrame([[pd.Timedelta("1D")]])

Expand Down Expand Up @@ -508,6 +513,7 @@ def test_writer_accepts_process_params(tmp_hyper):
pt.frame_to_hyper(frame, tmp_hyper, table="test", process_params=params)


@pytest.mark.skip_asan
def test_writer_invalid_process_params_raises(tmp_hyper):
frame = pd.DataFrame(list(range(10)), columns=["nums"]).astype("int8")
params = {"not_a_real_parameter": "0"}
Expand Down

0 comments on commit c1344d8

Please sign in to comment.