diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/linux-ci.yml index 3d250bfe9..ccd66aed2 100644 --- a/.github/workflows/linux-ci.yml +++ b/.github/workflows/linux-ci.yml @@ -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 }} diff --git a/platform/linux/BUILD.bazel b/platform/linux/BUILD.bazel index f7ffb87cf..40b1b8857 100644 --- a/platform/linux/BUILD.bazel +++ b/platform/linux/BUILD.bazel @@ -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", diff --git a/platform/linux/linux.cmake b/platform/linux/linux.cmake index 68e55d588..a83f84076 100644 --- a/platform/linux/linux.cmake +++ b/platform/linux/linux.cmake @@ -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 diff --git a/platform/linux/src/headless_backend_glx.cpp b/platform/linux/src/headless_backend_glx.cpp index 8e6e0f8cb..9132d35cb 100644 --- a/platform/linux/src/headless_backend_glx.cpp +++ b/platform/linux/src/headless_backend_glx.cpp @@ -4,6 +4,11 @@ #include +#ifdef CI_BUILD +#include +#include +#endif + #include 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."); } diff --git a/test/BUILD.bazel b/test/BUILD.bazel index ba36bc2c8..fcf45bb5e 100644 --- a/test/BUILD.bazel +++ b/test/BUILD.bazel @@ -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/**/*"]) + [ diff --git a/test/storage/main_resource_loader.test.cpp b/test/storage/main_resource_loader.test.cpp index d36b8e21c..16e9e0685 100644 --- a/test/storage/main_resource_loader.test.cpp +++ b/test/storage/main_resource_loader.test.cpp @@ -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{});