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

@@ -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.");
}