Linux CI: Retry failed XOpenDisplay calls and only log errors in coverage run (#1368)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Bart Louwers <bart@emeel.net>
Co-authored-by: Bart Louwers <bart.louwers@gmail.com>
This commit is contained in:
mwilsnd
2023-07-26 09:35:42 -05:00
committed by GitHub
parent 82ea2b5bf1
commit a5ac21587c
6 changed files with 54 additions and 12 deletions

View File

@@ -10,13 +10,13 @@ cc_library(
name = "impl",
srcs = [
"src/gl_functions.cpp",
"src/headless_backend_egl.cpp",
"src/headless_backend_glx.cpp",
],
copts = CPP_FLAGS + MAPLIBRE_FLAGS,
linkopts = [
"-lGL",
"-lglfw",
"-lEGL",
"-lX11",
"-lsqlite3",
"-luv",
"-lz",

View File

@@ -93,6 +93,15 @@ else()
)
endif()
if (DEFINED ENV{CI})
message("Building for CI")
target_compile_definitions(
mbgl-core
PRIVATE
CI_BUILD=1
)
endif()
# FIXME: Should not be needed, but now needed by node because of the headless frontend.
target_include_directories(
mbgl-core
@@ -153,9 +162,19 @@ add_executable(
target_compile_definitions(
mbgl-test-runner
PRIVATE WORK_DIRECTORY=${PROJECT_SOURCE_DIR}
PRIVATE
WORK_DIRECTORY=${PROJECT_SOURCE_DIR}
)
if (DEFINED ENV{CI})
message("Building for CI")
target_compile_definitions(
mbgl-test-runner
PRIVATE
CI_BUILD=1
)
endif()
target_link_libraries(
mbgl-test-runner
PRIVATE

View File

@@ -4,6 +4,11 @@
#include <cassert>
#ifdef CI_BUILD
#include <chrono>
#include <thread>
#endif
#include <GL/glx.h>
namespace mbgl {
@@ -24,7 +29,20 @@ public:
throw std::runtime_error("Failed to XInitThreads.");
}
xDisplay = XOpenDisplay(nullptr);
#ifdef CI_BUILD
// XOpenDisplay has proven very unreliable on CI, perform some retries if it fails
constexpr auto CI_RETRIES = 10;
for (int i = 0; i < CI_RETRIES; i++) {
#endif
xDisplay = XOpenDisplay(nullptr);
#ifdef CI_BUILD
if (xDisplay != nullptr) {
break;
}
Log::Debug(Event::OpenGL, "[CI] Failed to open X display, retrying...");
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
#endif
if (xDisplay == nullptr) {
throw std::runtime_error("Failed to open X display.");
}