未验证 提交 b5d4a1f3 编写于 作者: L LoveAn 提交者: GitHub

Add the strategy of skipping cc/cu test compilation and execution in CI (#29499)

* Add the strategy of skipping cc/cu test compilation and execution in CI, test=develop

* fix if error with CI_SKIP_TEST, test=develop

* fix add properties to test error on Linux/MAC, test=develop

* fix set test properties of test_code_generator error, test=develop

* remove test codes and advance judgment of file modification on Linux, test=develop

* rename CI_SKIP_TEST to CI_SKIP_CPP_TEST, test=document_fix

* Add branch judgement on Linux, test=develop
上级 2a422506
...@@ -431,7 +431,10 @@ function(cc_test_run TARGET_NAME) ...@@ -431,7 +431,10 @@ function(cc_test_run TARGET_NAME)
endfunction() endfunction()
function(cc_test TARGET_NAME) function(cc_test TARGET_NAME)
if(WITH_TESTING) # The environment variable `CI_SKIP_CPP_TEST` is used to skip the compilation
# and execution of test in CI. `CI_SKIP_CPP_TEST` is set to ON when no files
# other than *.py are modified.
if(WITH_TESTING AND NOT "$ENV{CI_SKIP_CPP_TEST}" STREQUAL "ON")
set(oneValueArgs "") set(oneValueArgs "")
set(multiValueArgs SRCS DEPS ARGS) set(multiValueArgs SRCS DEPS ARGS)
cmake_parse_arguments(cc_test "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) cmake_parse_arguments(cc_test "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
...@@ -508,7 +511,10 @@ function(nv_binary TARGET_NAME) ...@@ -508,7 +511,10 @@ function(nv_binary TARGET_NAME)
endfunction(nv_binary) endfunction(nv_binary)
function(nv_test TARGET_NAME) function(nv_test TARGET_NAME)
if (WITH_GPU AND WITH_TESTING) # The environment variable `CI_SKIP_CPP_TEST` is used to skip the compilation
# and execution of test in CI. `CI_SKIP_CPP_TEST` is set to ON when no files
# other than *.py are modified.
if (WITH_GPU AND WITH_TESTING AND NOT "$ENV{CI_SKIP_CPP_TEST}" STREQUAL "ON")
set(oneValueArgs "") set(oneValueArgs "")
set(multiValueArgs SRCS DEPS) set(multiValueArgs SRCS DEPS)
cmake_parse_arguments(nv_test "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) cmake_parse_arguments(nv_test "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
......
...@@ -349,6 +349,6 @@ if(APPLE) ...@@ -349,6 +349,6 @@ if(APPLE)
${PADDLE_BINARY_DIR}/paddle/fluid/framework/libpaddle_framework.dylib ${PADDLE_BINARY_DIR}/paddle/fluid/framework/libpaddle_framework.dylib
CACHE INTERNAL "Fluid framework lib") CACHE INTERNAL "Fluid framework lib")
endif() endif()
if(WITH_TESTING) if(WITH_TESTING AND TEST selected_rows_test)
set_tests_properties(selected_rows_test PROPERTIES TIMEOUT 120) set_tests_properties(selected_rows_test PROPERTIES TIMEOUT 120)
endif() endif()
...@@ -9,6 +9,6 @@ cc_library(fusion_group_pass ...@@ -9,6 +9,6 @@ cc_library(fusion_group_pass
SRCS fusion_group_pass.cc elementwise_group_detector.cc SRCS fusion_group_pass.cc elementwise_group_detector.cc
DEPS subgraph_detector fuse_pass_base code_generator device_code) DEPS subgraph_detector fuse_pass_base code_generator device_code)
cc_test(test_fusion_group_pass SRCS fusion_group_pass_tester.cc DEPS fusion_group_pass graph_viz_pass) cc_test(test_fusion_group_pass SRCS fusion_group_pass_tester.cc DEPS fusion_group_pass graph_viz_pass)
if(WITH_TESTING) if(WITH_TESTING AND TEST test_code_generator)
set_tests_properties(test_code_generator PROPERTIES TIMEOUT 120) set_tests_properties(test_code_generator PROPERTIES TIMEOUT 120)
endif() endif()
...@@ -57,11 +57,13 @@ cc_library(allocator_facade SRCS allocator_facade.cc DEPS allocator_strategy) ...@@ -57,11 +57,13 @@ cc_library(allocator_facade SRCS allocator_facade.cc DEPS allocator_strategy)
cc_test(retry_allocator_test SRCS retry_allocator_test.cc DEPS retry_allocator locked_allocator cpu_allocator) cc_test(retry_allocator_test SRCS retry_allocator_test.cc DEPS retry_allocator locked_allocator cpu_allocator)
if (WITH_TESTING) if (WITH_TESTING)
if (WITH_GPU) if (WITH_GPU AND TARGET retry_allocator_test)
target_link_libraries(retry_allocator_test cuda_allocator) target_link_libraries(retry_allocator_test cuda_allocator)
endif() endif()
set_tests_properties(retry_allocator_test PROPERTIES LABELS "RUN_TYPE=EXCLUSIVE") if (TEST retry_allocator_test)
set_tests_properties(retry_allocator_test PROPERTIES LABELS "RUN_TYPE=EXCLUSIVE")
endif()
endif() endif()
cc_test(allocator_facade_abs_flags_test SRCS allocator_facade_abs_flags_test.cc DEPS allocator_facade) cc_test(allocator_facade_abs_flags_test SRCS allocator_facade_abs_flags_test.cc DEPS allocator_facade)
......
...@@ -34,7 +34,9 @@ FUNCTION(file_download_and_uncompress URL NAME) ...@@ -34,7 +34,9 @@ FUNCTION(file_download_and_uncompress URL NAME)
ENDFUNCTION() ENDFUNCTION()
if(WITH_TESTING) if(WITH_TESTING)
set_tests_properties(buddy_allocator_test PROPERTIES LABELS "RUN_TYPE=EXCLUSIVE") if(TEST buddy_allocator_test)
set_tests_properties(buddy_allocator_test PROPERTIES LABELS "RUN_TYPE=EXCLUSIVE")
endif()
set(URL "https://paddle-ci.cdn.bcebos.com/buddy_allocator_test_data.tar") set(URL "https://paddle-ci.cdn.bcebos.com/buddy_allocator_test_data.tar")
file_download_and_uncompress(URL "buddy_allocator") file_download_and_uncompress(URL "buddy_allocator")
endif() endif()
...@@ -69,6 +69,10 @@ if(WITH_GPU) ...@@ -69,6 +69,10 @@ if(WITH_GPU)
selected_rows_functor scope math_function) selected_rows_functor scope math_function)
endif() endif()
if(WITH_TESTING) if(WITH_TESTING)
set_tests_properties(rpc_server_test PROPERTIES TIMEOUT 120) if(TEST rpc_server_test)
set_tests_properties(heart_beat_monitor_test PROPERTIES TIMEOUT 120) set_tests_properties(rpc_server_test PROPERTIES TIMEOUT 120)
endif()
if(TEST heart_beat_monitor_test)
set_tests_properties(heart_beat_monitor_test PROPERTIES TIMEOUT 120)
endif()
endif() endif()
...@@ -26,6 +26,6 @@ cc_test(jit_kernel_test SRCS test.cc DEPS jit_kernel_helper) ...@@ -26,6 +26,6 @@ cc_test(jit_kernel_test SRCS test.cc DEPS jit_kernel_helper)
if(NOT WIN32) if(NOT WIN32)
cc_binary(jit_kernel_benchmark SRCS benchmark.cc DEPS jit_kernel_helper device_tracer tensor) cc_binary(jit_kernel_benchmark SRCS benchmark.cc DEPS jit_kernel_helper device_tracer tensor)
endif() endif()
if(WITH_TESTING) if(WITH_TESTING AND TEST jit_kernel_test)
set_tests_properties(jit_kernel_test PROPERTIES TIMEOUT 120) set_tests_properties(jit_kernel_test PROPERTIES TIMEOUT 120)
endif() endif()
...@@ -91,6 +91,6 @@ if(WITH_GPU) ...@@ -91,6 +91,6 @@ if(WITH_GPU)
endif() endif()
cc_test(concat_test SRCS concat_test.cc DEPS concat_and_split) cc_test(concat_test SRCS concat_test.cc DEPS concat_and_split)
cc_test(cpu_vec_test SRCS cpu_vec_test.cc DEPS blas cpu_info) cc_test(cpu_vec_test SRCS cpu_vec_test.cc DEPS blas cpu_info)
if(WITH_TESTING) if(WITH_TESTING AND TEST im2col_test)
set_tests_properties(im2col_test PROPERTIES TIMEOUT 120) set_tests_properties(im2col_test PROPERTIES TIMEOUT 120)
endif() endif()
...@@ -15,11 +15,13 @@ function(train_test TARGET_NAME) ...@@ -15,11 +15,13 @@ function(train_test TARGET_NAME)
DEPS paddle_fluid_api DEPS paddle_fluid_api
ARGS --dirname=${PYTHON_TESTS_DIR}/book/) ARGS --dirname=${PYTHON_TESTS_DIR}/book/)
endif() endif()
set_tests_properties(test_train_${TARGET_NAME} if(TEST test_train_${TARGET_NAME})
PROPERTIES FIXTURES_REQUIRED test_${TARGET_NAME}_infer_model)
if(NOT WIN32 AND NOT APPLE)
set_tests_properties(test_train_${TARGET_NAME} set_tests_properties(test_train_${TARGET_NAME}
PROPERTIES TIMEOUT 150) PROPERTIES FIXTURES_REQUIRED test_${TARGET_NAME}_infer_model)
if(NOT WIN32 AND NOT APPLE)
set_tests_properties(test_train_${TARGET_NAME}
PROPERTIES TIMEOUT 150)
endif()
endif() endif()
endfunction(train_test) endfunction(train_test)
......
...@@ -74,6 +74,9 @@ if %ERRORLEVEL% EQU 0 ( ...@@ -74,6 +74,9 @@ if %ERRORLEVEL% EQU 0 (
git branch last_pr git branch last_pr
) )
:: set CI_SKIP_CPP_TEST if only *.py changed
git diff --name-only %BRANCH% | findstr /V "\.py" || set CI_SKIP_CPP_TEST=ON
:: for /F %%# in ('wmic os get localdatetime^|findstr 20') do set datetime=%%# :: for /F %%# in ('wmic os get localdatetime^|findstr 20') do set datetime=%%#
:: set day_now=%datetime:~6,2% :: set day_now=%datetime:~6,2%
:: set day_before=-1 :: set day_before=-1
......
...@@ -60,6 +60,13 @@ function init() { ...@@ -60,6 +60,13 @@ function init() {
# NOTE(chenweihang): For easy debugging, CI displays the C++ error stacktrace by default # NOTE(chenweihang): For easy debugging, CI displays the C++ error stacktrace by default
export FLAGS_call_stack_level=2 export FLAGS_call_stack_level=2
# set CI_SKIP_CPP_TEST if only *.py changed
# In order to avoid using in some CI(such as daily performance), the current
# branch must not be `${BRANCH}` which is usually develop.
if [ "$(git branch | grep "^\*" | awk '{print $2}')" != "${BRANCH}" ]; then
git diff --name-only ${BRANCH} | grep -v "\.py$" || export CI_SKIP_CPP_TEST=ON
fi
} }
function cmake_base() { function cmake_base() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册