From ed5122232cf40d2e9cf279b01a56c836cf2288d7 Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Sat, 26 Dec 2020 01:29:45 +0100 Subject: [PATCH 1/8] Adding a valgrind build on debug Python 3.9 Co-authored-by: Boris Staletic --- .github/workflows/ci.yml | 63 ++++++++++++++++++++++++++++++++++++++++ tests/requirements.txt | 2 +- 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3fa9c4eca4..c0e0478bde 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -164,6 +164,69 @@ jobs: - name: Setuptools helpers test run: pytest tests/extra_setuptools + valgrind: + runs-on: ubuntu-latest + name: "🐍 3.9 debug • Valgrind" + + steps: + - uses: actions/checkout@v2 + + - name: Install debug Python + uses: deadsnakes/action@v2.1.0 + with: + python-version: 3.9 + debug: true + + - name: Update CMake + uses: jwlawson/actions-setup-cmake@v1.5 + + - name: Valgrind cache + uses: actions/cache@v2 + id: cache-valgrind + with: + path: valgrind + key: 3.16.1 # Valgrind version + + - name: Compile and install Valgrind + if: steps.cache-valgrind.outputs.cache-hit != 'true' + run: | + VALGRIND_VERSION=3.16.1 + curl https://sourceware.org/pub/valgrind/valgrind-$VALGRIND_VERSION.tar.bz2 -o - | tar xj + mv valgrind-$VALGRIND_VERSION valgrind + pushd valgrind + ./configure && make -j 2 > /dev/null && sudo make install + popd + sudo apt-get update && sudo apt-get install libc6-dbg # Needed by Valgrind + + - name: Install Valgrind + if: steps.cache-valgrind.outputs.cache-hit == 'true' + run: | + pushd valgrind + sudo make install + popd + sudo apt-get update && sudo apt-get install libc6-dbg # Needed by Valgrind + + - name: Prepare env + run: python -m pip install -r tests/requirements.txt --prefer-binary + + - name: Configure + run: > + cmake -S . -B build + -DCMAKE_BUILD_TYPE=Debug + -DPYBIND11_WERROR=ON + -DPYBIND11_MEMCHECK=ON + -DDOWNLOAD_CATCH=ON + -DDOWNLOAD_EIGEN=ON + -DCMAKE_CXX_STANDARD=17 + + - name: Build + run: cmake --build build -j 2 + + - name: Python tests + run: cmake --build build --target pytest + + - name: Run Valgrind on Python tests + run: cmake --build build --target memcheck deadsnakes: strategy: diff --git a/tests/requirements.txt b/tests/requirements.txt index a6253e0042..0b383bf5c3 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -6,4 +6,4 @@ pytest==4.6.9; python_version<"3.5" pytest==6.1.2; python_version=="3.5" pytest==6.2.1; python_version>="3.6" scipy==1.2.3; (platform_python_implementation!="PyPy" or sys_platform=="linux") and python_version<"3.6" -scipy==1.5.2; (platform_python_implementation!="PyPy" or sys_platform=="linux") and python_version>="3.6" and python_version<"3.9" +scipy==1.5.4; (platform_python_implementation!="PyPy" or sys_platform=="linux") and python_version>="3.6" and python_version<"3.10" From 2505bd39bc050628f263b237e0d55a20a8522408 Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Sun, 27 Dec 2020 00:34:56 +0100 Subject: [PATCH 2/8] Add Valgrind suppression files - Introduce suppression file, populate it with a first suppression taken from CPython, and fix one leak in the tests - Suppress leak in NumPy - More clean tests! - Tests with names a-e passing (except for test_buffer) - Suppress multiprocessing errors - Merge multiprocessing suppressions into other suppression files - Numpy seems to be spelled with a big P - Append single entry from valgrind-misc.supp to valgrind-python.supp, and make clear valgrind-python.supp is only CPython Co-authored-by: Boris Staletic --- tests/valgrind-numpy-scipy.supp | 118 ++++++++++++++++++++++++++++++++ tests/valgrind-python.supp | 117 +++++++++++++++++++++++++++++++ 2 files changed, 235 insertions(+) create mode 100644 tests/valgrind-numpy-scipy.supp create mode 100644 tests/valgrind-python.supp diff --git a/tests/valgrind-numpy-scipy.supp b/tests/valgrind-numpy-scipy.supp new file mode 100644 index 0000000000..60e9f479e6 --- /dev/null +++ b/tests/valgrind-numpy-scipy.supp @@ -0,0 +1,118 @@ +# Valgrind suppression file for NumPy & SciPy errors and leaks in pybind11 tests + +{ + Leaks when importing NumPy + Memcheck:Leak + fun:malloc + fun:_PyMem_RawMalloc + fun:PyObject_Malloc + fun:_PyObject_GC_Alloc + fun:_PyObject_GC_Malloc + fun:_PyObject_GC_NewVar + fun:tuple_alloc + fun:PyTuple_Pack + ... + fun:__pyx_pymod_exec_* +} + +{ + Leaks when importing NumPy (bis) + Memcheck:Leak + fun:malloc + fun:_PyMem_RawMalloc + fun:PyObject_Malloc + fun:_PyObject_New + fun:PyCode_NewWithPosOnlyArgs + fun:PyCode_New + ... + fun:__pyx_pymod_exec_* +} + +{ + Leaks when importing NumPy (tris) + Memcheck:Leak + fun:malloc + fun:_PyMem_RawMalloc + fun:PyObject_Malloc + fun:_PyObject_GC_Alloc + fun:_PyObject_GC_Malloc + fun:_PyObject_GC_NewVar + fun:tuple_alloc + fun:_PyTuple_FromArray + fun:_PyObject_MakeTpCall + fun:_PyObject_VectorcallTstate + fun:PyObject_Vectorcall + fun:call_function + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalFrame + fun:function_code_fastcall + fun:_PyFunction_Vectorcall +} + +{ + Leaks when importing NumPy (quater) + Memcheck:Leak + fun:malloc + fun:_PyMem_RawMalloc + fun:PyObject_Malloc + fun:_PyObject_GC_Alloc + fun:_PyObject_GC_Malloc + fun:_PyObject_GC_NewVar + fun:tuple_alloc + fun:PyTuple_New + fun:r_object + fun:r_object + fun:r_object + fun:r_object +} + +{ + Leaks when importing NumPy (quinquies) + Memcheck:Leak + fun:malloc + fun:_PyMem_RawMalloc + fun:PyObject_Malloc + fun:_PyObject_GC_Alloc + fun:_PyObject_GC_Malloc + fun:_PyObject_GC_NewVar + fun:tuple_alloc + fun:PyTuple_New + fun:dictiter_iternextitem + fun:list_extend + fun:_PyList_Extend + fun:PySequence_List +} + +{ + Leak when importing scipy.fft + Memcheck:Leak + fun:_Znwm + fun:PyInit_pypocketfft + fun:_PyImport_LoadDynamicModuleWithSpec + fun:_imp_create_dynamic_impl.constprop.3 + fun:_imp_create_dynamic + fun:cfunction_vectorcall_FASTCALL + fun:PyVectorcall_Call + fun:_PyObject_Call + fun:PyObject_Call + fun:do_call_core + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalFrame + fun:_PyEval_EvalCode +} + +{ + NumPy leaks when spawning a subprocess + Memcheck:Leak + fun:malloc + ... + fun:_buffer_get_info + fun:array_getbuffer + fun:PyObject_GetBuffer + fun:__Pyx__GetBufferAndValidate* + fun:__pyx_f_5numpy_6random_13bit_generator_12SeedSequence_mix_entropy + fun:__pyx_pw_5numpy_6random_13bit_generator_12SeedSequence_1__init__ + fun:type_call + fun:__Pyx__PyObject_CallOneArg + fun:__pyx_pw_5numpy_6random_13bit_generator_12BitGenerator_1__init__ +} diff --git a/tests/valgrind-python.supp b/tests/valgrind-python.supp new file mode 100644 index 0000000000..d77d5e5c5c --- /dev/null +++ b/tests/valgrind-python.supp @@ -0,0 +1,117 @@ +# Valgrind suppression file for CPython errors and leaks in pybind11 tests + +# Taken verbatim from https://github.com/python/cpython/blob/3.9/Misc/valgrind-python.supp#L266-L272 +{ + Uninitialised byte(s) false alarm, see bpo-35561 + Memcheck:Param + epoll_ctl(event) + fun:epoll_ctl + fun:pyepoll_internal_ctl +} + +{ + Python leaks when spawning a subprocess + Memcheck:Leak + fun:malloc + fun:_PyMem_RawMalloc + fun:PyMem_RawMalloc + fun:PyThread_allocate_lock + fun:_PyEval_InitState + fun:PyInterpreterState_New + ... + fun:pyinit_core* + fun:Py_InitializeFromConfig + fun:pymain_init + fun:pymain_main +} + +{ + Python leaks when spawning a subprocess + Memcheck:Leak + fun:malloc + fun:_PyMem_RawMalloc + fun:_PyMem_DebugRawAlloc + fun:_PyMem_DebugRawMalloc + fun:PyMem_RawMalloc + fun:PyThread_allocate_lock + fun:_PyRuntimeState_Init_impl + fun:_PyRuntimeState_Init + fun:_PyRuntime_Initialize + fun:pymain_init + fun:pymain_main + fun:Py_BytesMain +} + +{ + Python leaks when spawning a subprocess + Memcheck:Leak + fun:malloc + fun:_PyMem_RawMalloc + fun:PyMem_RawMalloc + fun:PyThread_allocate_lock + fun:_PyImport_AcquireLock + fun:_imp_acquire_lock_impl* + fun:_imp_acquire_lock + fun:cfunction_vectorcall_NOARGS + fun:_PyObject_VectorcallTstate + fun:PyObject_Vectorcall + fun:call_function + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalFrame + fun:function_code_fastcall +} + +{ + Python leaks when spawning a subprocess + Memcheck:Leak + fun:malloc + fun:_PyMem_RawMalloc + fun:PyMem_RawMalloc + fun:PyThread_allocate_lock + fun:newlockobject + ... + fun:cfunction_vectorcall_NOARGS + fun:_PyObject_VectorcallTstate + fun:PyObject_Vectorcall + fun:call_function + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalFrame + fun:function_code_fastcall + fun:_PyFunction_Vectorcall +} + +{ + Python leaks when spawning a subprocess + Memcheck:Leak + fun:malloc + fun:_PyMem_RawMalloc + fun:PyMem_RawMalloc + fun:PyThread_allocate_lock + fun:rlock_new + fun:type_call + fun:_PyObject_Call + fun:PyObject_Call + fun:do_call_core + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalFrame + fun:_PyEval_EvalCode + fun:_PyFunction_Vectorcall +} + +# Not really CPython-specific, see link +{ + dlopen leak (https://stackoverflow.com/questions/1542457/memory-leak-reported-by-valgrind-in-dlopen) + Memcheck:Leak + fun:malloc + ... + fun:dl_open_worker + fun:_dl_catch_exception + fun:_dl_open + fun:dlopen_doit + fun:_dl_catch_exception + fun:_dl_catch_error + fun:_dlerror_run + fun:dlopen@@GLIBC_2.2.5 + fun:_PyImport_FindSharedFuncptr + fun:_PyImport_LoadDynamicModuleWithSpec +} From 0c1257762b49892552d0fce5c752641292e50ff6 Mon Sep 17 00:00:00 2001 From: Boris Staletic Date: Mon, 28 Dec 2020 15:39:17 +0100 Subject: [PATCH 3/8] Enable test_virtual_functions with a workaround --- tests/test_virtual_functions.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_virtual_functions.py b/tests/test_virtual_functions.py index ae19930164..f7d3bd1e4b 100644 --- a/tests/test_virtual_functions.py +++ b/tests/test_virtual_functions.py @@ -251,8 +251,7 @@ def dispatch(self): == 'Tried to call pure virtual function "Base::dispatch"' ) - p = PyClass1() - return m.dispatch_issue_go(p) + return m.dispatch_issue_go(PyClass1()) b = PyClass2() assert m.dispatch_issue_go(b) == "Yay.." From 7a09521f7db48babeed91a5ea29aaf5a59329e60 Mon Sep 17 00:00:00 2001 From: Boris Staletic Date: Mon, 28 Dec 2020 17:19:37 +0100 Subject: [PATCH 4/8] Add a memcheck cmake target - Add a memcheck cmake target - Reformat cmake - Appease the formatting overlords - they are angry - Format CMake valgrind target decently --- tests/CMakeLists.txt | 27 ++++++++++++++++++++++++++- tests/valgrind-python.supp | 18 ++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index dae8b5ad43..40b1d4c70f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -370,10 +370,30 @@ endif() string(REPLACE "test_" "${CMAKE_CURRENT_SOURCE_DIR}/test_" PYBIND11_ABS_PYTEST_FILES "${PYBIND11_PYTEST_FILES}") +if(NOT PYBIND11_MEMCHECK) + set(PYBIND11_TEST_PREFIX_COMMAND "") +else() + # cmake-format: off + set(PYBIND11_TEST_PREFIX_COMMAND + PYTHONMALLOC=malloc + valgrind + --leak-check=full + --show-leak-kinds=definite,indirect + --errors-for-leak-kinds=definite,indirect + --error-exitcode=1 + --read-var-info=yes + --track-origins=yes + --suppressions="${CMAKE_CURRENT_SOURCE_DIR}/valgrind-python.supp" + --suppressions="${CMAKE_CURRENT_SOURCE_DIR}/valgrind-numpy-scipy.supp" + --gen-suppressions=all) + # cmake-format: on +endif() + # A single command to compile and run the tests add_custom_target( pytest - COMMAND ${PYTHON_EXECUTABLE} -m pytest ${PYBIND11_ABS_PYTEST_FILES} + COMMAND ${PYBIND11_TEST_PREFIX_COMMAND} ${PYTHON_EXECUTABLE} -m pytest + ${PYBIND11_ABS_PYTEST_FILES} DEPENDS ${test_targets} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} USES_TERMINAL) @@ -386,6 +406,11 @@ if(PYBIND11_TEST_OVERRIDE) "Note: not all tests run: -DPYBIND11_TEST_OVERRIDE is in effect") endif() +add_custom_target( + memcheck + DEPENDS pytest + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + # Add a check target to run all the tests, starting with pytest (we add dependencies to this below) add_custom_target(check DEPENDS pytest) diff --git a/tests/valgrind-python.supp b/tests/valgrind-python.supp index d77d5e5c5c..1dd04fa7b8 100644 --- a/tests/valgrind-python.supp +++ b/tests/valgrind-python.supp @@ -115,3 +115,21 @@ fun:_PyImport_FindSharedFuncptr fun:_PyImport_LoadDynamicModuleWithSpec } + +# Not really CPython-specific, see link +{ + dlopen leak (https://stackoverflow.com/questions/1542457/memory-leak-reported-by-valgrind-in-dlopen) + Memcheck:Leak + fun:malloc + ... + fun:dl_open_worker + fun:_dl_catch_exception + fun:_dl_open + fun:dlopen_doit + fun:_dl_catch_exception + fun:_dl_catch_error + fun:_dlerror_run + fun:dlopen@@GLIBC_2.2.5 + fun:_PyImport_FindSharedFuncptr + fun:_PyImport_LoadDynamicModuleWithSpec +} From e26e714fa78b02fe02425bb9d5fd19960b0af27b Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Thu, 14 Jan 2021 20:00:14 +0100 Subject: [PATCH 5/8] Update CI config to new action versions --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c0e0478bde..8058a23763 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -166,19 +166,19 @@ jobs: valgrind: runs-on: ubuntu-latest - name: "🐍 3.9 debug • Valgrind" + name: "🐍 3.9 (debug) • Valgrind" steps: - uses: actions/checkout@v2 - name: Install debug Python - uses: deadsnakes/action@v2.1.0 + uses: deadsnakes/action@v2.1.1 with: python-version: 3.9 debug: true - name: Update CMake - uses: jwlawson/actions-setup-cmake@v1.5 + uses: jwlawson/actions-setup-cmake@v1.6 - name: Valgrind cache uses: actions/cache@v2 From 38d2cd8b8637d7963e7d1835cb8eb13a21ffa06b Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 14 Jan 2021 23:12:31 -0500 Subject: [PATCH 6/8] fix: separate memcheck from pytest --- tests/CMakeLists.txt | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 40b1d4c70f..cf1a984f01 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -370,24 +370,9 @@ endif() string(REPLACE "test_" "${CMAKE_CURRENT_SOURCE_DIR}/test_" PYBIND11_ABS_PYTEST_FILES "${PYBIND11_PYTEST_FILES}") -if(NOT PYBIND11_MEMCHECK) - set(PYBIND11_TEST_PREFIX_COMMAND "") -else() - # cmake-format: off - set(PYBIND11_TEST_PREFIX_COMMAND - PYTHONMALLOC=malloc - valgrind - --leak-check=full - --show-leak-kinds=definite,indirect - --errors-for-leak-kinds=definite,indirect - --error-exitcode=1 - --read-var-info=yes - --track-origins=yes - --suppressions="${CMAKE_CURRENT_SOURCE_DIR}/valgrind-python.supp" - --suppressions="${CMAKE_CURRENT_SOURCE_DIR}/valgrind-numpy-scipy.supp" - --gen-suppressions=all) - # cmake-format: on -endif() +set(PYBIND11_TEST_PREFIX_COMMAND + "" + CACHE STRING "Put this before pytest, use for checkers and such") # A single command to compile and run the tests add_custom_target( @@ -395,7 +380,7 @@ add_custom_target( COMMAND ${PYBIND11_TEST_PREFIX_COMMAND} ${PYTHON_EXECUTABLE} -m pytest ${PYBIND11_ABS_PYTEST_FILES} DEPENDS ${test_targets} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" USES_TERMINAL) if(PYBIND11_TEST_OVERRIDE) @@ -406,10 +391,26 @@ if(PYBIND11_TEST_OVERRIDE) "Note: not all tests run: -DPYBIND11_TEST_OVERRIDE is in effect") endif() +# cmake-format: off add_custom_target( memcheck - DEPENDS pytest - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + COMMAND + PYTHONMALLOC=malloc + valgrind + --leak-check=full + --show-leak-kinds=definite,indirect + --errors-for-leak-kinds=definite,indirect + --error-exitcode=1 + --read-var-info=yes + --track-origins=yes + --suppressions="${CMAKE_CURRENT_SOURCE_DIR}/valgrind-python.supp" + --suppressions="${CMAKE_CURRENT_SOURCE_DIR}/valgrind-numpy-scipy.supp" + --gen-suppressions=all + ${PYTHON_EXECUTABLE} -m pytest ${PYBIND11_ABS_PYTEST_FILES} + DEPENDS ${test_targets} + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + USES_TERMINAL) +# cmake-format: on # Add a check target to run all the tests, starting with pytest (we add dependencies to this below) add_custom_target(check DEPENDS pytest) From 3c6efb6362809577e5316d6911cf4e1aa30c4784 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 14 Jan 2021 23:26:45 -0500 Subject: [PATCH 7/8] ci: cleanup --- .github/workflows/ci.yml | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8058a23763..09cf522037 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -187,24 +187,24 @@ jobs: path: valgrind key: 3.16.1 # Valgrind version - - name: Compile and install Valgrind + - name: Compile Valgrind if: steps.cache-valgrind.outputs.cache-hit != 'true' run: | VALGRIND_VERSION=3.16.1 curl https://sourceware.org/pub/valgrind/valgrind-$VALGRIND_VERSION.tar.bz2 -o - | tar xj mv valgrind-$VALGRIND_VERSION valgrind - pushd valgrind - ./configure && make -j 2 > /dev/null && sudo make install - popd - sudo apt-get update && sudo apt-get install libc6-dbg # Needed by Valgrind + cd valgrind + ./configure + make -j 2 > /dev/null - name: Install Valgrind - if: steps.cache-valgrind.outputs.cache-hit == 'true' + working-directory: valgrind + run: sudo make install + + - name: Install requirement for Valgrind run: | - pushd valgrind - sudo make install - popd - sudo apt-get update && sudo apt-get install libc6-dbg # Needed by Valgrind + sudo apt-get update + sudo apt-get install libc6-dbg - name: Prepare env run: python -m pip install -r tests/requirements.txt --prefer-binary @@ -214,7 +214,6 @@ jobs: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DPYBIND11_WERROR=ON - -DPYBIND11_MEMCHECK=ON -DDOWNLOAD_CATCH=ON -DDOWNLOAD_EIGEN=ON -DCMAKE_CXX_STANDARD=17 From 8abf0da90084b9f5a856a813692195d2d83b1636 Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Fri, 15 Jan 2021 14:56:58 +0100 Subject: [PATCH 8/8] Merge Valgrind and other deadsnakes builds --- .github/workflows/ci.yml | 77 +++++++++++++--------------------------- 1 file changed, 25 insertions(+), 52 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 09cf522037..23dfbb0c99 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -164,23 +164,35 @@ jobs: - name: Setuptools helpers test run: pytest tests/extra_setuptools - valgrind: + + deadsnakes: + strategy: + fail-fast: false + matrix: + include: + - python-version: 3.9 + python-debug: true + valgrind: true + - python-version: 3.10-dev + python-debug: false + + name: "🐍 ${{ matrix.python-version }}${{ matrix.python-debug && '-dbg' || '' }} (deadsnakes)${{ matrix.valgrind && ' • Valgrind' || '' }} • x64" runs-on: ubuntu-latest - name: "🐍 3.9 (debug) • Valgrind" steps: - uses: actions/checkout@v2 - - name: Install debug Python + - name: Setup Python ${{ matrix.python-version }} (deadsnakes) uses: deadsnakes/action@v2.1.1 with: - python-version: 3.9 - debug: true + python-version: ${{ matrix.python-version }} + debug: ${{ matrix.python-debug }} - name: Update CMake uses: jwlawson/actions-setup-cmake@v1.6 - name: Valgrind cache + if: matrix.valgrind uses: actions/cache@v2 id: cache-valgrind with: @@ -188,7 +200,7 @@ jobs: key: 3.16.1 # Valgrind version - name: Compile Valgrind - if: steps.cache-valgrind.outputs.cache-hit != 'true' + if: matrix.valgrind && steps.cache-valgrind.outputs.cache-hit != 'true' run: | VALGRIND_VERSION=3.16.1 curl https://sourceware.org/pub/valgrind/valgrind-$VALGRIND_VERSION.tar.bz2 -o - | tar xj @@ -198,13 +210,12 @@ jobs: make -j 2 > /dev/null - name: Install Valgrind + if: matrix.valgrind working-directory: valgrind - run: sudo make install - - - name: Install requirement for Valgrind run: | + sudo make install sudo apt-get update - sudo apt-get install libc6-dbg + sudo apt-get install libc6-dbg # Needed by Valgrind - name: Prepare env run: python -m pip install -r tests/requirements.txt --prefer-binary @@ -224,51 +235,13 @@ jobs: - name: Python tests run: cmake --build build --target pytest - - name: Run Valgrind on Python tests - run: cmake --build build --target memcheck - - deadsnakes: - strategy: - fail-fast: false - matrix: - python: - - version: 3.9 - debug: true - - version: 3.10-dev - debug: false - - name: "🐍 ${{ matrix.python.version }}${{ matrix.python.debug && ' (debug)' || '' }} • deadsnakes • x64" - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: Setup Python ${{ matrix.python.version }} (deadsnakes) - uses: deadsnakes/action@v2.1.1 - with: - python-version: ${{ matrix.python.version }} - debug: ${{ matrix.python.debug }} - - - name: Prepare env - run: python -m pip install -r tests/requirements.txt --prefer-binary - - - name: Configure - run: > - cmake -S . -B build - -DPYBIND11_WERROR=ON - -DDOWNLOAD_CATCH=ON - -DDOWNLOAD_EIGEN=ON - -DCMAKE_CXX_STANDARD=17 - - - name: Build - run: cmake --build build -j 2 - - - name: Python tests - run: cmake --build build --target pytest - - name: C++ tests run: cmake --build build --target cpptest + - name: Run Valgrind on Python tests + if: matrix.valgrind + run: cmake --build build --target memcheck + # Testing on clang using the excellent silkeh clang docker images clang: