From 6eadd3da17633f5534c0cefde7516d67dc842351 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc Date: Mon, 26 Oct 2026 11:14:00 +0100 Subject: [PATCH 1/5] Run the Linux desktop CI job in a prebuilt toolchain image --- .github/docker/linux-ci.Dockerfile | 21 +++++++++++++ .github/workflows/BuildAndTest.yml | 48 +++++++++++++++++++++++------- docs/CHANGELOG.md | 4 +++ 3 files changed, 63 insertions(+), 10 deletions(-) create mode 100644 .github/docker/linux-ci.Dockerfile diff --git a/.github/docker/linux-ci.Dockerfile b/.github/docker/linux-ci.Dockerfile new file mode 100644 index 00000000..55cc376c --- /dev/null +++ b/.github/docker/linux-ci.Dockerfile @@ -0,0 +1,21 @@ +# Toolchain of the Linux desktop CI job (GCC 16, WebKitGTK, lcov, Xvfb), prebuilt so that a job downloads one image from +# ghcr.io instead of dozens of packages from an Ubuntu mirror. BuildAndTest.yml tags it with the hash of this file: +# changing the file (for example to refresh the packages) is what rebuilds it. CMake is not part of it: the +# setup-cmake action installs an exact, checksummed release. +FROM ubuntu:26.04@sha256:c098726dd9b9733f3e885f8de0ef375206a311b0a317eadc40d347b1115fb944 + +LABEL org.opencontainers.image.source="https://github.com/ambroise-leclerc/WebFront" +LABEL org.opencontainers.image.description="WebFront CI: GCC 16, WebKitGTK 6, lcov and Xvfb on Ubuntu 26.04" + +ENV DEBIAN_FRONTEND=noninteractive + +# sudo: the composite actions of the repository call it, as they do on a hosted runner. +RUN apt-get update \ + && apt-get install -y --no-install-recommends -o Acquire::Retries=3 \ + ca-certificates curl git sudo tar xz-utils \ + ninja-build pkg-config python3 \ + gcc-16 g++-16 libwebkitgtk-6.0-dev lcov \ + xvfb xauth \ + && rm -rf /var/lib/apt/lists/* + +ENV CC=gcc-16 CXX=g++-16 diff --git a/.github/workflows/BuildAndTest.yml b/.github/workflows/BuildAndTest.yml index c5d724d9..92528a4f 100644 --- a/.github/workflows/BuildAndTest.yml +++ b/.github/workflows/BuildAndTest.yml @@ -28,7 +28,41 @@ env: # Third-party actions are pinned to commit SHAs; GitHub-owned actions/* use version tags. jobs: + # The Linux toolchain image is tagged with the hash of its Dockerfile and built only when that tag is missing from ghcr.io, + # so a change of the Dockerfile is validated by the very run that carries it. A pull request from a fork cannot push it + # (read-only token): its Linux job then fails at the pull, which a maintainer re-run on a branch of this repository fixes. + linux-image: + if: github.event_name != 'workflow_dispatch' || inputs.repeat_desktop_tests + runs-on: ubuntu-24.04 + timeout-minutes: 30 + permissions: + contents: read + packages: write + outputs: + image: ${{ steps.tag.outputs.image }} + steps: + - uses: actions/checkout@v7 + - name: Name the image after its Dockerfile + id: tag + run: | + hash=$(sha256sum .github/docker/linux-ci.Dockerfile | cut -c1-16) + echo "image=ghcr.io/${GITHUB_REPOSITORY,,}/linux-ci:$hash" >> "$GITHUB_OUTPUT" + - name: Log in to ghcr.io + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin + - name: Build and push the image if its tag does not exist + run: | + if docker manifest inspect "${{ steps.tag.outputs.image }}" > /dev/null 2>&1; then + echo "${{ steps.tag.outputs.image }} already exists" + else + docker build -f .github/docker/linux-ci.Dockerfile -t "${{ steps.tag.outputs.image }}" .github/docker + docker push "${{ steps.tag.outputs.image }}" + fi + desktop: + needs: linux-image + permissions: + contents: read + packages: read # Manual runs add extended checks; stability checks opt into desktops. if: github.event_name != 'workflow_dispatch' || inputs.repeat_desktop_tests # No `name:` expression: a skipped matrix job would display it unevaluated. @@ -40,6 +74,7 @@ jobs: include: - platform: linux-gcc-webkitgtk os: ubuntu-26.04 + use_image: true build_type: Debug test_env: {WEBKIT_DISABLE_SANDBOX_THIS_IS_DANGEROUS: '1'} options: -DWEBFRONT_EMBED_WEBKITGTK=ON -DWEBFRONT_WEBTEST_FRONTEND=WebKitGTK -DENABLE_COVERAGE=ON @@ -54,6 +89,8 @@ jobs: test_env: {} options: -DWEBFRONT_EMBED_WKWEBVIEW=ON -DWEBFRONT_WEBTEST_FRONTEND=WKWebView runs-on: ${{ matrix.os }} + # Only the Linux job runs in the prebuilt toolchain image; an empty value means no container. + container: ${{ matrix.use_image && fromJSON(format('{{"image":"{0}","credentials":{{"username":"{1}","password":"{2}"}},"options":"--shm-size=1g"}}', needs.linux-image.outputs.image, github.actor, github.token)) || '' }} steps: - uses: actions/checkout@v7 # No step of a build or of its tests needs a JavaScript runtime or package manager: the runner has none from here on. @@ -70,16 +107,7 @@ jobs: - name: Initialize MSVC environment if: runner.os == 'Windows' uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1 - # Ubuntu 26.04 ships GCC 16 in its main archive (no flaky toolchain PPA). The image already - # provides CMake, Ninja, pkg-config and Xvfb, so install only the missing pieces. - - name: Install GCC 16, WebKitGTK and coverage tools - if: runner.os == 'Linux' - run: | - sudo apt-get update - sudo apt-get install -y --no-install-recommends -o Acquire::Retries=3 \ - gcc-16 g++-16 libwebkitgtk-6.0-dev lcov - echo "CC=gcc-16" >> "$GITHUB_ENV" - echo "CXX=g++-16" >> "$GITHUB_ENV" + # GCC 16, WebKitGTK, lcov, Ninja and Xvfb come from the container image (.github/docker/linux-ci.Dockerfile). - name: Setup Xcode if: runner.os == 'macOS' uses: maxim-lobanov/setup-xcode@ed7a3b1fda3918c0306d1b724322adc0b8cc0a90 # v1 diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index b25720b2..0f6d3f2b 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +- The Linux desktop CI job runs in a prebuilt toolchain image (GCC 16, WebKitGTK, lcov, Xvfb; `.github/docker/linux-ci.Dockerfile`) + published to ghcr.io and tagged with the hash of its Dockerfile, instead of installing those packages from an Ubuntu mirror + on every run. Windows, macOS and the extended jobs are unchanged. + - HTTP status-line buffers belong to each response until its asynchronous send ends (#376). Ordinary responses announce `Connection: close`, matching the existing one-request-per-socket server behavior; WebSocket upgrades remain open. Unit and real-browser regressions cover From 84e8306d67cf9a4a6bbe49e0f0e03ad121d8cb57 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc Date: Mon, 26 Oct 2026 11:38:29 +0100 Subject: [PATCH 2/5] Keep Windows and macOS independent of the image job and fix workspace paths in the container --- .github/workflows/BuildAndTest.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/BuildAndTest.yml b/.github/workflows/BuildAndTest.yml index 92528a4f..8cb6e1a0 100644 --- a/.github/workflows/BuildAndTest.yml +++ b/.github/workflows/BuildAndTest.yml @@ -63,8 +63,9 @@ jobs: permissions: contents: read packages: read - # Manual runs add extended checks; stability checks opt into desktops. - if: github.event_name != 'workflow_dispatch' || inputs.repeat_desktop_tests + # Manual runs add extended checks; stability checks opt into desktops. The image job gates only the Linux leg: when it + # fails, Windows and macOS still run (a skipped `needs` would skip the whole matrix) and the Linux leg fails at its pull. + if: ${{ !cancelled() && (github.event_name != 'workflow_dispatch' || inputs.repeat_desktop_tests) }} # No `name:` expression: a skipped matrix job would display it unevaluated. timeout-minutes: 25 strategy: @@ -98,6 +99,10 @@ jobs: - uses: ./.github/actions/setup-cmake with: version: '4.4.4' + # In the container the workspace is mounted elsewhere than the host path that `github.workspace` expands to. + - name: Point the CPM cache at the workspace + if: matrix.use_image + run: echo "CPM_SOURCE_CACHE=$GITHUB_WORKSPACE/.cache/CPM" >> "$GITHUB_ENV" - uses: mozilla-actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # v0.0.9 - uses: actions/cache@v4 with: @@ -159,7 +164,7 @@ jobs: # Only Linux trusted fixtures need the sandbox opt-out on hosted runners. env: ${{ matrix.test_env }} run: >- - cmake -DBUILD_DIR=${{ github.workspace }}/build -DCONFIG=${{ matrix.build_type }} + cmake -DBUILD_DIR=build -DCONFIG=${{ matrix.build_type }} -DREPEAT=${{ github.event_name == 'workflow_dispatch' && inputs.repeat_desktop_tests && '3' || '1' }} -P test/cmake/RunTestSuite.cmake - name: Collect coverage From b0abb22c3b42f69fa8556b9f63b3101303925045 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc Date: Mon, 26 Oct 2026 11:45:40 +0100 Subject: [PATCH 3/5] Add make, a default compiler and a git safe directory to the CI image --- .github/docker/linux-ci.Dockerfile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/docker/linux-ci.Dockerfile b/.github/docker/linux-ci.Dockerfile index 55cc376c..fb08b136 100644 --- a/.github/docker/linux-ci.Dockerfile +++ b/.github/docker/linux-ci.Dockerfile @@ -9,13 +9,17 @@ LABEL org.opencontainers.image.description="WebFront CI: GCC 16, WebKitGTK 6, lc ENV DEBIAN_FRONTEND=noninteractive -# sudo: the composite actions of the repository call it, as they do on a hosted runner. +# sudo: the composite actions of the repository call it, as they do on a hosted runner. build-essential: the CTest +# fixtures configure sub-projects with CMake's default generator and compiler, which a hosted runner also provides. RUN apt-get update \ && apt-get install -y --no-install-recommends -o Acquire::Retries=3 \ - ca-certificates curl git sudo tar xz-utils \ + ca-certificates curl git sudo tar xz-utils build-essential \ ninja-build pkg-config python3 \ gcc-16 g++-16 libwebkitgtk-6.0-dev lcov \ xvfb xauth \ && rm -rf /var/lib/apt/lists/* +# The workspace is mounted from the host runner and owned by another user: let git (and the tests that call it) read it. +RUN git config --system --add safe.directory '*' + ENV CC=gcc-16 CXX=g++-16 From 4fb53b9c86da240ba9a359aa70996456484147d8 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc Date: Mon, 26 Oct 2026 12:01:04 +0100 Subject: [PATCH 4/5] Resolve a relative build directory in the CTest suite runner --- test/cmake/CheckTestSuiteRepetition.cmake | 15 +++++++++++++++ test/cmake/RunTestSuite.cmake | 2 ++ 2 files changed, 17 insertions(+) diff --git a/test/cmake/CheckTestSuiteRepetition.cmake b/test/cmake/CheckTestSuiteRepetition.cmake index a7cf4dc5..33f8b277 100644 --- a/test/cmake/CheckTestSuiteRepetition.cmake +++ b/test/cmake/CheckTestSuiteRepetition.cmake @@ -53,6 +53,21 @@ if(NOT result EQUAL 0 OR EXISTS "${WORK}/build/test-results-2.xml" OR EXISTS "${ OR NOT EXISTS "${WORK}/build/test-results-manual.xml" OR NOT EXISTS "${WORK}/build/test-results-2-extra.xml") message(FATAL_ERROR "A shorter rerun must keep only its own numbered reports: ${output}${error}") endif() +# A relative build directory (the container jobs of the CI pass "build") designates the same directory for the reports as for CTest. +file(WRITE "${WORK}/build/test-results-3.xml" "stale") +execute_process(COMMAND "${CMAKE_COMMAND}" -DBUILD_DIR=build -DCONFIG=Release -DREPEAT=2 -P "${ROOT}/test/cmake/RunTestSuite.cmake" + WORKING_DIRECTORY "${WORK}" RESULT_VARIABLE result OUTPUT_VARIABLE output ERROR_VARIABLE error) +if(NOT result EQUAL 0) + message(FATAL_ERROR "Repetition with a relative build directory failed: ${output}${error}") +endif() +foreach(pass RANGE 1 2) + if(NOT EXISTS "${WORK}/build/test-results-${pass}.xml") + message(FATAL_ERROR "A relative build directory must keep the JUnit report of pass ${pass} in it") + endif() +endforeach() +if(EXISTS "${WORK}/build/build" OR EXISTS "${WORK}/build/test-results-3.xml") + message(FATAL_ERROR "A relative build directory must not nest its reports nor keep a stale numbered report") +endif() # Recreate the successful reports to exercise cleanup when the next invocation fails early. execute_process(COMMAND "${CMAKE_COMMAND}" -DBUILD_DIR=${WORK}/build -DCONFIG=Release -DREPEAT=3 -P "${ROOT}/test/cmake/RunTestSuite.cmake" RESULT_VARIABLE result OUTPUT_VARIABLE output ERROR_VARIABLE error) diff --git a/test/cmake/RunTestSuite.cmake b/test/cmake/RunTestSuite.cmake index dd99df59..55c446cc 100644 --- a/test/cmake/RunTestSuite.cmake +++ b/test/cmake/RunTestSuite.cmake @@ -9,6 +9,8 @@ endif() if(NOT REPEAT MATCHES "^[1-9][0-9]*$") message(FATAL_ERROR "REPEAT must be a positive integer") endif() +# CTest runs in the build directory: a relative path would place a relative report path inside it, and miss the cleanup below. +cmake_path(ABSOLUTE_PATH BUILD_DIR NORMALIZE) get_filename_component(cmake_bin "${CMAKE_COMMAND}" DIRECTORY) find_program(CTEST_EXECUTABLE ctest HINTS "${cmake_bin}" REQUIRED) set(options --test-dir "${BUILD_DIR}" --output-on-failure --no-tests=error --parallel 4) From de6f14c5590593b8731fbc8a6fa6d784f24538ac Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc Date: Mon, 26 Oct 2026 12:28:07 +0100 Subject: [PATCH 5/5] Install the fast JSON parser lcov recommends in the CI image --- .github/docker/linux-ci.Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/docker/linux-ci.Dockerfile b/.github/docker/linux-ci.Dockerfile index fb08b136..3841e304 100644 --- a/.github/docker/linux-ci.Dockerfile +++ b/.github/docker/linux-ci.Dockerfile @@ -11,11 +11,12 @@ ENV DEBIAN_FRONTEND=noninteractive # sudo: the composite actions of the repository call it, as they do on a hosted runner. build-essential: the CTest # fixtures configure sub-projects with CMake's default generator and compiler, which a hosted runner also provides. +# libjson-xs-perl: a recommendation of lcov, which falls back to a pure-Perl parser about eight times slower without it. RUN apt-get update \ && apt-get install -y --no-install-recommends -o Acquire::Retries=3 \ ca-certificates curl git sudo tar xz-utils build-essential \ ninja-build pkg-config python3 \ - gcc-16 g++-16 libwebkitgtk-6.0-dev lcov \ + gcc-16 g++-16 libwebkitgtk-6.0-dev lcov libjson-xs-perl \ xvfb xauth \ && rm -rf /var/lib/apt/lists/*