Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ Important CMake options:
The headers of the embedded assets are generated, and checked by CTest, in pure CMake (`js/core/EmbedAsset.cmake`; the
`webfront-embedded-assets` target regenerates them). Normal C++ builds consume the versioned headers. Configuring with
`WEBFRONT_ENABLE_TESTING=ON` downloads the pinned bootstrap environment and the packages of the test registry, each verified
against its SHA-512; `-DWEBFRONT_BOOTSTRAP_DIR` and `-DWEBFRONT_REGISTRY_DIR` replace those downloads on a machine
without network access.
against its SHA-512, tried three times and kept once per machine (`WEBFRONT_DOWNLOAD_CACHE`, by default in CPM's cache or
the user's cache directory), so a new build tree links them instead of downloading them again; `-DWEBFRONT_BOOTSTRAP_DIR`
and `-DWEBFRONT_REGISTRY_DIR` replace those downloads on a machine without network access.

- `WEBFRONT_EMBED_CEF=OFF` (default): CEF is unavailable; this is the normal unit-test build. `ON` downloads/links CEF and enables the automated browser test; it makes `CEFFrontend` available but does not select it: `webfront::WebFront` always uses the system browser.
- `WEBFRONT_EMBED_WEBVIEW2=OFF` (default): Windows-only opt-in SDK and static loader for `WebView2Frontend`; requires the separately installed Evergreen runtime. Select it explicitly with `WebFrontWithFrontend<frontend::WebView2Frontend>`. With tests enabled, `WEBFRONT_WEBTEST_FRONTEND=WebView2` runs the shared Jasmine suite and lifecycle cases.
Expand Down
139 changes: 121 additions & 18 deletions cmake/WebFrontBootstrap.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,124 @@ set(WEBFRONT_BOOTSTRAP_INTEGRITY "sha512-qaSYOJvxcXtKIbrjfjZFFvfoQrda5NfBq24ttQ7
# A directory holding environment.tgz (the pinned archive) replaces the download on a machine without network access.
set(WEBFRONT_BOOTSTRAP_DIR "" CACHE PATH "Directory with the pinned bootstrap environment.tgz, instead of downloading it")

# The verified downloads of the configure, kept once per machine: a new build tree links them instead of downloading them
# again. WEBFRONT_DOWNLOAD_CACHE or CPM's cache chooses the place; WebFront's own build otherwise uses the user's cache
# directory, and a project that consumes WebFront keeps each download in its build tree unless it asks. An environment
# variable set to nothing counts as unset, so that it never makes a path at the root; -DWEBFRONT_DOWNLOAD_CACHE= disables
# the cache.
get_filename_component(_webfront_source "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE)
set(_webfront_download_cache "")
if(NOT "$ENV{WEBFRONT_DOWNLOAD_CACHE}" STREQUAL "")
set(_webfront_download_cache "$ENV{WEBFRONT_DOWNLOAD_CACHE}")
elseif(NOT "$ENV{CPM_SOURCE_CACHE}" STREQUAL "")
set(_webfront_download_cache "$ENV{CPM_SOURCE_CACHE}/webfront-downloads")
elseif(NOT CMAKE_SOURCE_DIR STREQUAL _webfront_source)
# A consuming project: each download stays in its build tree.
elseif(CMAKE_HOST_WIN32 AND NOT "$ENV{LOCALAPPDATA}" STREQUAL "")
set(_webfront_download_cache "$ENV{LOCALAPPDATA}/WebFront/downloads")
elseif(CMAKE_HOST_APPLE AND NOT "$ENV{HOME}" STREQUAL "")
set(_webfront_download_cache "$ENV{HOME}/Library/Caches/WebFront/downloads")
elseif(NOT "$ENV{XDG_CACHE_HOME}" STREQUAL "")
set(_webfront_download_cache "$ENV{XDG_CACHE_HOME}/webfront/downloads")
elseif(NOT "$ENV{HOME}" STREQUAL "")
set(_webfront_download_cache "$ENV{HOME}/.cache/webfront/downloads")
endif()
set(WEBFRONT_DOWNLOAD_CACHE "${_webfront_download_cache}" CACHE PATH "Directory keeping the verified configure downloads for every build tree (empty: none)")
# A download that fails is tried again, WEBFRONT_DOWNLOAD_ATTEMPTS times in all, WEBFRONT_DOWNLOAD_RETRY_DELAY seconds apart.
if(NOT DEFINED WEBFRONT_DOWNLOAD_ATTEMPTS)
set(WEBFRONT_DOWNLOAD_ATTEMPTS 3)
endif()
if(NOT DEFINED WEBFRONT_DOWNLOAD_RETRY_DELAY)
set(WEBFRONT_DOWNLOAD_RETRY_DELAY 5)
endif()

# Sets <output> to TRUE when a file can be created in <directory>, which is created when missing. An existing directory
# may still refuse files (a read-only cache, a mount of another user's): a probe file tells.
function(_webfront_writable_directory directory output)
set(${output} FALSE PARENT_SCOPE)
file(MAKE_DIRECTORY "${directory}" RESULT made)
if(NOT made EQUAL 0)
return()
endif()
string(RANDOM LENGTH 12 suffix)
set(probe "${directory}/.webfront-probe-${suffix}")
execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${probe}" RESULT_VARIABLE touched OUTPUT_QUIET ERROR_QUIET)
if(touched EQUAL 0 AND EXISTS "${probe}")
file(REMOVE "${probe}")
set(${output} TRUE PARENT_SCOPE)
endif()
endfunction()

# webfront_download_verified(<path> URL <url> SHA512 <hex> FAILURE <text> MISMATCH <text>): makes <path> a file whose SHA-512
# is <hex>. A file already there with that digest is kept. Otherwise the machine's download cache provides it, a download
# filling the cache first; <path> is then a link to the cached file, or a copy where a link cannot be made. A download that
# fails is tried again; when it still fails, the configure stops with FAILURE and the reason, and with MISMATCH when the
# data it brought has another digest. No file without the expected digest is ever left at <path> or in the cache.
function(webfront_download_verified path)
cmake_parse_arguments(ARG "" "URL;SHA512;FAILURE;MISMATCH" "" ${ARGN})
if(EXISTS "${path}")
file(SHA512 "${path}" actual)
if(actual STREQUAL ARG_SHA512)
return()
endif()
file(REMOVE "${path}")
endif()
get_filename_component(name "${path}" NAME)
get_filename_component(destination "${path}" DIRECTORY)
file(MAKE_DIRECTORY "${destination}")
set(target "${path}")
if(WEBFRONT_DOWNLOAD_CACHE)
# The first half of the digest names the entry: two files of the same name and version never meet.
string(SUBSTRING "${ARG_SHA512}" 0 32 key)
set(entry "${WEBFRONT_DOWNLOAD_CACHE}/${key}/${name}")
# A verified entry serves even a cache that cannot be written, such as a shared read-only one.
if(EXISTS "${entry}")
file(SHA512 "${entry}" actual)
if(actual STREQUAL ARG_SHA512)
file(CREATE_LINK "${entry}" "${path}" COPY_ON_ERROR)
return()
endif()
endif()
# A download fills the cache only where a file can be created; a damaged entry is replaced once verified.
_webfront_writable_directory("${WEBFRONT_DOWNLOAD_CACHE}/${key}" writable)
if(writable)
set(target "${entry}")
else()
message(WARNING "The download cache ${WEBFRONT_DOWNLOAD_CACHE} cannot be written: ${name} is kept in the build tree only")
endif()
endif()
set(present FALSE)
foreach(attempt RANGE 1 ${WEBFRONT_DOWNLOAD_ATTEMPTS})
# Written aside, then renamed once verified: a concurrent configure never reads a partial file.
string(RANDOM LENGTH 12 suffix)
set(partial "${target}.${suffix}.partial")
file(DOWNLOAD "${ARG_URL}" "${partial}" STATUS result TLS_VERIFY ON INACTIVITY_TIMEOUT 60 TIMEOUT 600)
list(GET result 0 code)
if(code EQUAL 0)
file(SHA512 "${partial}" actual)
if(NOT actual STREQUAL ARG_SHA512)
file(REMOVE "${partial}")
message(FATAL_ERROR "${ARG_MISMATCH}")
endif()
file(RENAME "${partial}" "${target}")
set(present TRUE)
break()
endif()
file(REMOVE "${partial}")
list(GET result 1 reason)
if(attempt LESS WEBFRONT_DOWNLOAD_ATTEMPTS)
message(STATUS "Download of ${ARG_URL} failed (${reason}); trying again in ${WEBFRONT_DOWNLOAD_RETRY_DELAY} s")
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep ${WEBFRONT_DOWNLOAD_RETRY_DELAY})
endif()
endforeach()
if(NOT present)
message(FATAL_ERROR "${ARG_FAILURE}: ${reason} (${WEBFRONT_DOWNLOAD_ATTEMPTS} attempts)")
endif()
if(NOT target STREQUAL path)
file(CREATE_LINK "${target}" "${path}" COPY_ON_ERROR)
endif()
endfunction()

# Converts a base64 value to lowercase hexadecimal bytes.
function(webfront_base64_to_hex value output)
set(alphabet "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")
Expand Down Expand Up @@ -86,24 +204,9 @@ function(webfront_provision_bootstrap archive)
endif()
else()
set(path "${ARG_DESTINATION}/${name}")
set(present FALSE)
if(EXISTS "${path}")
file(SHA512 "${path}" actual)
if(actual STREQUAL expected)
set(present TRUE)
endif()
endif()
if(NOT present)
file(MAKE_DIRECTORY "${ARG_DESTINATION}")
file(DOWNLOAD "${ARG_URL}" "${path}" STATUS result TLS_VERIFY ON INACTIVITY_TIMEOUT 60 TIMEOUT 600)
list(GET result 0 code)
if(NOT code EQUAL 0)
file(REMOVE "${path}")
list(GET result 1 reason)
message(FATAL_ERROR "Cannot download the bootstrap environment ${ARG_URL}: ${reason}. "
"Provision it with -DWEBFRONT_BOOTSTRAP_DIR=<directory holding ${name}>.")
endif()
endif()
webfront_download_verified("${path}" URL "${ARG_URL}" SHA512 "${expected}"
FAILURE "Cannot download the bootstrap environment ${ARG_URL}. Provision it with -DWEBFRONT_BOOTSTRAP_DIR=<directory holding ${name}>"
MISMATCH "Bootstrap environment integrity check failed for ${ARG_URL}: expected ${ARG_INTEGRITY}")
endif()
file(SHA512 "${path}" actual)
if(NOT actual STREQUAL expected)
Expand Down
25 changes: 11 additions & 14 deletions cmake/WebFrontRegistry.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,25 @@ function(webfront_provision_registry output list directory)
set(name "${CMAKE_MATCH_1}-${name}")
endif()
set(path "${directory}/${name}")
# A verified archive already in the build tree is kept: the offline directory need not stay mounted.
set(present FALSE)
if(EXISTS "${path}")
file(SHA512 "${path}" actual)
if(actual STREQUAL expected)
set(present TRUE)
endif()
endif()
if(NOT present)
if(WEBFRONT_REGISTRY_DIR)
if(NOT EXISTS "${WEBFRONT_REGISTRY_DIR}/${name}")
message(FATAL_ERROR "Test registry archive ${WEBFRONT_REGISTRY_DIR}/${name} is missing: WEBFRONT_REGISTRY_DIR must hold it")
endif()
file(COPY_FILE "${WEBFRONT_REGISTRY_DIR}/${name}" "${path}" ONLY_IF_DIFFERENT)
else()
file(DOWNLOAD "${url}" "${path}" STATUS result TLS_VERIFY ON INACTIVITY_TIMEOUT 60 TIMEOUT 600)
list(GET result 0 code)
if(NOT code EQUAL 0)
file(REMOVE "${path}")
list(GET result 1 reason)
message(FATAL_ERROR "Cannot download ${url}: ${reason}. Provision the archives with -DWEBFRONT_REGISTRY_DIR=<directory holding ${name}>.")
endif()
if(present)
continue()
elseif(WEBFRONT_REGISTRY_DIR)
if(NOT EXISTS "${WEBFRONT_REGISTRY_DIR}/${name}")
message(FATAL_ERROR "Test registry archive ${WEBFRONT_REGISTRY_DIR}/${name} is missing: WEBFRONT_REGISTRY_DIR must hold it")
endif()
file(COPY_FILE "${WEBFRONT_REGISTRY_DIR}/${name}" "${path}" ONLY_IF_DIFFERENT)
else()
webfront_download_verified("${path}" URL "${url}" SHA512 "${expected}"
FAILURE "Cannot download ${url}. Provision the archives with -DWEBFRONT_REGISTRY_DIR=<directory holding ${name}>"
MISMATCH "Integrity check failed for ${name}: expected ${integrity}")
endif()
file(SHA512 "${path}" actual)
if(NOT actual STREQUAL expected)
Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ these entries stays in the GitHub releases and the Git history.
- Run each developer integration part and each wf command of the tests in a process of its own again: the shared windows of #544 and #556 made the driver cases about a third slower on Windows and failed more often. Remove the timing analysis tools and their CI steps, and repeat the desktop suite through one path, with `desktop_passes` on a manual dispatch (#570, `docs/TEST_PERFORMANCE.md`).
- Close the test driver's window with `requestClose()` instead of asking the page: a spec that blocks the page now ends with the driver's timeout report instead of a forced exit (#570).
- Retire browser tests that repeated others: `LifeEmbeddedBuild` and `LifeEmbeddedIntegration` (the journey compiles and runs the same application from its own generated header), `WfDriverCreateStarter` and `WfDriverTestPasses` (`JourneyCreate` and `JourneyTest`), and `AutomationCliWatchdog`, whose endpoint reuse and Unicode failure checks now follow `AutomationMcpWatchdog` (#570).
- Keep the configure downloads of the tests (bootstrap environment, test registry, jasmine-core) once per machine, in `WEBFRONT_DOWNLOAD_CACHE`, and try a failed download three times: a new build tree links the verified archives instead of downloading them again (#570, `docs/DEVELOPER_ENVIRONMENT.md`).
- Declare GCC 13 as the best-effort S2 minimum for the library and examples, document the GCC 14 exit clause and qualified Clang scope, and add GCC 13 ASan/UBSan fast tests (#525, ADR-022).

- Skip the cases that configure a CMake project (label `configuration`, about 75 s of worker time) and the coverage capture on a pull request that does not change the build system, and drop the compiler-cache probe step; a push to `develop` and the full tier still run them (#545).
Expand Down
8 changes: 6 additions & 2 deletions docs/DEVELOPER_ENVIRONMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -673,8 +673,12 @@ webfront-wf --project <dir> [--environment <environment.tgz> --integrity <sha512
- Without `--environment`, it uses the **bootstrap environment** provisioned at configure time. `cmake/WebFrontBootstrap.cmake`
pins its URL and SHA-512 (distinct from `DeveloperReleaseData.hpp`, the environment applications start from, and changed
by an explicit pull request). With `WEBFRONT_ENABLE_TESTING=ON`, configure downloads it to `<build>/bootstrap/` and verifies the
digest; a wrong digest or an unreachable URL stops the configure. On a machine without network access, pass
`-DWEBFRONT_BOOTSTRAP_DIR=<directory holding environment.tgz>`: the archive is verified the same way.
digest; a wrong digest, or a URL still unreachable after three attempts, stops the configure. The verified downloads are
kept once per machine in `WEBFRONT_DOWNLOAD_CACHE` (the `WEBFRONT_DOWNLOAD_CACHE` environment variable, else
`$CPM_SOURCE_CACHE/webfront-downloads`, else the user's cache directory for WebFront's own build; a consuming project keeps
them in its build tree unless it sets one): a new build tree links them instead of downloading them again. On a machine
without network access, pass `-DWEBFRONT_BOOTSTRAP_DIR=<directory holding environment.tgz>`: the archive is verified the
same way.
- `--environment` and `--integrity` run an archive built elsewhere, such as the one built from the current sources (the
environment under test of #315). `--registry-dir` serves a local npm registry from the driver's origin and imposes it. `--manifest-dir` keeps the manifest and
the lock in that directory of the project (usage error 64 when it is absolute, has an empty or dot component or leaves the project).
Expand Down
Loading
Loading