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

@@ -72,6 +72,8 @@ jobs:
libwebp-dev
- name: Build MapLibre Native Core
env:
CI: 1
run: |
cmake --version
cmake -B build -GNinja -DCMAKE_BUILD_TYPE=Debug -DMLN_WITH_CLANG_TIDY=ON -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DMLN_WITH_COVERAGE=ON
@@ -182,7 +184,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y \
libcurl4-openssl-dev \
libuv1-dev \
libjpeg-dev \
@@ -190,8 +192,8 @@ jobs:
libwebp-dev \
libglfw3-dev \
libsqlite3-dev \
xserver-xorg-video-dummy \
xinit
xvfb \
x11-xserver-utils
- name: Cache Bazel
uses: actions/cache@v3
@@ -208,10 +210,14 @@ jobs:
- name: Generate coverage report
run: |
bazel coverage --test_output=all --combined_report=lcov --nobuild_runfile_links --local_test_jobs=1 --instrumentation_filter="//:mbgl-core" //test:core //render-test:render-test --//:maplibre_platform=linux --run_under=//platform/linux:startxwrapper
echo coverage_report="$(bazel info output_path)"/_coverage/_coverage_report.dat >> "$GITHUB_ENV"
xvfb-run -a \
bazel coverage --combined_report=lcov --instrumentation_filter="//:mbgl-core" --//:maplibre_platform=linux \
--test_output=errors --local_test_jobs=1 \
--test_env=DISPLAY --test_env=XAUTHORITY --define=CI_BUILD=1 \
//test:core
- name: Upload coverage report
if: '!cancelled()'
uses: codecov/codecov-action@v3
with:
files: ${{ env.coverage_report }}

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

View File

@@ -42,7 +42,7 @@ cc_test(
],
),
args = [
"--gtest_filter=-Map.StyleNetworkErrorRetry:Map.StyleNotFound",
"--gtest_filter=-Map.StyleNetworkErrorRetry:Map.StyleNotFound:MainResourceLoader.CachedResourceLowPriority",
],
copts = CPP_FLAGS + MAPLIBRE_FLAGS,
data = glob(["fixtures/**/*"]) + [

View File

@@ -715,9 +715,8 @@ TEST(MainResourceLoader, TEST_REQUIRES_SERVER(RespondToStaleMustRevalidate)) {
}
// Test that requests for expired resources have lower priority than requests for new resources
// Flaky https://github.com/maplibre/maplibre-native/issues/1071
TEST(MainResourceLoader, TEST_REQUIRES_SERVER(CachedResourceLowPriority)) {
GTEST_SKIP() << "Skipping MainResourceLoader.CachedResourceLowPriority. "
<< "See https://github.com/maplibre/maplibre-native/issues/1071";
util::RunLoop loop;
MainResourceLoader fs(ResourceOptions{}, ClientOptions{});