Skip to content

Commit

Permalink
Make TF tests optional in python CI build script. (#2249)
Browse files Browse the repository at this point in the history
This should be optional for users relying on these CI scripts to build
StableHLO python bindings in other projects / locally.
  • Loading branch information
GleasonK authored Apr 23, 2024
1 parent c65a30d commit ae2a114
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/buildAndTestCMake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,4 @@ jobs:
env:
CMAKE_BUILD_TYPE: Release
STABLEHLO_ENABLE_BINDINGS_PYTHON: ON
STABLEHLO_ENABLE_PYTHON_TF_TESTS: ON
1 change: 1 addition & 0 deletions .github/workflows/publishWheelRelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ jobs:
env:
CMAKE_BUILD_TYPE: Release
STABLEHLO_ENABLE_BINDINGS_PYTHON: ON
STABLEHLO_ENABLE_PYTHON_TF_TESTS: ON

- name: Build and Test Python Wheel
shell: bash
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ endif()
#-------------------------------------------------------------------------------
option(STABLEHLO_BUILD_EMBEDDED "Build StableHLO as part of another project" OFF)
option(STABLEHLO_ENABLE_BINDINGS_PYTHON "Enables StableHLO Python bindings" OFF)
option(STABLEHLO_ENABLE_PYTHON_TF_TESTS "Enables StableHLO to SavedModel tests requiring TF" OFF)
option(STABLEHLO_ENABLE_STRICT_BUILD "Build StableHLO with strict warnings and warnings as errors" OFF)
option(STABLEHLO_ENABLE_SANITIZER "Enable a sanitizer [OFF, address]" OFF)
option(STABLEHLO_ENABLE_SPLIT_DWARF "Enable split DWARF if the platform supports it" OFF)
Expand Down
5 changes: 4 additions & 1 deletion build_tools/github_actions/ci_build_cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-RelWithDebInfo}"

# Turn on building Python bindings
STABLEHLO_ENABLE_BINDINGS_PYTHON="${STABLEHLO_ENABLE_BINDINGS_PYTHON:-OFF}"
# Turn on running SavedModel Python tests requiring TF dependency
STABLEHLO_ENABLE_PYTHON_TF_TESTS="${STABLEHLO_ENABLE_PYTHON_TF_TESTS:-OFF}"
# Turn on building Sanitizers
# Note: This is not congruent with building python bindings
STABLEHLO_ENABLE_SANITIZER="${STABLEHLO_ENABLE_SANITIZER:-OFF}"
Expand All @@ -56,7 +58,8 @@ cmake -GNinja \
-DSTABLEHLO_ENABLE_STRICT_BUILD=ON \
-DCMAKE_PLATFORM_NO_VERSIONED_SONAME:BOOL=ON \
-DSTABLEHLO_ENABLE_SANITIZER="$STABLEHLO_ENABLE_SANITIZER" \
-DSTABLEHLO_ENABLE_BINDINGS_PYTHON="$STABLEHLO_ENABLE_BINDINGS_PYTHON"
-DSTABLEHLO_ENABLE_BINDINGS_PYTHON="$STABLEHLO_ENABLE_BINDINGS_PYTHON" \
-DSTABLEHLO_ENABLE_PYTHON_TF_TESTS="$STABLEHLO_ENABLE_PYTHON_TF_TESTS"

# Build and Test StableHLO
cd "$STABLEHLO_BUILD_DIR" || exit
Expand Down
6 changes: 5 additions & 1 deletion stablehlo/integrations/python/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ endfunction()
add_stablehlo_python_test(stablehlo-python-chlo chlo.py)
add_stablehlo_python_test(stablehlo-python-smoketest smoketest.py)
add_stablehlo_python_test(stablehlo-python-stablehlo stablehlo.py)
add_stablehlo_python_test(stablehlo-python-stablehlo-to-saved-model stablehlo_to_tf_saved_model_test.py)
add_stablehlo_python_test(stablehlo-python-vhlo vhlo.py)

if(STABLEHLO_ENABLE_PYTHON_TF_TESTS)
add_stablehlo_python_test(stablehlo-python-stablehlo-to-saved-model stablehlo_to_tf_saved_model_test.py)
endif()


add_dependencies(check-stablehlo-quick check-stablehlo-python)

0 comments on commit ae2a114

Please sign in to comment.