From 4119d80c41c6caafd93ba30eb1f170404cf53e1d Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Mon, 9 Nov 2026 16:46:52 +0100 Subject: [PATCH 01/13] Add the release-developer workflow and its checks (#482) Phase 1 of ADR-021, repository side: - release-developer workflow: double build, closed list of paths committed on release/developer-, tag in the same run, publication, verification of the deployed bytes, pull request into develop with the application's token; permissions declared job by job and checked by a test. - wf run pin fails when the pinned URL is off the origin of baseUrl, redirects or lacks CORS; previousBase carries the bounded migration waiver. - Consistency test of the pin states (a) to (c) and of the inconsistencies. - Compatibility table maintained by cmake/DeveloperCompatibility.cmake and required for v* tags by CheckReleaseVersion.cmake. - PUBLISHING.md describes the workflow; the manual procedure is the fallback. --- .github/workflows/ReleaseDeveloper.yml | 281 ++++++++++++++++++++ cmake/DeveloperCompatibility.cmake | 62 +++++ docs/CHANGELOG.md | 9 + docs/DEVELOPER_ENVIRONMENT.md | 20 ++ js/developer/scripts/pin.mjs | 29 +- js/developer/tools/PUBLISHING.md | 53 +++- js/developer/tools/check-release-paths.sh | 19 ++ test/cmake/CheckDeveloperPin.cmake | 66 +++++ test/cmake/CheckDeveloperPinTests.cmake | 67 +++++ test/cmake/CheckReleasePaths.cmake | 40 +++ test/cmake/CheckReleaseVersion.cmake | 21 ++ test/cmake/CheckReleaseVersionTests.cmake | 15 ++ test/cmake/CheckReleaseWorkflow.cmake | 104 ++++++++ test/cmake/CheckReleaseWorkflowTests.cmake | 47 ++++ test/developer/specs/distribution-specs.mjs | 34 +++ test/unit/CMakeLists.txt | 18 ++ 16 files changed, 875 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/ReleaseDeveloper.yml create mode 100644 cmake/DeveloperCompatibility.cmake create mode 100755 js/developer/tools/check-release-paths.sh create mode 100644 test/cmake/CheckDeveloperPin.cmake create mode 100644 test/cmake/CheckDeveloperPinTests.cmake create mode 100644 test/cmake/CheckReleasePaths.cmake create mode 100644 test/cmake/CheckReleaseWorkflow.cmake create mode 100644 test/cmake/CheckReleaseWorkflowTests.cmake diff --git a/.github/workflows/ReleaseDeveloper.yml b/.github/workflows/ReleaseDeveloper.yml new file mode 100644 index 00000000..c2b7a906 --- /dev/null +++ b/.github/workflows/ReleaseDeveloper.yml @@ -0,0 +1,281 @@ +name: release-developer + +# One workflow publishes a version of the developer environment (ADR-021): it builds twice, commits the closed list of +# paths on release/developer-, tags, publishes, verifies the deployed bytes and opens the pull request that merges +# the pin into develop. With publish=false it stops after the rehearsal: nothing is pushed, tagged or published. +# The GITHUB_TOKEN has no permission by default; each job declares exactly its own (table of ADR-021, decision 1). + +on: + workflow_dispatch: + inputs: + version: + description: Version of the environment to release (MAJOR.MINOR.PATCH, greater than the one of distribution.json) + type: string + required: true + publish: + description: Publish (false runs the rehearsal on the candidate bytes only) + type: boolean + default: false + +permissions: {} + +concurrency: + group: release-developer + cancel-in-progress: false + +env: + VERSION: ${{ inputs.version }} + # The closed list of paths of the release commit: the step that commits fails when the diff touches another one. + RELEASE_PATHS: >- + js/developer/tools/distribution.json + include/webfront/system/DeveloperReleaseData.hpp + js/developer/environment/bundles.json + js/core/bootstrap/bootstrap.bundle.mjs + js/developer/environment/packages.bundle.mjs + include/webfront/system/DeveloperBootstrapData.hpp + include/webfront/system/DeveloperIndexHtmlData.hpp + docs/DEVELOPER_ENVIRONMENT.md + +jobs: + # Construction and rehearsal: contents: read, no destination but the artifact. + wf-package: + runs-on: ubuntu-26.04 + timeout-minutes: 30 + permissions: + contents: read + steps: + - uses: actions/checkout@v7 + with: + ref: develop + persist-credentials: false + - name: Check the requested version + run: | + [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "::error::Version must be MAJOR.MINOR.PATCH"; exit 1; } + current=$(jq -r .version js/developer/tools/distribution.json) + if [ "$(printf '%s\n%s\n' "$current" "$VERSION" | sort -V | tail -n 1)" != "$VERSION" ] || [ "$current" = "$VERSION" ]; then + echo "::error::Version $VERSION must be greater than the current $current" + exit 1 + fi + - uses: ./.github/actions/remove-node + - uses: ./.github/actions/wf-driver + - name: Set the version + run: | + jq --arg version "$VERSION" '.version = $version' js/developer/tools/distribution.json > "$RUNNER_TEMP/distribution.json" + cp "$RUNNER_TEMP/distribution.json" js/developer/tools/distribution.json + - name: Restore the locked build dependencies + run: wf restore + - name: Build twice, refreshing the checked-in bootstrap, and compare + run: | + wf run build build-distribution --refresh-bootstrap + wf run build build-distribution-repeat + for name in environment.tgz life-starter.tgz provision.json DeveloperReleaseData.hpp; do + cmp "build-distribution/$name" "build-distribution-repeat/$name" + done + cmp include/webfront/system/DeveloperReleaseData.hpp build-distribution/DeveloperReleaseData.hpp + - name: Render the embedded headers and the compatibility table + run: | + cmake --build build-driver --target webfront-embedded-assets + cmake -DROOT="$PWD" -DMODE=unreleased -P cmake/DeveloperCompatibility.cmake + - name: Check the closed list of paths + run: | + # shellcheck disable=SC2086 + bash js/developer/tools/check-release-paths.sh $RELEASE_PATHS + - name: Check the consistency of the new pin + run: cmake -DROOT="$PWD" -P test/cmake/CheckDeveloperPin.cmake + - name: Run the specs of the environment + run: wf test --timeout 300 + - name: Collect the release files + run: | + mkdir release-files + # shellcheck disable=SC2086 + tar -cf release-files/paths.tar $RELEASE_PATHS + - uses: actions/upload-artifact@v4 + with: + name: release-files + if-no-files-found: error + path: release-files/paths.tar + - uses: actions/upload-artifact@v4 + with: + name: developer-distribution + if-no-files-found: error + path: | + build-distribution/environment.tgz + build-distribution/life-starter.tgz + build-distribution/provision.json + build-distribution/DeveloperReleaseData.hpp + + # Preparation: the application's token pushes the release branch only (never develop or master); the GITHUB_TOKEN reads. + prepare: + if: inputs.publish + needs: wf-package + runs-on: ubuntu-26.04 + timeout-minutes: 10 + environment: developer-release-app + permissions: + contents: read + outputs: + commit: ${{ steps.commit.outputs.commit }} + steps: + - uses: actions/create-github-app-token@v2 + id: app + with: + app-id: ${{ vars.RELEASE_APP_ID }} + private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }} + - uses: actions/checkout@v7 + with: + ref: develop + token: ${{ steps.app.outputs.token }} + - uses: actions/download-artifact@v4 + with: + name: release-files + path: release-files + - name: Commit the closed list of paths on the release branch + id: commit + run: | + branch="release/developer-$VERSION" + if git ls-remote --exit-code --heads origin "$branch" > /dev/null; then + echo "::error::$branch already exists" + exit 1 + fi + git switch -c "$branch" + tar -xf release-files/paths.tar + rm -rf release-files + # shellcheck disable=SC2086 + bash js/developer/tools/check-release-paths.sh $RELEASE_PATHS + git config user.name "webfront-release[bot]" + git config user.email "webfront-release[bot]@users.noreply.github.com" + # shellcheck disable=SC2086 + git add -- $RELEASE_PATHS + git commit -m "Pin developer environment $VERSION" + git push origin "HEAD:refs/heads/$branch" + echo "commit=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" + + # The tag is set by this run, after the build succeeded: a tag pushed with the GITHUB_TOKEN would not start another run. + tag: + needs: prepare + runs-on: ubuntu-26.04 + timeout-minutes: 5 + permissions: + contents: write + steps: + - name: Tag the release commit + env: + GH_TOKEN: ${{ github.token }} + COMMIT: ${{ needs.prepare.outputs.commit }} + run: | + gh api --method POST "repos/$GITHUB_REPOSITORY/git/refs" -f "ref=refs/tags/developer-v$VERSION" -f "sha=$COMMIT" > /dev/null + + publish: + needs: [prepare, tag] + runs-on: ubuntu-26.04 + timeout-minutes: 15 + environment: developer-pages-publication + permissions: + contents: write + pages: write + concurrency: + group: developer-pages-publication + cancel-in-progress: false + env: + GH_TOKEN: ${{ github.token }} + steps: + - uses: actions/checkout@v7 + with: + ref: ${{ needs.prepare.outputs.commit }} + - uses: ./.github/actions/remove-node + - uses: ./.github/actions/wf-driver + - name: Restore the locked build dependencies + run: wf restore + - uses: actions/download-artifact@v4 + with: + name: developer-distribution + path: build-distribution + - name: Check the configured Pages source before pushing + run: bash js/developer/tools/pages.sh --check + - name: Preserve existing versions and publish the static branch + shell: bash + run: | + set -euo pipefail + gh auth setup-git + site=build-site + git init --initial-branch=gh-pages "$site" + git -C "$site" remote add origin "https://github.com/$GITHUB_REPOSITORY.git" + result=0 + git -C "$site" ls-remote --exit-code --heads origin gh-pages > "$RUNNER_TEMP/developer-pages-ref" || result=$? + if [ "$result" = 0 ]; then + git -C "$site" fetch --depth=1 origin gh-pages + git -C "$site" switch --detach FETCH_HEAD + elif [ "$result" != 2 ]; then + exit "$result" + fi + host=$(jq -r '.baseUrl | sub("^https://"; "") | sub("[/:].*$"; "")' js/developer/tools/distribution.json) + case "$host" in *.github.io) git -C "$site" rm -q --ignore-unmatch CNAME ;; esac + wf run site build-distribution "$site" + git -C "$site" config user.name "$GITHUB_ACTOR" + git -C "$site" config user.email "$GITHUB_ACTOR@users.noreply.github.com" + git -C "$site" add .nojekyll index.html developer + if [ -e "$site/CNAME" ]; then git -C "$site" add CNAME; fi + if ! git -C "$site" diff --cached --quiet; then + git -C "$site" commit -m "Publish developer packages $VERSION [#288]" + git -C "$site" push origin HEAD:refs/heads/gh-pages + fi + - name: Request the configured Pages build + run: bash js/developer/tools/pages.sh + - name: Archive the packages in a dedicated prerelease + run: bash js/developer/tools/archive-release.sh "developer-v$VERSION" build-distribution + + # The deployed bytes, the pinned URL and the access from a browser; a transient failure is retried with the same bytes. + verify: + needs: [prepare, publish] + runs-on: ubuntu-26.04 + timeout-minutes: 30 + permissions: + contents: read + steps: + - uses: actions/checkout@v7 + with: + ref: ${{ needs.prepare.outputs.commit }} + persist-credentials: false + - uses: ./.github/actions/remove-node + - uses: ./.github/actions/wf-driver + - name: Restore the locked build dependencies + run: wf restore + - name: Check the deployed bytes and the pinned URL + run: | + for attempt in 1 2 3 4 5 6; do + if wf run pin; then exit 0; fi + echo "::notice::Attempt $attempt failed; Pages may still be building" + sleep 30 + done + exit 1 + - name: Run the public smoke test from the pinned header + run: | + cmake -S . -B build-public -G Ninja -DCMAKE_BUILD_TYPE=Release -DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_ENABLE_TESTING=ON \ + -DWEBFRONT_EMBED_WEBKITGTK=ON -DWEBFRONT_WEBTEST_FRONTEND=WebKitGTK -DCMAKE_CXX_SCAN_FOR_MODULES=OFF + cmake --build build-public --target developer_integration --parallel 2 + ctest --test-dir build-public -R '^DeveloperFixtures$' --output-on-failure --no-tests=error + xvfb-run -a ./build-public/test/web/developer_integration \ + "$PWD/build-public/test/web/developer-fixtures" "$PWD/build-public/test/web/public-generated" --public + + # The pull request carries the application's identity so that BuildAndTest.yml and DeveloperDistribution.yml run on it. + # It is not merged here: the review that protects develop stays. + pull-request: + needs: [prepare, verify] + runs-on: ubuntu-26.04 + timeout-minutes: 5 + environment: developer-release-app + permissions: + contents: read + steps: + - uses: actions/create-github-app-token@v2 + id: app + with: + app-id: ${{ vars.RELEASE_APP_ID }} + private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }} + - name: Open the pull request into develop + env: + GH_TOKEN: ${{ steps.app.outputs.token }} + run: | + gh pr create --repo "$GITHUB_REPOSITORY" --base develop --head "release/developer-$VERSION" \ + --title "Pin developer environment $VERSION" \ + --body "Pins the published developer environment $VERSION (tag developer-v$VERSION, deployed bytes verified by the release-developer workflow, run $GITHUB_RUN_ID)." diff --git a/cmake/DeveloperCompatibility.cmake b/cmake/DeveloperCompatibility.cmake new file mode 100644 index 00000000..518f4f7f --- /dev/null +++ b/cmake/DeveloperCompatibility.cmake @@ -0,0 +1,62 @@ +# Maintains the compatibility table of docs/DEVELOPER_ENVIRONMENT.md (ADR-021, decision 4), in pure CMake: +# +# cmake -DROOT= -DMODE=unreleased -P cmake/DeveloperCompatibility.cmake +# rewrites the "unreleased" row from DeveloperReleaseData.hpp and developer::apiVersion (the release workflow) +# cmake -DROOT= -DMODE=freeze -DLIBRARY_VERSION= -P cmake/DeveloperCompatibility.cmake +# freezes the "unreleased" row into a row of that library version (the preparation of a library release) +# +# The table lies between the markers below; a row is "| library | environment | minimum api |". +cmake_minimum_required(VERSION 3.31) +if(NOT ROOT OR NOT MODE) + message(FATAL_ERROR "ROOT and MODE (unreleased or freeze) are required") +endif() + +set(document "${ROOT}/docs/DEVELOPER_ENVIRONMENT.md") +set(begin_marker "") +set(end_marker "") + +file(READ "${ROOT}/include/webfront/system/DeveloperReleaseData.hpp" header) +if(NOT header MATCHES "version\{\"([^\"]*)\"\}") + message(FATAL_ERROR "DeveloperReleaseData.hpp has no version") +endif() +set(environment "${CMAKE_MATCH_1}") +file(READ "${ROOT}/include/webfront/DeveloperApp.hpp" application) +if(NOT application MATCHES "apiVersion *= *([0-9]+);") + message(FATAL_ERROR "DeveloperApp.hpp has no apiVersion") +endif() +set(api "${CMAKE_MATCH_1}") + +file(READ "${document}" content) +string(FIND "${content}" "${begin_marker}" begin_at) +string(FIND "${content}" "${end_marker}" end_at) +if(begin_at EQUAL -1 OR end_at EQUAL -1 OR end_at LESS begin_at) + message(FATAL_ERROR "The compatibility table markers are missing from DEVELOPER_ENVIRONMENT.md") +endif() +string(LENGTH "${begin_marker}" begin_length) +math(EXPR table_at "${begin_at} + ${begin_length}") +math(EXPR table_length "${end_at} - ${table_at}") +string(SUBSTRING "${content}" 0 ${table_at} before) +string(SUBSTRING "${content}" ${table_at} ${table_length} table) +string(SUBSTRING "${content}" ${end_at} -1 after) + +string(REGEX MATCH "[|] unreleased [|][^\n]*\n" unreleased_row "${table}") +if(NOT unreleased_row) + message(FATAL_ERROR "The compatibility table has no unreleased row") +endif() +set(new_unreleased "| unreleased | ${environment} | ${api} |\n") + +if(MODE STREQUAL "unreleased") + string(REPLACE "${unreleased_row}" "${new_unreleased}" table "${table}") +elseif(MODE STREQUAL "freeze") + if(NOT LIBRARY_VERSION MATCHES "^[0-9]+\.[0-9]+\.[0-9]+$") + message(FATAL_ERROR "LIBRARY_VERSION must be MAJOR.MINOR.PATCH") + endif() + if(table MATCHES "[|] ${LIBRARY_VERSION} [|]") + message(FATAL_ERROR "The compatibility table already has a row for ${LIBRARY_VERSION}") + endif() + string(REPLACE "${unreleased_row}" "${new_unreleased}| ${LIBRARY_VERSION} | ${environment} | ${api} |\n" table "${table}") +else() + message(FATAL_ERROR "MODE must be unreleased or freeze") +endif() +file(WRITE "${document}" "${before}${table}${after}") +message(STATUS "Compatibility table (${MODE}): environment ${environment}, api ${api}") diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 31d1e9d8..e8eaa9f7 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -11,6 +11,15 @@ thread (message-only window pump, AppKit run loop with `NSApplication` in the Accessory policy, GLib loop; all loaded at run time, nothing to link) that ends with `requestStop()`; the plain browser frontend still has no executor. Catch2 tests with a simulated loop and the shared lifecycle case `ui-executor` (execution on the interface thread, race with closure, call after closure). +- Release workflow of the developer environment (#482, ADR-021 phase 1; repository side). The `release-developer` workflow + (`.github/workflows/ReleaseDeveloper.yml`) builds twice, commits a closed list of paths on `release/developer-` + with a dedicated GitHub application's token, tags in the same run, publishes, verifies the deployed bytes and opens the + pull request into `develop`; its permissions are declared job by job and checked by `ReleaseDeveloperWorkflow`. + `wf run pin` now fails (instead of warning) when the pinned URL is off the origin of `baseUrl`, redirects or lacks CORS, + and reads `previousBase` for the bounded migration waiver. `DeveloperPinConsistency` checks the states (a) to (c) and the + inconsistencies of ADR-021 decision 2. The compatibility table of `docs/DEVELOPER_ENVIRONMENT.md` is maintained by + `cmake/DeveloperCompatibility.cmake` and enforced on `v*` tags by `CheckReleaseVersion.cmake`. The application, the tag rule + and the first real publication are repository operations that remain to be done by a maintainer. - `@webfront/services` package (#461, ADR-010 1.8, ADR-020 step 4). The browser side of the optional system services is delivered outside the core, like `@webfront/react`: `js/services/` (a skeleton: an empty frozen `services` object and `selfTest()`, declarations, license), `wf run services-package` for its deterministic archive and SHA-512, the same diff --git a/docs/DEVELOPER_ENVIRONMENT.md b/docs/DEVELOPER_ENVIRONMENT.md index 5b6ecfe4..32eece17 100644 --- a/docs/DEVELOPER_ENVIRONMENT.md +++ b/docs/DEVELOPER_ENVIRONMENT.md @@ -583,6 +583,26 @@ a missing archive and archives with an incompatible protocol or API. `BootstrapP configure-time provisioning (verified download, reuse, local directory, wrong digest, malformed value). The Linux CEF CI job blocks the public network after the configure step. +## Compatibility table + +Which environment accompanies which library version (ADR-021). The two cycles are independent: the first row, **unreleased**, +is the environment pinned by `develop` and is rewritten by the `release-developer` workflow at each pin; preparing a library +release freezes it into a row carrying that library's version (`cmake -DROOT=. -DMODE=freeze -DLIBRARY_VERSION= -P +cmake/DeveloperCompatibility.cmake`, from the `DeveloperReleaseData.hpp` of the release commit). `CheckReleaseVersion.cmake` +fails a `v*` tag whose version has no row, or whose row differs from that header. A release published without a new +environment therefore reuses the previous one. "Minimum api" is `developer::apiVersion` (see the compatibility contract +above). Rows before 0.9 were reconstructed from the header of each tag; 0.4.0 predates the pin. + + +| Library | Environment | Minimum api | +| --- | --- | --- | +| unreleased | 0.6.6 | 1 | +| 0.8.0 | 0.6.3 | 1 | +| 0.7.0 | 0.6.3 | 1 | +| 0.6.0 | 0.6.3 | 1 | +| 0.5.0 | 0.6.2 | 1 | + + ## Dependencies, storage and limitations - `wf install` accepts exact versions, registry tags and semver ranges, resolves ordinary diff --git a/js/developer/scripts/pin.mjs b/js/developer/scripts/pin.mjs index 8ce95967..0ff2b5c0 100644 --- a/js/developer/scripts/pin.mjs +++ b/js/developer/scripts/pin.mjs @@ -17,19 +17,30 @@ export default async function (context) { const marker = `developer/${version}/environment.tgz`; if (!url.endsWith('/' + marker) || header !== bootstrapHeader(version, url.slice(0, -marker.length), integrity)) throw new Error(`DeveloperReleaseData.hpp is not the header generated for the published ${version}`); - // The archive is fetched where the distribution is served now. A version pinned under a previous address (the - // github.io one, which redirects to the custom domain without CORS headers, so that a browser cannot follow it) is the - // same file there: the pinned integrity is what proves it. - const current = baseUrl(JSON.parse(await project.readText('js/developer/tools/distribution.json')).baseUrl); + // (ii) The pinned URL itself: on the origin of baseUrl, or under the declared migration waiver (ADR-021). + const distribution = JSON.parse(await project.readText('js/developer/tools/distribution.json')); + const current = baseUrl(distribution.baseUrl); + const {waiver, warning} = pinOrigin(url, current, distribution.previousBase); + // (i) The bytes, fetched where the distribution is served now: the pinned integrity proves the file. const served = new URL(marker, current).href; const response = await context.fetch(served, {signal: context.signal}); if (!response.ok) throw new Error(`The pinned environment ${served} is not published (${response.status})`); if (await sriOf(new Uint8Array(await response.arrayBuffer())) !== integrity) throw new Error(`The published ${served} does not have the pinned integrity`); + if (waiver) { + context.console.warn(`WARNING: ${warning}`); + } else if (served !== url) { + // (ii) and (iii): the script's fetch rejects a redirect, and a cross-origin fetch from its Worker succeeds only + // with valid CORS headers. + let pinned; + try { + pinned = await context.fetch(url, {signal: context.signal}); + } catch (error) { + throw new Error(`The pinned ${url} cannot be fetched without redirection and with CORS headers: ${error.message}`); + } + if (pinned.status !== 200) throw new Error(`The pinned ${url} answers ${pinned.status}, not 200`); + if (await sriOf(new Uint8Array(await pinned.arrayBuffer())) !== integrity) + throw new Error(`The archive at the pinned ${url} does not have the pinned integrity`); + } context.console.log(`DeveloperReleaseData.hpp pins the published ${version}.`); - // The check above proves the bytes, not that a browser can start from the pinned address: when that address is not - // the one the distribution is served from, the pinned URL redirects without CORS headers and an application built with - // this header cannot start its developer environment until a version pinned on the current address is published. - if (new URL(url).origin !== new URL(current).origin) - context.console.log(`WARNING: the pinned ${url} is not on ${new URL(current).origin}; its redirect carries no CORS headers, so a browser cannot start the developer environment from this pin.`); } diff --git a/js/developer/tools/PUBLISHING.md b/js/developer/tools/PUBLISHING.md index ca1a1b69..fc4cc399 100644 --- a/js/developer/tools/PUBLISHING.md +++ b/js/developer/tools/PUBLISHING.md @@ -10,6 +10,57 @@ The environment builds itself: the pinned bootstrap environment (`cmake/WebFront lock). Building, reviewing and publishing need a C++23 compiler, CMake, the engine of the driver's frontend and `gh` and `jq` for the host operations. +## Releasing with the workflow + +The **release-developer** workflow (`.github/workflows/ReleaseDeveloper.yml`, ADR-021) is the way to publish a version. Dispatch +it on `develop` with the version (greater than the one of `distribution.json`): + +```sh +gh workflow run release-developer.yml --ref develop -f version=0.6.7 -f publish=false # rehearsal +gh workflow run release-developer.yml --ref develop -f version=0.6.7 -f publish=true # release +``` + +The jobs run in this order, and each declares only the permissions of the table of ADR-021 (`ReleaseDeveloperWorkflow` checks them): + +1. `wf-package` (`contents: read`): sets the version, builds twice with `--refresh-bootstrap`, compares the repeat build and the + header, renders the embedded headers and the **unreleased** row of the compatibility table, fails if the diff touches a path + outside `RELEASE_PATHS` (declared once in the workflow; `check-release-paths.sh`), checks the pin (`CheckDeveloperPin.cmake`) + and runs the specs. With `publish=false` the workflow ends here: nothing is pushed, tagged or published. +2. `prepare`: with the token of the dedicated GitHub application, commits that closed list of paths on + `release/developer-` (never `develop` or `master`); an existing branch stops the run. +3. `tag`: sets `developer-v` on that commit, in the same run. +4. `publish`: stages the site on `gh-pages` (immutable versions, no force-push), requests the Pages build and archives the + prerelease. +5. `verify`: `wf run pin` (bytes, pinned URL without redirection, CORS; retried while Pages builds) and the public smoke test. +6. `pull-request`: with the application's token, opens the pull request of the release branch into `develop`. It is not merged by + the workflow: the review and the required checks of `develop` apply, and they run because the pull request is not created + with the `GITHUB_TOKEN`. + +**Resuming.** A failure of `wf-package` or `prepare` leaves nothing pushed or deployed (delete the release branch if `prepare` +pushed it) and the same version can be dispatched again. Once `tag` has run, the tag rule `developer-tags` forbids moving or +deleting `developer-v`: a failure of `tag` or `publish` after it is resumed by re-running the failed jobs of the same +run, which publishes the same bytes, and a defect found at that point requires the next version. A failure of `verify` after `publish` is a transient fault if +`wf run pin` succeeds on a rerun (re-run the failed jobs: the bytes are the same) and a defect otherwise, which requires a new +version. A failed `verify` opens no pull request and changes neither `develop` nor `master`. + +`pin.mjs` (`wf run pin`) fails when the pinned URL is not on the origin of `baseUrl`, redirects, or lacks CORS headers. The only +exception is a migration, declared by `previousBase` in `distribution.json` while the header still pins a version published +under that address; it prints a warning, and is refused as soon as the header pins a version published under the new address. + +**Repository settings the workflow needs** (made by a maintainer, not by the workflow): + +- a GitHub application with `pull-requests: write` and `contents: write` only, installed on this repository; its identifier is + the variable `RELEASE_APP_ID` and its private key the secret `RELEASE_APP_PRIVATE_KEY` of the protected environment + `developer-release-app`; +- a tag rule on `developer-v*` forbidding updates and deletions; +- the branch protection of `develop` and `master` must not cover `release/*`, and the application has no bypass; +- the Pages source and the environment `developer-pages-publication` unchanged ("One-time Pages configuration" below). + +The library's release preparation freezes the compatibility table with `cmake -DROOT=. -DMODE=freeze -DLIBRARY_VERSION= -P +cmake/DeveloperCompatibility.cmake`; `CheckReleaseVersion.cmake` fails a `v*` tag without its row. + +The sections below describe the building blocks and the manual procedure, which remains the fallback when the workflow cannot run. + ## Build and review The driver `webfront-wf` runs one `wf` command without interaction on a project (here, the repository). Any frontend @@ -50,7 +101,7 @@ The static branch preserves every version. Republishing identical bytes is allow published version with different bytes fails. Increment `distribution.json` before publishing any changed environment, starter, public URL or provisioning configuration. -## Pinning a new version +## Pinning a new version (manual fallback) `distribution.json` names the version under development; `DeveloperReleaseData.hpp` pins the last version that is published. Pull requests and branch pushes therefore require the header to match a fresh build only when both name diff --git a/js/developer/tools/check-release-paths.sh b/js/developer/tools/check-release-paths.sh new file mode 100755 index 00000000..f7d5018c --- /dev/null +++ b/js/developer/tools/check-release-paths.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# Fails when the working tree differs from HEAD on a path outside the closed list of the release commit (ADR-021, decision 1), +# or when an untracked file exists. The list is the arguments: the release-developer workflow declares it once. +# check-release-paths.sh ... +set -euo pipefail + +[ "$#" -gt 0 ] || { echo "Usage: check-release-paths.sh ..." >&2; exit 2; } +status=0 +while IFS= read -r -d '' changed; do + allowed=false + for path in "$@"; do + if [ "$changed" = "$path" ]; then allowed=true; break; fi + done + if [ "$allowed" = false ]; then + echo "::error::The release changes $changed, which is not in the closed list of paths" >&2 + status=1 + fi +done < <({ git diff --name-only -z HEAD; git ls-files --others --exclude-standard -z; }) +exit "$status" diff --git a/test/cmake/CheckDeveloperPin.cmake b/test/cmake/CheckDeveloperPin.cmake new file mode 100644 index 00000000..a045145d --- /dev/null +++ b/test/cmake/CheckDeveloperPin.cmake @@ -0,0 +1,66 @@ +# Offline consistency of the developer pin (ADR-021, decision 2), in pure CMake. The three places that name a version: +# distribution.json the sources' version (may be ahead of the pin: state (a)) +# DeveloperReleaseData.hpp the version applications accept +# WebFrontBootstrap.cmake the version the tests run (the header's, or an earlier published one: state (c)) +# Normal: distribution == header or ahead of it; bootstrap <= header. Inconsistent: a header newer than distribution.json, a +# header whose URL is not the one of its own version, a bootstrap newer than the header, or a bootstrap equal to the header +# with another URL or integrity. The bytes and the origin of the pinned URL are checked by `wf run pin`; a header equal to a +# fresh build, by the comparison of the Developer packages workflow. ROOT is the repository (or a fixture of it). +cmake_minimum_required(VERSION 3.31) +if(NOT ROOT) + message(FATAL_ERROR "ROOT is required") +endif() + +file(READ "${ROOT}/js/developer/tools/distribution.json" distribution) +string(JSON sources_version GET "${distribution}" version) + +file(READ "${ROOT}/include/webfront/system/DeveloperReleaseData.hpp" header) +foreach(field version environment integrity) + if(NOT header MATCHES "${field}\{\"([^\"]*)\"\}") + message(FATAL_ERROR "DeveloperReleaseData.hpp has no ${field}") + endif() + set(header_${field} "${CMAKE_MATCH_1}") +endforeach() + +file(READ "${ROOT}/cmake/WebFrontBootstrap.cmake" bootstrap) +foreach(field VERSION URL INTEGRITY) + if(NOT bootstrap MATCHES "WEBFRONT_BOOTSTRAP_${field} \"([^\"]*)\"") + message(FATAL_ERROR "WebFrontBootstrap.cmake has no WEBFRONT_BOOTSTRAP_${field}") + endif() + set(bootstrap_${field} "${CMAKE_MATCH_1}") +endforeach() + +if(header_version VERSION_GREATER sources_version) + message(FATAL_ERROR "DeveloperReleaseData.hpp pins ${header_version}, newer than distribution.json ${sources_version}") +endif() +if(NOT header_environment MATCHES "/developer/${header_version}/environment\.tgz$") + message(FATAL_ERROR "DeveloperReleaseData.hpp is not the header of its version ${header_version}: ${header_environment}") +endif() +if(bootstrap_VERSION VERSION_GREATER header_version) + message(FATAL_ERROR "The bootstrap ${bootstrap_VERSION} is ahead of the header ${header_version}") +endif() +if(NOT bootstrap_URL MATCHES "/developer/${bootstrap_VERSION}/environment\.tgz$") + message(FATAL_ERROR "The bootstrap URL is not the one of its version ${bootstrap_VERSION}: ${bootstrap_URL}") +endif() +if(bootstrap_VERSION VERSION_EQUAL header_version + AND (NOT bootstrap_URL STREQUAL header_environment OR NOT bootstrap_INTEGRITY STREQUAL header_integrity)) + message(FATAL_ERROR "The bootstrap and the header both name ${header_version} with a different URL or integrity") +endif() + +if(header_version VERSION_EQUAL sources_version) + set(state "(b) sources equal to the header") +else() + set(state "(a) sources ${sources_version} ahead of the header") +endif() +message(STATUS "Developer pin: ${state}; header ${header_version}; bootstrap ${bootstrap_VERSION}") + +# The "unreleased" row of the compatibility table follows the header (the release workflow rewrites it at each pin). +if(EXISTS "${ROOT}/docs/DEVELOPER_ENVIRONMENT.md") + file(READ "${ROOT}/docs/DEVELOPER_ENVIRONMENT.md" environment_document) + if(NOT environment_document MATCHES "\n[|] unreleased [|] ([^ |]+) [|]") + message(FATAL_ERROR "The compatibility table has no unreleased row") + endif() + if(NOT "${CMAKE_MATCH_1}" STREQUAL "${header_version}") + message(FATAL_ERROR "The unreleased row of the compatibility table names ${CMAKE_MATCH_1}, not the pinned ${header_version}") + endif() +endif() diff --git a/test/cmake/CheckDeveloperPinTests.cmake b/test/cmake/CheckDeveloperPinTests.cmake new file mode 100644 index 00000000..07ff8c06 --- /dev/null +++ b/test/cmake/CheckDeveloperPinTests.cmake @@ -0,0 +1,67 @@ +# Regression for CheckDeveloperPin.cmake: each normal state is accepted and each inconsistency of ADR-021 fails. +cmake_minimum_required(VERSION 3.31) +if(NOT ROOT OR NOT WORK) + message(FATAL_ERROR "ROOT and WORK are required") +endif() + +string(REPEAT "A" 86 digest_a) +string(REPEAT "B" 86 digest_b) + +function(fixture directory sources header bootstrap) + file(REMOVE_RECURSE "${WORK}/${directory}") + file(MAKE_DIRECTORY "${WORK}/${directory}/js/developer/tools" "${WORK}/${directory}/include/webfront/system" + "${WORK}/${directory}/cmake") + file(WRITE "${WORK}/${directory}/js/developer/tools/distribution.json" "{\"version\": \"${sources}\", \"baseUrl\": \"https://dist.example/\"}") + # header and bootstrap are "[:[:]]". + foreach(kind header bootstrap) + string(REPLACE ":" ";" parts "${${kind}}") + list(GET parts 0 version) + list(LENGTH parts count) + set(url_version "${version}") + set(digest "${digest_a}") + if(count GREATER 1) + list(GET parts 1 url_version) + endif() + if(count GREATER 2) + list(GET parts 2 digest) + set(digest "${digest_${digest}}") + endif() + set(${kind}_version "${version}") + set(${kind}_url "https://dist.example/developer/${url_version}/environment.tgz") + set(${kind}_digest "sha512-${digest}==") + endforeach() + file(WRITE "${WORK}/${directory}/include/webfront/system/DeveloperReleaseData.hpp" + "inline constexpr std::string_view version{\"${header_version}\"};\n" + "inline constexpr std::string_view environment{\"${header_url}\"};\n" + "inline constexpr std::string_view integrity{\"${header_digest}\"};\n") + file(WRITE "${WORK}/${directory}/cmake/WebFrontBootstrap.cmake" + "set(WEBFRONT_BOOTSTRAP_VERSION \"${bootstrap_version}\")\n" + "set(WEBFRONT_BOOTSTRAP_URL \"${bootstrap_url}\")\n" + "set(WEBFRONT_BOOTSTRAP_INTEGRITY \"${bootstrap_digest}\")\n") +endfunction() + +function(check description expected message sources header bootstrap) + fixture(case "${sources}" "${header}" "${bootstrap}") + execute_process(COMMAND "${CMAKE_COMMAND}" "-DROOT=${WORK}/case" -P "${ROOT}/test/cmake/CheckDeveloperPin.cmake" + RESULT_VARIABLE result OUTPUT_VARIABLE output ERROR_VARIABLE error) + if(expected STREQUAL "accept" AND NOT result EQUAL 0) + message(FATAL_ERROR "${description}: refused: ${output}${error}") + elseif(expected STREQUAL "refuse" AND result EQUAL 0) + message(FATAL_ERROR "${description}: accepted") + endif() + if(NOT "${output}${error}" MATCHES "${message}") + message(FATAL_ERROR "${description}: missing diagnostic '${message}': ${output}${error}") + endif() +endfunction() + +# Normal states. +check("(a) sources ahead of the header" accept "Developer pin: [(]a[)]" 0.6.6 0.6.5 0.6.5) +check("(b) sources equal to the header" accept "Developer pin: [(]b[)]" 0.6.5 0.6.5 0.6.5) +check("(c) bootstrap earlier than the header" accept "bootstrap 0.6.4" 0.6.6 0.6.5 0.6.4) +check("(c) bootstrap earlier, sources equal" accept "bootstrap 0.6.4" 0.6.5 0.6.5 0.6.4) +# Inconsistencies. +check("header newer than the sources" refuse "newer than distribution.json" 0.6.4 0.6.5 0.6.4) +check("header that is not its version's" refuse "not the header of its version" 0.6.6 0.6.5:0.6.4 0.6.4) +check("bootstrap ahead of the header" refuse "ahead of the header" 0.6.6 0.6.4 0.6.5) +check("bootstrap that is not its version's" refuse "not the one of its version" 0.6.6 0.6.5 0.6.4:0.6.3) +check("bootstrap equal to the header, other integrity" refuse "both name" 0.6.6 0.6.5 0.6.5:0.6.5:b) diff --git a/test/cmake/CheckReleasePaths.cmake b/test/cmake/CheckReleasePaths.cmake new file mode 100644 index 00000000..0abc2319 --- /dev/null +++ b/test/cmake/CheckReleasePaths.cmake @@ -0,0 +1,40 @@ +# check-release-paths.sh accepts a diff inside the closed list of paths and refuses any other path, tracked or not +# (acceptance criterion 4 of ADR-021). SCRIPT is the script, WORK a scratch directory, BASH the shell. +cmake_minimum_required(VERSION 3.31) +if(NOT SCRIPT OR NOT WORK OR NOT BASH) + message(FATAL_ERROR "SCRIPT, WORK and BASH are required") +endif() +find_package(Git REQUIRED QUIET) +string(RANDOM LENGTH 12 ALPHABET 0123456789abcdef suffix) +set(repo "${WORK}/repo-${suffix}") +file(MAKE_DIRECTORY "${repo}/allowed" "${repo}/other") +file(WRITE "${repo}/allowed/a.txt" "1\n") +file(WRITE "${repo}/other/b.txt" "1\n") +function(git) + execute_process(COMMAND "${GIT_EXECUTABLE}" -c user.name=Test -c user.email=test@example.invalid -c commit.gpgsign=false ${ARGN} + WORKING_DIRECTORY "${repo}" COMMAND_ERROR_IS_FATAL ANY OUTPUT_QUIET ERROR_QUIET) +endfunction() +git(init) +git(add .) +git(commit -m fixture) + +function(check description expected) + execute_process(COMMAND "${BASH}" "${SCRIPT}" allowed/a.txt allowed/new.txt + WORKING_DIRECTORY "${repo}" RESULT_VARIABLE result OUTPUT_VARIABLE output ERROR_VARIABLE error) + if(expected STREQUAL "accept" AND NOT result EQUAL 0) + message(FATAL_ERROR "${description}: refused: ${output}${error}") + elseif(expected STREQUAL "refuse" AND (result EQUAL 0 OR NOT "${output}${error}" MATCHES "closed list")) + message(FATAL_ERROR "${description}: accepted or no diagnostic: ${output}${error}") + endif() +endfunction() + +check("no change" accept) +file(WRITE "${repo}/allowed/a.txt" "2\n") +file(WRITE "${repo}/allowed/new.txt" "new\n") +check("changes inside the list" accept) +file(WRITE "${repo}/other/b.txt" "2\n") +check("a tracked path outside the list" refuse) +git(checkout -- other/b.txt) +file(WRITE "${repo}/other/untracked.txt" "x\n") +check("an untracked path outside the list" refuse) +file(REMOVE_RECURSE "${repo}") diff --git a/test/cmake/CheckReleaseVersion.cmake b/test/cmake/CheckReleaseVersion.cmake index f2d0d358..16b49698 100644 --- a/test/cmake/CheckReleaseVersion.cmake +++ b/test/cmake/CheckReleaseVersion.cmake @@ -49,3 +49,24 @@ foreach(tag IN LISTS release_tags) endif() endforeach() message(STATUS "WebFront.hpp/CMake version: ${header_version}; release tags checked: ${release_tags}") + +# ADR-021: a released library version has a row in the compatibility table of docs/DEVELOPER_ENVIRONMENT.md, and that row +# names the environment that the header of the release commit pins. +if(release_tags) + file(READ "${ROOT}/include/webfront/system/DeveloperReleaseData.hpp" pin_header) + if(NOT pin_header MATCHES "version\{\"([^\"]*)\"\}") + message(FATAL_ERROR "DeveloperReleaseData.hpp has no version") + endif() + set(pinned_environment "${CMAKE_MATCH_1}") + file(READ "${ROOT}/docs/DEVELOPER_ENVIRONMENT.md" environment_document) + string(REPLACE "." "[.]" version_pattern "${header_version}") + if(NOT environment_document MATCHES "\n[|] ${version_pattern} [|] ([^ |]+) [|] [0-9]+ [|]\n") + message(FATAL_ERROR "The compatibility table of docs/DEVELOPER_ENVIRONMENT.md has no row for the library ${header_version}; " + "freeze it with cmake/DeveloperCompatibility.cmake (MODE=freeze)") + endif() + if(NOT "${CMAKE_MATCH_1}" STREQUAL "${pinned_environment}") + message(FATAL_ERROR "The compatibility row of ${header_version} names the environment ${CMAKE_MATCH_1}, " + "but DeveloperReleaseData.hpp pins ${pinned_environment}") + endif() + message(STATUS "Compatibility table: ${header_version} -> environment ${pinned_environment}") +endif() diff --git a/test/cmake/CheckReleaseVersionTests.cmake b/test/cmake/CheckReleaseVersionTests.cmake index a5f28ad6..f08d6e82 100644 --- a/test/cmake/CheckReleaseVersionTests.cmake +++ b/test/cmake/CheckReleaseVersionTests.cmake @@ -6,6 +6,14 @@ endif() file(MAKE_DIRECTORY "${WORK}/archive/include/webfront") file(WRITE "${WORK}/archive/include/webfront/WebFront.hpp" "inline constexpr std::string_view version = \"0.1.0\";\n") +file(MAKE_DIRECTORY "${WORK}/archive/include/webfront/system" "${WORK}/archive/docs") +file(WRITE "${WORK}/archive/include/webfront/system/DeveloperReleaseData.hpp" + "inline constexpr std::string_view version{\"0.6.0\"};\n") +function(write_table rows) + file(WRITE "${WORK}/archive/docs/DEVELOPER_ENVIRONMENT.md" + "\n| Library | Environment | Minimum api |\n| --- | --- | --- |\n| unreleased | 0.6.0 | 1 |\n${rows}\n") +endfunction() +write_table("| 0.1.0 | 0.6.0 | 1 |\n") function(check_case description expected_result expected_message) execute_process(COMMAND "${CMAKE_COMMAND}" "-DROOT=${WORK}/archive" ${ARGN} @@ -34,6 +42,13 @@ check_case("Malformed release tag" failure "must have the form" -DEXPECTED_VERSION=0.1.0 -DRELEASE_TAG=release-0.1.0) check_case("Empty release tag" failure "must have the form" -DEXPECTED_VERSION=0.1.0 -DRELEASE_TAG=) +write_table("") +check_case("Release without a compatibility row" failure "has no row" + -DEXPECTED_VERSION=0.1.0 -DRELEASE_TAG=v0.1.0) +write_table("| 0.1.0 | 0.5.0 | 1 |\n") +check_case("Compatibility row that differs from the header" failure "names the environment" + -DEXPECTED_VERSION=0.1.0 -DRELEASE_TAG=v0.1.0) +write_table("| 0.1.0 | 0.6.0 | 1 |\n") find_package(Git REQUIRED QUIET) # Use a fresh repository on every run; keep the archive fixture independent of it. diff --git a/test/cmake/CheckReleaseWorkflow.cmake b/test/cmake/CheckReleaseWorkflow.cmake new file mode 100644 index 00000000..6556aec9 --- /dev/null +++ b/test/cmake/CheckReleaseWorkflow.cmake @@ -0,0 +1,104 @@ +# Checks the permissions of .github/workflows/ReleaseDeveloper.yml against the table of ADR-021, decision 1 (acceptance +# criterion 4): no permission for the workflow as a whole, and exactly the permissions of the table for each job. The GitHub +# application's token is created only by the two jobs that the table gives it to, and the workflow carries no assistant +# attribution. WORKFLOW is the file to check (a mutated copy in the regression, FILE_UNDER_TEST of CheckReleaseWorkflowTests). +cmake_minimum_required(VERSION 3.31) +if(NOT WORKFLOW) + message(FATAL_ERROR "WORKFLOW is required") +endif() + +# job -> the permissions of its GITHUB_TOKEN, as "key: value" entries separated by "|". +set(expected_wf-package "contents: read") +set(expected_prepare "contents: read") +set(expected_tag "contents: write") +set(expected_publish "contents: write|pages: write") +set(expected_verify "contents: read") +set(expected_pull-request "contents: read") +set(jobs wf-package prepare tag publish verify pull-request) +# The jobs that create the application's token (the preparation and the pull request). +set(app_jobs prepare pull-request) + +file(READ "${WORKFLOW}" content) +if(content MATCHES "[Cc]o-[Aa]uthored|[Gg]enerated with|Claude|Codex|Copilot") + message(FATAL_ERROR "The workflow carries an assistant attribution") +endif() +string(REPLACE ";" "" content "${content}") +string(REPLACE "\n" ";" lines "${content}") + +set(job "") +set(in_permissions FALSE) +set(top_permissions "") +set(found_jobs "") +set(in_jobs FALSE) +foreach(line IN LISTS lines) + if(line MATCHES "^permissions: *(.*)$") + set(top_permissions "${CMAKE_MATCH_1}") + endif() + if(line MATCHES "^jobs:") + set(in_jobs TRUE) + endif() + if(NOT in_jobs) + continue() + endif() + if(line MATCHES "^ ([a-z][a-z-]*):[ ]*$") + set(job "${CMAKE_MATCH_1}") + list(APPEND found_jobs "${job}") + set(actual_${job} "") + set(has_permissions_${job} FALSE) + set(in_permissions FALSE) + continue() + endif() + if(job STREQUAL "") + continue() + endif() + if(line MATCHES "^ permissions:[ ]*(.*)$") + set(has_permissions_${job} TRUE) + set(in_permissions TRUE) + if(NOT "${CMAKE_MATCH_1}" STREQUAL "") + message(FATAL_ERROR "Job ${job}: permissions must be a list of entries, not '${CMAKE_MATCH_1}'") + endif() + continue() + endif() + if(in_permissions) + if(line MATCHES "^ ([a-z-]+: [a-z]+)[ ]*$") + if(actual_${job}) + set(actual_${job} "${actual_${job}}|${CMAKE_MATCH_1}") + else() + set(actual_${job} "${CMAKE_MATCH_1}") + endif() + continue() + endif() + set(in_permissions FALSE) + endif() + if(line MATCHES "create-github-app-token") + list(APPEND app_token_jobs "${job}") + endif() + if(line MATCHES "secrets\\.([A-Z_]+)" AND NOT job IN_LIST app_jobs) + message(FATAL_ERROR "Job ${job} reads a secret (${CMAKE_MATCH_1}); only the jobs of the application's token may") + endif() +endforeach() + +if(NOT top_permissions STREQUAL "{}") + message(FATAL_ERROR "The workflow must declare 'permissions: {}' at its top level, not '${top_permissions}'") +endif() +list(SORT found_jobs) +set(expected_jobs ${jobs}) +list(SORT expected_jobs) +if(NOT found_jobs STREQUAL expected_jobs) + message(FATAL_ERROR "The jobs of the workflow are '${found_jobs}', the table of ADR-021 has '${expected_jobs}'") +endif() +foreach(job IN LISTS jobs) + if(NOT has_permissions_${job}) + message(FATAL_ERROR "Job ${job} declares no permissions of its own") + endif() + if(NOT "${actual_${job}}" STREQUAL "${expected_${job}}") + message(FATAL_ERROR "Job ${job} has the permissions '${actual_${job}}', the table of ADR-021 gives '${expected_${job}}'") + endif() +endforeach() +list(SORT app_token_jobs) +set(expected_app_jobs ${app_jobs}) +list(SORT expected_app_jobs) +if(NOT app_token_jobs STREQUAL expected_app_jobs) + message(FATAL_ERROR "The application's token is created by '${app_token_jobs}', not by '${expected_app_jobs}'") +endif() +message(STATUS "release-developer: permissions of ${found_jobs} match the table of ADR-021") diff --git a/test/cmake/CheckReleaseWorkflowTests.cmake b/test/cmake/CheckReleaseWorkflowTests.cmake new file mode 100644 index 00000000..54c05194 --- /dev/null +++ b/test/cmake/CheckReleaseWorkflowTests.cmake @@ -0,0 +1,47 @@ +# Regression for CheckReleaseWorkflow.cmake: the workflow is accepted, and each deviation from the table of ADR-021 fails. +cmake_minimum_required(VERSION 3.31) +if(NOT ROOT OR NOT WORK) + message(FATAL_ERROR "ROOT and WORK are required") +endif() +set(workflow "${ROOT}/.github/workflows/ReleaseDeveloper.yml") +file(READ "${workflow}" original) +file(MAKE_DIRECTORY "${WORK}") + +function(check description expected message) + # Each mutation is a "from" then a "to" text (the first occurrence of "from" is replaced). + set(content "${original}") + set(arguments ${ARGN}) + while(arguments) + list(POP_FRONT arguments from to) + string(FIND "${content}" "${from}" at) + if(at EQUAL -1) + message(FATAL_ERROR "${description}: the mutation target '${from}' is not in the workflow") + endif() + string(REPLACE "${from}" "${to}" content "${content}") + endwhile() + file(WRITE "${WORK}/ReleaseDeveloper.yml" "${content}") + execute_process(COMMAND "${CMAKE_COMMAND}" "-DWORKFLOW=${WORK}/ReleaseDeveloper.yml" + -P "${ROOT}/test/cmake/CheckReleaseWorkflow.cmake" + RESULT_VARIABLE result OUTPUT_VARIABLE output ERROR_VARIABLE error) + if(expected STREQUAL "accept" AND NOT result EQUAL 0) + message(FATAL_ERROR "${description}: refused: ${output}${error}") + elseif(expected STREQUAL "refuse" AND result EQUAL 0) + message(FATAL_ERROR "${description}: accepted") + endif() + if(NOT "${output}${error}" MATCHES "${message}") + message(FATAL_ERROR "${description}: missing diagnostic '${message}': ${output}${error}") + endif() +endfunction() + +check("the workflow as written" accept "match the table") +check("a workflow-wide permission" refuse "top level" "permissions: {}\n" "permissions:\n contents: write\n") +check("a verification that may write" refuse "Job verify" + " needs: [prepare, publish]\n runs-on: ubuntu-26.04\n timeout-minutes: 30\n permissions:\n contents: read\n" + " needs: [prepare, publish]\n runs-on: ubuntu-26.04\n timeout-minutes: 30\n permissions:\n contents: write\n") +check("a pull-request job that may write pull requests" refuse "Job pull-request" + " needs: [prepare, verify]\n runs-on: ubuntu-26.04\n timeout-minutes: 5\n environment: developer-release-app\n permissions:\n contents: read\n" + " needs: [prepare, verify]\n runs-on: ubuntu-26.04\n timeout-minutes: 5\n environment: developer-release-app\n permissions:\n contents: read\n pull-requests: write\n") +check("a publication without pages permission" refuse "Job publish" " pages: write\n" "") +check("a job without permissions of its own" refuse "Job tag declares no permissions" + " timeout-minutes: 5\n permissions:\n contents: write\n steps:\n - name: Tag" " timeout-minutes: 5\n steps:\n - name: Tag") +check("an assistant attribution" refuse "attribution" "Pins the published" "Generated with a tool. Pins the published") diff --git a/test/developer/specs/distribution-specs.mjs b/test/developer/specs/distribution-specs.mjs index f7138a0b..34c8b03c 100644 --- a/test/developer/specs/distribution-specs.mjs +++ b/test/developer/specs/distribution-specs.mjs @@ -1,6 +1,7 @@ // Specs of the developer distribution: the starters, the Pages staging and the pinned bootstrap header. import {tar} from '../../../js/developer/tools/archive.mjs'; import {bootstrapHeader, versionPath, distributionFiles, customDomain} from '../../../js/developer/tools/distribution.mjs'; +import {pinOrigin} from '../../../js/developer/scripts/pin.mjs'; import stageSite from '../../../js/developer/scripts/site.mjs'; import {compress} from '../../../js/developer/environment/embed.mjs'; import {createStarter} from '../../../js/developer/environment/starter.mjs'; @@ -179,4 +180,37 @@ describe('The developer distribution', () => { } throws(() => distributionFiles({starters: {life: {archive: '../life-starter.tgz'}}})); }); + + describe('the origin of a pinned URL (ADR-021)', () => { + const base = 'https://dist.webfront.fr/'; + const previous = 'https://ambroise-leclerc.github.io/WebFront/'; + const onBase = 'https://dist.webfront.fr/developer/0.6.5/environment.tgz'; + const onPrevious = 'https://ambroise-leclerc.github.io/WebFront/developer/0.6.4/environment.tgz'; + + it('accepts a pin on the origin of baseUrl without a waiver', () => { + expect(pinOrigin(onBase, base)).toEqual({waiver: false}); + }); + + it('refuses a pin off the origin of baseUrl when no migration is declared', () => { + throws(() => pinOrigin(onPrevious, base), /declares no previousBase/); + }); + + it('tolerates a pin under the declared previousBase with a warning that names the waiver', () => { + const result = pinOrigin(onPrevious, base, previous); + expect(result.waiver).toBe(true); + expect(result.warning).toMatch(/migration waiver/); + }); + + it('refuses a pin outside both the base and the declared previousBase', () => { + throws(() => pinOrigin('https://elsewhere.example/developer/0.6.4/environment.tgz', base, previous), /neither/); + }); + + it('refuses a stale waiver once the header pins a version published under the new base', () => { + throws(() => pinOrigin(onBase, base, previous), /Stale migration waiver/); + }); + + it('refuses a previousBase on the origin of baseUrl', () => { + throws(() => pinOrigin(onBase, base, base), /another origin/); + }); + }); }); diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index 057a6b0f..802be5f7 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -167,6 +167,19 @@ add_test(NAME ReleaseVersionRegression COMMAND ${CMAKE_COMMAND} -DROOT=${PROJECT_SOURCE_DIR} -DWORK=${CMAKE_CURRENT_BINARY_DIR}/release-version-regression -P ${PROJECT_SOURCE_DIR}/test/cmake/CheckReleaseVersionTests.cmake) +add_test(NAME DeveloperPinConsistency + COMMAND ${CMAKE_COMMAND} -DROOT=${PROJECT_SOURCE_DIR} -P ${PROJECT_SOURCE_DIR}/test/cmake/CheckDeveloperPin.cmake) +add_test(NAME DeveloperPinRegression + COMMAND ${CMAKE_COMMAND} -DROOT=${PROJECT_SOURCE_DIR} -DWORK=${CMAKE_CURRENT_BINARY_DIR}/developer-pin-regression + -P ${PROJECT_SOURCE_DIR}/test/cmake/CheckDeveloperPinTests.cmake) +add_test(NAME ReleaseDeveloperWorkflow + COMMAND ${CMAKE_COMMAND} -DWORKFLOW=${PROJECT_SOURCE_DIR}/.github/workflows/ReleaseDeveloper.yml + -P ${PROJECT_SOURCE_DIR}/test/cmake/CheckReleaseWorkflow.cmake) +add_test(NAME ReleaseDeveloperWorkflowRegression + COMMAND ${CMAKE_COMMAND} -DROOT=${PROJECT_SOURCE_DIR} -DWORK=${CMAKE_CURRENT_BINARY_DIR}/release-workflow-regression + -P ${PROJECT_SOURCE_DIR}/test/cmake/CheckReleaseWorkflowTests.cmake) +set_tests_properties(DeveloperPinConsistency DeveloperPinRegression ReleaseDeveloperWorkflow ReleaseDeveloperWorkflowRegression + PROPERTIES TIMEOUT 60 LABELS fast) add_test(NAME BootstrapProvisioning COMMAND ${CMAKE_COMMAND} -DROOT=${PROJECT_SOURCE_DIR} -DWORK=${CMAKE_CURRENT_BINARY_DIR}/bootstrap-provisioning -P ${PROJECT_SOURCE_DIR}/test/cmake/CheckBootstrapProvisioning.cmake) @@ -176,6 +189,11 @@ if(UNIX) add_test(NAME RunWithDeadline COMMAND ${CMAKE_COMMAND} -DSCRIPT=${PROJECT_SOURCE_DIR}/cmake/RunWithDeadline.sh -P ${PROJECT_SOURCE_DIR}/test/cmake/CheckRunWithDeadline.cmake) set_tests_properties(RunWithDeadline PROPERTIES TIMEOUT 60 LABELS fast) + # The closed list of paths of the developer release commit (ADR-021). + add_test(NAME ReleasePathsClosedList + COMMAND ${CMAKE_COMMAND} -DSCRIPT=${PROJECT_SOURCE_DIR}/js/developer/tools/check-release-paths.sh + -DWORK=${CMAKE_CURRENT_BINARY_DIR}/release-paths -DBASH=bash -P ${PROJECT_SOURCE_DIR}/test/cmake/CheckReleasePaths.cmake) + set_tests_properties(ReleasePathsClosedList PROPERTIES TIMEOUT 60 LABELS fast) find_program(WEBFRONT_TEST_BASH_EXECUTABLE bash) find_package(Git QUIET) if(WEBFRONT_TEST_BASH_EXECUTABLE AND Git_FOUND) From 2efa89a183a8fcf1fb6345807558793eef59b26c Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Mon, 9 Nov 2026 17:03:54 +0100 Subject: [PATCH 02/13] Fix pinOrigin, pin the release commit to the built source, rehearse on the candidate (#482) - pin.mjs: define and export pinOrigin, which the previous commit used without defining it (wf run pin failed and the specs could not import it). - release-developer: wf-package records the commit it built and prepare checks out that commit instead of rereading develop, so the tag designates the sources of the published archives. - release-developer: the rehearsal runs the browser suite (label web-integration) on the environment and starters built from the candidate sources and served locally, before anything is tagged. - ReleaseDeveloperWorkflow refuses a preparation that rereads develop and a rehearsal without the browser suite. --- .github/workflows/ReleaseDeveloper.yml | 18 ++++++++++++++++-- js/developer/scripts/pin.mjs | 20 ++++++++++++++++++++ test/cmake/CheckReleaseWorkflow.cmake | 14 ++++++++++++++ test/cmake/CheckReleaseWorkflowTests.cmake | 4 ++++ 4 files changed, 54 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ReleaseDeveloper.yml b/.github/workflows/ReleaseDeveloper.yml index c2b7a906..7ff7611a 100644 --- a/.github/workflows/ReleaseDeveloper.yml +++ b/.github/workflows/ReleaseDeveloper.yml @@ -40,14 +40,20 @@ jobs: # Construction and rehearsal: contents: read, no destination but the artifact. wf-package: runs-on: ubuntu-26.04 - timeout-minutes: 30 + timeout-minutes: 90 permissions: contents: read + outputs: + # The commit that was built: the release commit is made on this one, not on whatever develop became in the meantime. + source: ${{ steps.source.outputs.commit }} steps: - uses: actions/checkout@v7 with: ref: develop persist-credentials: false + - name: Record the source commit + id: source + run: echo "commit=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" - name: Check the requested version run: | [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "::error::Version must be MAJOR.MINOR.PATCH"; exit 1; } @@ -84,6 +90,13 @@ jobs: run: cmake -DROOT="$PWD" -P test/cmake/CheckDeveloperPin.cmake - name: Run the specs of the environment run: wf test --timeout 300 + # The rehearsal: the browser suite on the candidate bytes. The fixtures of CTest serve, from a local origin, the + # environment and the starters built from these sources (the candidate, whose bootstrap was just refreshed), and the + # developer journey starts and runs them. A defect found here costs no version. + - name: Run the browser suite on the candidate bytes served locally + run: | + cmake --build build-driver --target webtest developer_integration webfront-wf --parallel 2 + xvfb-run -a ctest --test-dir build-driver -L web-integration --output-on-failure --no-tests=error --parallel 2 - name: Collect the release files run: | mkdir release-files @@ -123,7 +136,8 @@ jobs: private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }} - uses: actions/checkout@v7 with: - ref: develop + # The commit wf-package built, never the current develop: the files applied below come from that build. + ref: ${{ needs.wf-package.outputs.source }} token: ${{ steps.app.outputs.token }} - uses: actions/download-artifact@v4 with: diff --git a/js/developer/scripts/pin.mjs b/js/developer/scripts/pin.mjs index 0ff2b5c0..a9f197d9 100644 --- a/js/developer/scripts/pin.mjs +++ b/js/developer/scripts/pin.mjs @@ -6,6 +6,26 @@ // The header must be exactly the one generated for its version, and the archive at its URL must have its integrity. import {baseUrl, bootstrapHeader, sriOf} from '../tools/distribution.mjs'; +/** + * Where a pinned URL stands relative to the distribution's base URL (ADR-021, decision 2). Returns `{waiver, warning}`: + * `waiver` is true when the pin is tolerated only by the declared migration waiver (`previousBase` of distribution.json). + * Throws when the pinned URL is off the origin of the base without a valid waiver, or when a waiver is stale (the pin + * is on the current base, so `previousBase` must be removed). + */ +export function pinOrigin(pinnedUrl, base, previousBase) { + const current = new URL(baseUrl(base)); + const pinned = new URL(pinnedUrl); + const previous = previousBase === undefined ? undefined : new URL(baseUrl(previousBase)); + if (previous && previous.origin === current.origin) throw new Error('previousBase must be on another origin than baseUrl'); + if (pinned.origin === current.origin) { + if (previous) throw new Error(`Stale migration waiver: the header pins a version published under ${current.origin}; remove previousBase from distribution.json`); + return {waiver: false}; + } + if (!previous) throw new Error(`The pinned ${pinned.href} is not on ${current.origin}, the origin of baseUrl, and distribution.json declares no previousBase`); + if (!pinned.href.startsWith(previous.href)) throw new Error(`The pinned ${pinned.href} is on neither ${current.origin} nor the declared previousBase ${previous.href}`); + return {waiver: true, warning: `migration waiver: the pinned ${pinned.href} is under the previous base ${previous.href}; it is not checked for redirection or CORS, and a browser cannot start from it if it redirects`}; +} + export default async function (context) { const {project} = context; const header = await project.readText('include/webfront/system/DeveloperReleaseData.hpp'); diff --git a/test/cmake/CheckReleaseWorkflow.cmake b/test/cmake/CheckReleaseWorkflow.cmake index 6556aec9..f510be79 100644 --- a/test/cmake/CheckReleaseWorkflow.cmake +++ b/test/cmake/CheckReleaseWorkflow.cmake @@ -102,3 +102,17 @@ if(NOT app_token_jobs STREQUAL expected_app_jobs) message(FATAL_ERROR "The application's token is created by '${app_token_jobs}', not by '${expected_app_jobs}'") endif() message(STATUS "release-developer: permissions of ${found_jobs} match the table of ADR-021") + +# The release commit is made on the commit that was built, and only the build job reads develop by name. +string(REGEX MATCHALL "ref: develop" develop_refs "${content}") +list(LENGTH develop_refs develop_count) +if(NOT develop_count EQUAL 1) + message(FATAL_ERROR "Only wf-package may check out develop by name (${develop_count} found): the preparation must use its source commit") +endif() +if(NOT content MATCHES "needs[.]wf-package[.]outputs[.]source") + message(FATAL_ERROR "The preparation does not check out the commit built by wf-package") +endif() +# The rehearsal runs the browser suite on the candidate bytes before anything is tagged. +if(NOT content MATCHES "ctest --test-dir build-driver -L web-integration") + message(FATAL_ERROR "The rehearsal does not run the browser suite on the candidate bytes") +endif() diff --git a/test/cmake/CheckReleaseWorkflowTests.cmake b/test/cmake/CheckReleaseWorkflowTests.cmake index 54c05194..7bc2ac4b 100644 --- a/test/cmake/CheckReleaseWorkflowTests.cmake +++ b/test/cmake/CheckReleaseWorkflowTests.cmake @@ -45,3 +45,7 @@ check("a publication without pages permission" refuse "Job publish" " pages check("a job without permissions of its own" refuse "Job tag declares no permissions" " timeout-minutes: 5\n permissions:\n contents: write\n steps:\n - name: Tag" " timeout-minutes: 5\n steps:\n - name: Tag") check("an assistant attribution" refuse "attribution" "Pins the published" "Generated with a tool. Pins the published") +check("a preparation that rereads develop" refuse "Only wf-package" + "needs.wf-package.outputs.source }}" "needs.wf-package.outputs.source }}\n x: y\n - uses: actions/checkout@v7\n with:\n ref: develop") +check("a rehearsal without the browser suite" refuse "rehearsal does not" + "ctest --test-dir build-driver -L web-integration" "ctest --test-dir build-driver -R Nothing") From 4f2b4b8136a8ff02ea3500d52ef674f9dea1178c Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Mon, 9 Nov 2026 17:35:03 +0100 Subject: [PATCH 03/13] Build the driver for the public smoke test and name the workflow file in the docs (#482) The public smoke test depends on the DeveloperFixtures fixture, whose cases run build-public/test/web/webfront-wf: build that target there too. The documented dispatch commands name ReleaseDeveloper.yml, the actual workflow file. --- .github/workflows/ReleaseDeveloper.yml | 2 +- js/developer/tools/PUBLISHING.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ReleaseDeveloper.yml b/.github/workflows/ReleaseDeveloper.yml index 7ff7611a..7e57d1d5 100644 --- a/.github/workflows/ReleaseDeveloper.yml +++ b/.github/workflows/ReleaseDeveloper.yml @@ -266,7 +266,7 @@ jobs: run: | cmake -S . -B build-public -G Ninja -DCMAKE_BUILD_TYPE=Release -DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_ENABLE_TESTING=ON \ -DWEBFRONT_EMBED_WEBKITGTK=ON -DWEBFRONT_WEBTEST_FRONTEND=WebKitGTK -DCMAKE_CXX_SCAN_FOR_MODULES=OFF - cmake --build build-public --target developer_integration --parallel 2 + cmake --build build-public --target developer_integration webfront-wf --parallel 2 ctest --test-dir build-public -R '^DeveloperFixtures$' --output-on-failure --no-tests=error xvfb-run -a ./build-public/test/web/developer_integration \ "$PWD/build-public/test/web/developer-fixtures" "$PWD/build-public/test/web/public-generated" --public diff --git a/js/developer/tools/PUBLISHING.md b/js/developer/tools/PUBLISHING.md index fc4cc399..a10c7bab 100644 --- a/js/developer/tools/PUBLISHING.md +++ b/js/developer/tools/PUBLISHING.md @@ -16,8 +16,8 @@ The **release-developer** workflow (`.github/workflows/ReleaseDeveloper.yml`, AD it on `develop` with the version (greater than the one of `distribution.json`): ```sh -gh workflow run release-developer.yml --ref develop -f version=0.6.7 -f publish=false # rehearsal -gh workflow run release-developer.yml --ref develop -f version=0.6.7 -f publish=true # release +gh workflow run ReleaseDeveloper.yml --ref develop -f version=0.6.7 -f publish=false # rehearsal +gh workflow run ReleaseDeveloper.yml --ref develop -f version=0.6.7 -f publish=true # release ``` The jobs run in this order, and each declares only the permissions of the table of ADR-021 (`ReleaseDeveloperWorkflow` checks them): From c1e2ea4d3432ed57476795d6db86b690af4f07b2 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Mon, 9 Nov 2026 17:41:03 +0100 Subject: [PATCH 04/13] Review the downstream jobs of release-developer (#482) The publish job named an environment that does not exist (developer-pages-publication is the concurrency group): drop it, as the previous workflow did. The verification retries for up to fifteen minutes, since a Pages build takes minutes and a 404 served before it ends may be cached. --- .github/workflows/ReleaseDeveloper.yml | 5 +++-- js/developer/tools/PUBLISHING.md | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ReleaseDeveloper.yml b/.github/workflows/ReleaseDeveloper.yml index 7e57d1d5..fcf0df58 100644 --- a/.github/workflows/ReleaseDeveloper.yml +++ b/.github/workflows/ReleaseDeveloper.yml @@ -183,7 +183,7 @@ jobs: needs: [prepare, tag] runs-on: ubuntu-26.04 timeout-minutes: 15 - environment: developer-pages-publication + # No environment: developer-pages-publication is the concurrency group below, the only writer of gh-pages. permissions: contents: write pages: write @@ -256,7 +256,8 @@ jobs: run: wf restore - name: Check the deployed bytes and the pinned URL run: | - for attempt in 1 2 3 4 5 6; do + # A Pages build takes minutes, and a 404 served before it ends may be cached for up to ten minutes. + for attempt in $(seq 1 30); do if wf run pin; then exit 0; fi echo "::notice::Attempt $attempt failed; Pages may still be building" sleep 30 diff --git a/js/developer/tools/PUBLISHING.md b/js/developer/tools/PUBLISHING.md index a10c7bab..5a19be17 100644 --- a/js/developer/tools/PUBLISHING.md +++ b/js/developer/tools/PUBLISHING.md @@ -54,7 +54,7 @@ under that address; it prints a warning, and is refused as soon as the header pi `developer-release-app`; - a tag rule on `developer-v*` forbidding updates and deletions; - the branch protection of `develop` and `master` must not cover `release/*`, and the application has no bypass; -- the Pages source and the environment `developer-pages-publication` unchanged ("One-time Pages configuration" below). +- the Pages source (`gh-pages`, root, branch build) unchanged ("One-time Pages configuration" below); the group `developer-pages-publication` is the only writer of `gh-pages`. The library's release preparation freezes the compatibility table with `cmake -DROOT=. -DMODE=freeze -DLIBRARY_VERSION= -P cmake/DeveloperCompatibility.cmake`; `CheckReleaseVersion.cmake` fails a `v*` tag without its row. From a206449c2590fa12a849be0670f63bfb327bfa22 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Mon, 9 Nov 2026 17:54:22 +0100 Subject: [PATCH 05/13] Reconfigure before the rehearsal and escape the dots of the version (#482) - The driver build is configured before the version is set, and CTest reads distribution.json at configure time: reconfigure build-driver before the browser suite, and have ReleaseDeveloperWorkflow require it. - DeveloperCompatibility.cmake validated LIBRARY_VERSION with an unescaped dot (1x2y3 was accepted and written to the table): use [.] and test the script (DeveloperCompatibilityTable). --- .github/workflows/ReleaseDeveloper.yml | 2 + cmake/DeveloperCompatibility.cmake | 2 +- test/cmake/CheckDeveloperCompatibility.cmake | 49 ++++++++++++++++++++ test/cmake/CheckReleaseWorkflow.cmake | 4 ++ test/cmake/CheckReleaseWorkflowTests.cmake | 2 + test/unit/CMakeLists.txt | 4 ++ 6 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 test/cmake/CheckDeveloperCompatibility.cmake diff --git a/.github/workflows/ReleaseDeveloper.yml b/.github/workflows/ReleaseDeveloper.yml index fcf0df58..657d401f 100644 --- a/.github/workflows/ReleaseDeveloper.yml +++ b/.github/workflows/ReleaseDeveloper.yml @@ -95,6 +95,8 @@ jobs: # developer journey starts and runs them. A defect found here costs no version. - name: Run the browser suite on the candidate bytes served locally run: | + # The driver was configured before the version was set: CTest read the former version of distribution.json then. + cmake -S . -B build-driver cmake --build build-driver --target webtest developer_integration webfront-wf --parallel 2 xvfb-run -a ctest --test-dir build-driver -L web-integration --output-on-failure --no-tests=error --parallel 2 - name: Collect the release files diff --git a/cmake/DeveloperCompatibility.cmake b/cmake/DeveloperCompatibility.cmake index 518f4f7f..0d5c644d 100644 --- a/cmake/DeveloperCompatibility.cmake +++ b/cmake/DeveloperCompatibility.cmake @@ -48,7 +48,7 @@ set(new_unreleased "| unreleased | ${environment} | ${api} |\n") if(MODE STREQUAL "unreleased") string(REPLACE "${unreleased_row}" "${new_unreleased}" table "${table}") elseif(MODE STREQUAL "freeze") - if(NOT LIBRARY_VERSION MATCHES "^[0-9]+\.[0-9]+\.[0-9]+$") + if(NOT LIBRARY_VERSION MATCHES "^[0-9]+[.][0-9]+[.][0-9]+$") message(FATAL_ERROR "LIBRARY_VERSION must be MAJOR.MINOR.PATCH") endif() if(table MATCHES "[|] ${LIBRARY_VERSION} [|]") diff --git a/test/cmake/CheckDeveloperCompatibility.cmake b/test/cmake/CheckDeveloperCompatibility.cmake new file mode 100644 index 00000000..aa9eb725 --- /dev/null +++ b/test/cmake/CheckDeveloperCompatibility.cmake @@ -0,0 +1,49 @@ +# cmake/DeveloperCompatibility.cmake rewrites the unreleased row, freezes it into a library version's row, and refuses +# a malformed or repeated version (ADR-021, decision 4). It runs on a copy of the three files it reads, never on ROOT. +cmake_minimum_required(VERSION 3.31) +if(NOT ROOT OR NOT WORK) + message(FATAL_ERROR "ROOT and WORK are required") +endif() +set(copy "${WORK}/copy") +file(REMOVE_RECURSE "${WORK}") +file(MAKE_DIRECTORY "${copy}/docs" "${copy}/include/webfront/system") +file(WRITE "${copy}/include/webfront/system/DeveloperReleaseData.hpp" "inline constexpr std::string_view version{\"0.6.9\"};\n") +file(WRITE "${copy}/include/webfront/DeveloperApp.hpp" "inline constexpr int apiVersion = 2;\n") +set(table_begin "\n| Library | Environment | Minimum api |\n| --- | --- | --- |\n") +set(table_end "\n") +file(WRITE "${copy}/docs/DEVELOPER_ENVIRONMENT.md" "text\n${table_begin}| unreleased | 0.6.1 | 1 |\n| 0.5.0 | 0.6.0 | 1 |\n${table_end}more\n") + +function(run result_variable) + execute_process(COMMAND "${CMAKE_COMMAND}" -DROOT=${copy} ${ARGN} -P "${ROOT}/cmake/DeveloperCompatibility.cmake" + RESULT_VARIABLE result OUTPUT_VARIABLE output ERROR_VARIABLE error) + set(${result_variable} ${result} PARENT_SCOPE) + set(last_output "${output}${error}" PARENT_SCOPE) +endfunction() +function(document variable) + file(READ "${copy}/docs/DEVELOPER_ENVIRONMENT.md" content) + set(${variable} "${content}" PARENT_SCOPE) +endfunction() + +run(status -DMODE=unreleased) +document(content) +if(NOT status EQUAL 0 OR NOT content MATCHES "[|] unreleased [|] 0[.]6[.]9 [|] 2 [|]") + message(FATAL_ERROR "The unreleased row was not rewritten: ${last_output}") +endif() +foreach(bad IN ITEMS 1x2y3 1.2 v1.2.3 1.2.3.4) + document(before) + run(status -DMODE=freeze "-DLIBRARY_VERSION=${bad}") + document(after) + if(status EQUAL 0 OR NOT before STREQUAL after) + message(FATAL_ERROR "The malformed version '${bad}' was accepted or changed the table") + endif() +endforeach() +run(status -DMODE=freeze -DLIBRARY_VERSION=1.2.3) +document(content) +if(NOT status EQUAL 0 OR NOT content MATCHES "\n[|] unreleased [|] 0[.]6[.]9 [|] 2 [|]\n[|] 1[.]2[.]3 [|] 0[.]6[.]9 [|] 2 [|]\n[|] 0[.]5[.]0 ") + message(FATAL_ERROR "The row was not frozen under the unreleased one: ${last_output}\n${content}") +endif() +run(status -DMODE=freeze -DLIBRARY_VERSION=1.2.3) +if(status EQUAL 0) + message(FATAL_ERROR "A repeated freeze was accepted") +endif() +file(REMOVE_RECURSE "${WORK}") diff --git a/test/cmake/CheckReleaseWorkflow.cmake b/test/cmake/CheckReleaseWorkflow.cmake index f510be79..dff03d8e 100644 --- a/test/cmake/CheckReleaseWorkflow.cmake +++ b/test/cmake/CheckReleaseWorkflow.cmake @@ -116,3 +116,7 @@ endif() if(NOT content MATCHES "ctest --test-dir build-driver -L web-integration") message(FATAL_ERROR "The rehearsal does not run the browser suite on the candidate bytes") endif() +# CTest reads distribution.json when it configures: the build directory is configured again after the version is set. +if(NOT content MATCHES "cmake -S [.] -B build-driver\n") + message(FATAL_ERROR "The rehearsal does not configure build-driver again after setting the version") +endif() diff --git a/test/cmake/CheckReleaseWorkflowTests.cmake b/test/cmake/CheckReleaseWorkflowTests.cmake index 7bc2ac4b..84237d36 100644 --- a/test/cmake/CheckReleaseWorkflowTests.cmake +++ b/test/cmake/CheckReleaseWorkflowTests.cmake @@ -49,3 +49,5 @@ check("a preparation that rereads develop" refuse "Only wf-package" "needs.wf-package.outputs.source }}" "needs.wf-package.outputs.source }}\n x: y\n - uses: actions/checkout@v7\n with:\n ref: develop") check("a rehearsal without the browser suite" refuse "rehearsal does not" "ctest --test-dir build-driver -L web-integration" "ctest --test-dir build-driver -R Nothing") +check("a rehearsal on a stale configuration" refuse "configure build-driver again" + " cmake -S . -B build-driver\n" "") diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index 802be5f7..ec1ba939 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -178,7 +178,11 @@ add_test(NAME ReleaseDeveloperWorkflow add_test(NAME ReleaseDeveloperWorkflowRegression COMMAND ${CMAKE_COMMAND} -DROOT=${PROJECT_SOURCE_DIR} -DWORK=${CMAKE_CURRENT_BINARY_DIR}/release-workflow-regression -P ${PROJECT_SOURCE_DIR}/test/cmake/CheckReleaseWorkflowTests.cmake) +add_test(NAME DeveloperCompatibilityTable + COMMAND ${CMAKE_COMMAND} -DROOT=${PROJECT_SOURCE_DIR} -DWORK=${CMAKE_CURRENT_BINARY_DIR}/developer-compatibility + -P ${PROJECT_SOURCE_DIR}/test/cmake/CheckDeveloperCompatibility.cmake) set_tests_properties(DeveloperPinConsistency DeveloperPinRegression ReleaseDeveloperWorkflow ReleaseDeveloperWorkflowRegression + DeveloperCompatibilityTable PROPERTIES TIMEOUT 60 LABELS fast) add_test(NAME BootstrapProvisioning COMMAND ${CMAKE_COMMAND} -DROOT=${PROJECT_SOURCE_DIR} -DWORK=${CMAKE_CURRENT_BINARY_DIR}/bootstrap-provisioning From d7cd3dc47946a5a39cfe795097051de5e2ae1508 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Mon, 9 Nov 2026 18:14:17 +0100 Subject: [PATCH 06/13] Make the tag step rerunnable and use literal dots in the pin check (#482) - A tag that already points at the release commit is accepted, so a rerun after a lost response resumes; a tag elsewhere stops the run and is never moved. - CheckDeveloperPin.cmake matched the version and the file name of the pinned URL with unescaped dots (developer/0x6x6/environmentXtgz was accepted): use [.] and add the regressions. --- .github/workflows/ReleaseDeveloper.yml | 17 ++++++++++++++++- test/cmake/CheckDeveloperPin.cmake | 7 +++++-- test/cmake/CheckDeveloperPinTests.cmake | 12 ++++++++++-- test/cmake/CheckReleaseWorkflow.cmake | 5 +++++ test/cmake/CheckReleaseWorkflowTests.cmake | 2 ++ 5 files changed, 38 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ReleaseDeveloper.yml b/.github/workflows/ReleaseDeveloper.yml index 657d401f..e4de00e5 100644 --- a/.github/workflows/ReleaseDeveloper.yml +++ b/.github/workflows/ReleaseDeveloper.yml @@ -179,7 +179,22 @@ jobs: GH_TOKEN: ${{ github.token }} COMMIT: ${{ needs.prepare.outputs.commit }} run: | - gh api --method POST "repos/$GITHUB_REPOSITORY/git/refs" -f "ref=refs/tags/developer-v$VERSION" -f "sha=$COMMIT" > /dev/null + # Rerunnable after a lost response: a tag that already points at the release commit is the expected result. A tag + # elsewhere is never moved (the tag rule forbids it) and stops the run. + tag="developer-v$VERSION" + errors=$(mktemp) + if existing=$(gh api "repos/$GITHUB_REPOSITORY/git/ref/tags/$tag" --jq '.object.sha' 2> "$errors"); then + if [ "$existing" != "$COMMIT" ]; then + echo "::error::$tag already points at $existing, not at the release commit $COMMIT" + exit 1 + fi + echo "$tag already points at the release commit" + elif grep -q '(HTTP 404)' "$errors"; then + gh api --method POST "repos/$GITHUB_REPOSITORY/git/refs" -f "ref=refs/tags/$tag" -f "sha=$COMMIT" > /dev/null + else + cat "$errors" >&2 + exit 1 + fi publish: needs: [prepare, tag] diff --git a/test/cmake/CheckDeveloperPin.cmake b/test/cmake/CheckDeveloperPin.cmake index a045145d..0dec9fa5 100644 --- a/test/cmake/CheckDeveloperPin.cmake +++ b/test/cmake/CheckDeveloperPin.cmake @@ -33,13 +33,16 @@ endforeach() if(header_version VERSION_GREATER sources_version) message(FATAL_ERROR "DeveloperReleaseData.hpp pins ${header_version}, newer than distribution.json ${sources_version}") endif() -if(NOT header_environment MATCHES "/developer/${header_version}/environment\.tgz$") +# Literal dots: a version or a suffix with another character in their place is another path. +string(REPLACE "." "[.]" header_pattern "${header_version}") +string(REPLACE "." "[.]" bootstrap_pattern "${bootstrap_VERSION}") +if(NOT header_environment MATCHES "/developer/${header_pattern}/environment[.]tgz$") message(FATAL_ERROR "DeveloperReleaseData.hpp is not the header of its version ${header_version}: ${header_environment}") endif() if(bootstrap_VERSION VERSION_GREATER header_version) message(FATAL_ERROR "The bootstrap ${bootstrap_VERSION} is ahead of the header ${header_version}") endif() -if(NOT bootstrap_URL MATCHES "/developer/${bootstrap_VERSION}/environment\.tgz$") +if(NOT bootstrap_URL MATCHES "/developer/${bootstrap_pattern}/environment[.]tgz$") message(FATAL_ERROR "The bootstrap URL is not the one of its version ${bootstrap_VERSION}: ${bootstrap_URL}") endif() if(bootstrap_VERSION VERSION_EQUAL header_version diff --git a/test/cmake/CheckDeveloperPinTests.cmake b/test/cmake/CheckDeveloperPinTests.cmake index 07ff8c06..a754d9a6 100644 --- a/test/cmake/CheckDeveloperPinTests.cmake +++ b/test/cmake/CheckDeveloperPinTests.cmake @@ -12,7 +12,7 @@ function(fixture directory sources header bootstrap) file(MAKE_DIRECTORY "${WORK}/${directory}/js/developer/tools" "${WORK}/${directory}/include/webfront/system" "${WORK}/${directory}/cmake") file(WRITE "${WORK}/${directory}/js/developer/tools/distribution.json" "{\"version\": \"${sources}\", \"baseUrl\": \"https://dist.example/\"}") - # header and bootstrap are "[:[:]]". + # header and bootstrap are "[:[:[:]]]". foreach(kind header bootstrap) string(REPLACE ":" ";" parts "${${kind}}") list(GET parts 0 version) @@ -26,8 +26,12 @@ function(fixture directory sources header bootstrap) list(GET parts 2 digest) set(digest "${digest_${digest}}") endif() + set(suffix environment.tgz) + if(count GREATER 3) + list(GET parts 3 suffix) + endif() set(${kind}_version "${version}") - set(${kind}_url "https://dist.example/developer/${url_version}/environment.tgz") + set(${kind}_url "https://dist.example/developer/${url_version}/${suffix}") set(${kind}_digest "sha512-${digest}==") endforeach() file(WRITE "${WORK}/${directory}/include/webfront/system/DeveloperReleaseData.hpp" @@ -65,3 +69,7 @@ check("header that is not its version's" refuse "not the header of its version" check("bootstrap ahead of the header" refuse "ahead of the header" 0.6.6 0.6.4 0.6.5) check("bootstrap that is not its version's" refuse "not the one of its version" 0.6.6 0.6.5 0.6.4:0.6.3) check("bootstrap equal to the header, other integrity" refuse "both name" 0.6.6 0.6.5 0.6.5:0.6.5:b) +check("header whose version has other characters in place of its dots" refuse "not the header of its version" 0.6.6 0.6.5:0x6x5 0.6.4) +check("header whose file name has another character in place of its dot" refuse "not the header of its version" 0.6.6 0.6.5:0.6.5:a:environmentXtgz 0.6.4) +check("bootstrap whose version has other characters in place of its dots" refuse "not the one of its version" 0.6.6 0.6.5 0.6.4:0x6x4) +check("bootstrap whose file name has another character in place of its dot" refuse "not the one of its version" 0.6.6 0.6.5 0.6.4:0.6.4:a:environmentXtgz) diff --git a/test/cmake/CheckReleaseWorkflow.cmake b/test/cmake/CheckReleaseWorkflow.cmake index dff03d8e..c18abc3c 100644 --- a/test/cmake/CheckReleaseWorkflow.cmake +++ b/test/cmake/CheckReleaseWorkflow.cmake @@ -120,3 +120,8 @@ endif() if(NOT content MATCHES "cmake -S [.] -B build-driver\n") message(FATAL_ERROR "The rehearsal does not configure build-driver again after setting the version") endif() + +# The tag step can be rerun after a lost response: it accepts a tag that already points at the release commit. +if(NOT content MATCHES "echo \"[$]tag already points at the release commit\"") + message(FATAL_ERROR "The tag step is not rerunnable: it must accept an existing tag at the release commit") +endif() diff --git a/test/cmake/CheckReleaseWorkflowTests.cmake b/test/cmake/CheckReleaseWorkflowTests.cmake index 84237d36..4ddee155 100644 --- a/test/cmake/CheckReleaseWorkflowTests.cmake +++ b/test/cmake/CheckReleaseWorkflowTests.cmake @@ -51,3 +51,5 @@ check("a rehearsal without the browser suite" refuse "rehearsal does not" "ctest --test-dir build-driver -L web-integration" "ctest --test-dir build-driver -R Nothing") check("a rehearsal on a stale configuration" refuse "configure build-driver again" " cmake -S . -B build-driver\n" "") +check("a tag step that fails on an existing tag" refuse "not rerunnable" + "already points at the release commit\"\n elif" "exists\"\n elif") From a2863cdb91250dd7cbda6e959b8884e0e98d3405 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Mon, 9 Nov 2026 18:51:50 +0100 Subject: [PATCH 07/13] Check the minimum api of the compatibility row on a release (#482) CheckReleaseVersion.cmake accepted any integer in the Minimum api column and compared only the environment. Compare it with developer::apiVersion of the release commit and add the regression (a row with 999 is refused). --- test/cmake/CheckReleaseVersion.cmake | 19 +++++++++++++++---- test/cmake/CheckReleaseVersionTests.cmake | 4 ++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/test/cmake/CheckReleaseVersion.cmake b/test/cmake/CheckReleaseVersion.cmake index 16b49698..5d33ac60 100644 --- a/test/cmake/CheckReleaseVersion.cmake +++ b/test/cmake/CheckReleaseVersion.cmake @@ -60,13 +60,24 @@ if(release_tags) set(pinned_environment "${CMAKE_MATCH_1}") file(READ "${ROOT}/docs/DEVELOPER_ENVIRONMENT.md" environment_document) string(REPLACE "." "[.]" version_pattern "${header_version}") - if(NOT environment_document MATCHES "\n[|] ${version_pattern} [|] ([^ |]+) [|] [0-9]+ [|]\n") + if(NOT environment_document MATCHES "\n[|] ${version_pattern} [|] ([^ |]+) [|] ([0-9]+) [|]\n") message(FATAL_ERROR "The compatibility table of docs/DEVELOPER_ENVIRONMENT.md has no row for the library ${header_version}; " "freeze it with cmake/DeveloperCompatibility.cmake (MODE=freeze)") endif() - if(NOT "${CMAKE_MATCH_1}" STREQUAL "${pinned_environment}") - message(FATAL_ERROR "The compatibility row of ${header_version} names the environment ${CMAKE_MATCH_1}, " + set(row_environment "${CMAKE_MATCH_1}") + set(row_api "${CMAKE_MATCH_2}") + if(NOT "${row_environment}" STREQUAL "${pinned_environment}") + message(FATAL_ERROR "The compatibility row of ${header_version} names the environment ${row_environment}, " "but DeveloperReleaseData.hpp pins ${pinned_environment}") endif() - message(STATUS "Compatibility table: ${header_version} -> environment ${pinned_environment}") + # The minimum api is developer::apiVersion of the release commit. + file(READ "${ROOT}/include/webfront/DeveloperApp.hpp" application_header) + if(NOT application_header MATCHES "apiVersion *= *([0-9]+);") + message(FATAL_ERROR "DeveloperApp.hpp has no apiVersion") + endif() + if(NOT "${row_api}" STREQUAL "${CMAKE_MATCH_1}") + message(FATAL_ERROR "The compatibility row of ${header_version} gives the minimum api ${row_api}, " + "but developer::apiVersion is ${CMAKE_MATCH_1}") + endif() + message(STATUS "Compatibility table: ${header_version} -> environment ${pinned_environment}, api ${row_api}") endif() diff --git a/test/cmake/CheckReleaseVersionTests.cmake b/test/cmake/CheckReleaseVersionTests.cmake index f08d6e82..689d19e9 100644 --- a/test/cmake/CheckReleaseVersionTests.cmake +++ b/test/cmake/CheckReleaseVersionTests.cmake @@ -7,6 +7,7 @@ file(MAKE_DIRECTORY "${WORK}/archive/include/webfront") file(WRITE "${WORK}/archive/include/webfront/WebFront.hpp" "inline constexpr std::string_view version = \"0.1.0\";\n") file(MAKE_DIRECTORY "${WORK}/archive/include/webfront/system" "${WORK}/archive/docs") +file(WRITE "${WORK}/archive/include/webfront/DeveloperApp.hpp" "inline constexpr int apiVersion = 1;\n") file(WRITE "${WORK}/archive/include/webfront/system/DeveloperReleaseData.hpp" "inline constexpr std::string_view version{\"0.6.0\"};\n") function(write_table rows) @@ -48,6 +49,9 @@ check_case("Release without a compatibility row" failure "has no row" write_table("| 0.1.0 | 0.5.0 | 1 |\n") check_case("Compatibility row that differs from the header" failure "names the environment" -DEXPECTED_VERSION=0.1.0 -DRELEASE_TAG=v0.1.0) +write_table("| 0.1.0 | 0.6.0 | 999 |\n") +check_case("Compatibility row with another minimum api" failure "minimum api" + -DEXPECTED_VERSION=0.1.0 -DRELEASE_TAG=v0.1.0) write_table("| 0.1.0 | 0.6.0 | 1 |\n") find_package(Git REQUIRED QUIET) From 1998ecf756da420b29f8f25d26aa4c852c10c1b9 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Mon, 9 Nov 2026 19:19:35 +0100 Subject: [PATCH 08/13] Pass the WebKitGTK sandbox opt-out to the steps that start the browser (#482) The wf command sets WEBKIT_DISABLE_SANDBOX_THIS_IS_DANGEROUS for itself only: CTest in the rehearsal and developer_integration in the public smoke test start the browser directly, as in BuildAndTest.yml. Set it on both steps and have ReleaseDeveloperWorkflow require it. --- .github/workflows/ReleaseDeveloper.yml | 5 +++++ test/cmake/CheckReleaseWorkflow.cmake | 8 ++++++++ test/cmake/CheckReleaseWorkflowTests.cmake | 2 ++ 3 files changed, 15 insertions(+) diff --git a/.github/workflows/ReleaseDeveloper.yml b/.github/workflows/ReleaseDeveloper.yml index e4de00e5..240dc45a 100644 --- a/.github/workflows/ReleaseDeveloper.yml +++ b/.github/workflows/ReleaseDeveloper.yml @@ -94,6 +94,9 @@ jobs: # environment and the starters built from these sources (the candidate, whose bootstrap was just refreshed), and the # developer journey starts and runs them. A defect found here costs no version. - name: Run the browser suite on the candidate bytes served locally + env: + # The wf command of the wf-driver action sets it for itself only; CTest and its tests start the browser directly. + WEBKIT_DISABLE_SANDBOX_THIS_IS_DANGEROUS: '1' run: | # The driver was configured before the version was set: CTest read the former version of distribution.json then. cmake -S . -B build-driver @@ -281,6 +284,8 @@ jobs: done exit 1 - name: Run the public smoke test from the pinned header + env: + WEBKIT_DISABLE_SANDBOX_THIS_IS_DANGEROUS: '1' run: | cmake -S . -B build-public -G Ninja -DCMAKE_BUILD_TYPE=Release -DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_ENABLE_TESTING=ON \ -DWEBFRONT_EMBED_WEBKITGTK=ON -DWEBFRONT_WEBTEST_FRONTEND=WebKitGTK -DCMAKE_CXX_SCAN_FOR_MODULES=OFF diff --git a/test/cmake/CheckReleaseWorkflow.cmake b/test/cmake/CheckReleaseWorkflow.cmake index c18abc3c..41b76303 100644 --- a/test/cmake/CheckReleaseWorkflow.cmake +++ b/test/cmake/CheckReleaseWorkflow.cmake @@ -125,3 +125,11 @@ endif() if(NOT content MATCHES "echo \"[$]tag already points at the release commit\"") message(FATAL_ERROR "The tag step is not rerunnable: it must accept an existing tag at the release commit") endif() + +# The steps that start the browser directly (CTest, developer_integration) carry the WebKitGTK sandbox opt-out of the +# trusted fixtures, as BuildAndTest.yml does: the one of the wf command applies to that command only. +string(REGEX MATCHALL "WEBKIT_DISABLE_SANDBOX_THIS_IS_DANGEROUS: '1'" sandbox_settings "${content}") +list(LENGTH sandbox_settings sandbox_count) +if(NOT sandbox_count EQUAL 2) + message(FATAL_ERROR "The rehearsal and the public smoke test must each set the WebKitGTK sandbox opt-out (${sandbox_count} found)") +endif() diff --git a/test/cmake/CheckReleaseWorkflowTests.cmake b/test/cmake/CheckReleaseWorkflowTests.cmake index 4ddee155..87770a87 100644 --- a/test/cmake/CheckReleaseWorkflowTests.cmake +++ b/test/cmake/CheckReleaseWorkflowTests.cmake @@ -53,3 +53,5 @@ check("a rehearsal on a stale configuration" refuse "configure build-driver agai " cmake -S . -B build-driver\n" "") check("a tag step that fails on an existing tag" refuse "not rerunnable" "already points at the release commit\"\n elif" "exists\"\n elif") +check("a public smoke test without the sandbox opt-out" refuse "must each set" + " env:\n WEBKIT_DISABLE_SANDBOX_THIS_IS_DANGEROUS: '1'\n run: |\n cmake -S . -B build-public" " run: |\n cmake -S . -B build-public") From a9d7ea83800c2f85c67191059bbad8a8b1ce29e9 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Mon, 9 Nov 2026 19:37:33 +0100 Subject: [PATCH 09/13] Bound the migration waiver of wf run pin by version (#482) pinOrigin accepted any URL under previousBase, so a 0.6.6 pin on github.io passed although the migration closed with 0.6.5. The waiver now needs baseSince, the first version published under baseUrl, and covers only a pin whose version precedes it; a previousBase without baseSince (and the converse) is refused. Specs cover the boundary, the ordering of versions and the incomplete declarations. --- docs/CHANGELOG.md | 2 +- js/developer/scripts/pin.mjs | 34 +++++++++++++++---- js/developer/tools/PUBLISHING.md | 7 ++-- test/developer/specs/distribution-specs.mjs | 37 ++++++++++++++++----- 4 files changed, 62 insertions(+), 18 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index e8eaa9f7..af9e4ef0 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -16,7 +16,7 @@ with a dedicated GitHub application's token, tags in the same run, publishes, verifies the deployed bytes and opens the pull request into `develop`; its permissions are declared job by job and checked by `ReleaseDeveloperWorkflow`. `wf run pin` now fails (instead of warning) when the pinned URL is off the origin of `baseUrl`, redirects or lacks CORS, - and reads `previousBase` for the bounded migration waiver. `DeveloperPinConsistency` checks the states (a) to (c) and the + and reads `previousBase` and `baseSince` for the migration waiver, which covers only versions before `baseSince`. `DeveloperPinConsistency` checks the states (a) to (c) and the inconsistencies of ADR-021 decision 2. The compatibility table of `docs/DEVELOPER_ENVIRONMENT.md` is maintained by `cmake/DeveloperCompatibility.cmake` and enforced on `v*` tags by `CheckReleaseVersion.cmake`. The application, the tag rule and the first real publication are repository operations that remain to be done by a maintainer. diff --git a/js/developer/scripts/pin.mjs b/js/developer/scripts/pin.mjs index a9f197d9..1101452b 100644 --- a/js/developer/scripts/pin.mjs +++ b/js/developer/scripts/pin.mjs @@ -6,23 +6,45 @@ // The header must be exactly the one generated for its version, and the archive at its URL must have its integrity. import {baseUrl, bootstrapHeader, sriOf} from '../tools/distribution.mjs'; +/** The numeric core and the prerelease of a version: an earlier prerelease precedes its release. */ +function versionOrder(version) { + const match = /^(\d+)\.(\d+)\.(\d+)(?:-(.+))?$/.exec(version); + if (!match) throw new Error(`Invalid version ${version}`); + return {core: match.slice(1, 4).map(Number), prerelease: match[4]}; +} + +/** Whether version a precedes version b. */ +export function precedes(a, b) { + const left = versionOrder(a); + const right = versionOrder(b); + for (let index = 0; index < 3; index++) if (left.core[index] !== right.core[index]) return left.core[index] < right.core[index]; + if (left.prerelease === right.prerelease) return false; + if (left.prerelease === undefined) return false; + return right.prerelease === undefined || left.prerelease < right.prerelease; +} + /** * Where a pinned URL stands relative to the distribution's base URL (ADR-021, decision 2). Returns `{waiver, warning}`: - * `waiver` is true when the pin is tolerated only by the declared migration waiver (`previousBase` of distribution.json). - * Throws when the pinned URL is off the origin of the base without a valid waiver, or when a waiver is stale (the pin - * is on the current base, so `previousBase` must be removed). + * `waiver` is true when the pin is tolerated only by the declared migration waiver. The waiver is `previousBase` of + * distribution.json with `baseSince`, the first version published under `baseUrl`; it is bounded: it covers only a pin + * under `previousBase` whose version precedes `baseSince`. Throws when the pinned URL is off the origin of the base without + * a valid waiver, when the waiver is incomplete, when the pin is not before `baseSince`, or when the waiver is stale + * (the pin is on the current base, so `previousBase` and `baseSince` must be removed). */ -export function pinOrigin(pinnedUrl, base, previousBase) { +export function pinOrigin(pinnedUrl, base, previousBase, pinnedVersion, baseSince) { const current = new URL(baseUrl(base)); const pinned = new URL(pinnedUrl); const previous = previousBase === undefined ? undefined : new URL(baseUrl(previousBase)); if (previous && previous.origin === current.origin) throw new Error('previousBase must be on another origin than baseUrl'); + if (previous && baseSince === undefined) throw new Error('previousBase requires baseSince, the first version published under baseUrl'); + if (!previous && baseSince !== undefined) throw new Error('baseSince is only meaningful with previousBase'); if (pinned.origin === current.origin) { - if (previous) throw new Error(`Stale migration waiver: the header pins a version published under ${current.origin}; remove previousBase from distribution.json`); + if (previous) throw new Error(`Stale migration waiver: the header pins a version published under ${current.origin}; remove previousBase and baseSince from distribution.json`); return {waiver: false}; } if (!previous) throw new Error(`The pinned ${pinned.href} is not on ${current.origin}, the origin of baseUrl, and distribution.json declares no previousBase`); if (!pinned.href.startsWith(previous.href)) throw new Error(`The pinned ${pinned.href} is on neither ${current.origin} nor the declared previousBase ${previous.href}`); + if (!precedes(pinnedVersion, baseSince)) throw new Error(`The migration waiver covers only versions before ${baseSince}, the first published under ${current.origin}; ${pinnedVersion} must be pinned on ${current.origin}`); return {waiver: true, warning: `migration waiver: the pinned ${pinned.href} is under the previous base ${previous.href}; it is not checked for redirection or CORS, and a browser cannot start from it if it redirects`}; } @@ -40,7 +62,7 @@ export default async function (context) { // (ii) The pinned URL itself: on the origin of baseUrl, or under the declared migration waiver (ADR-021). const distribution = JSON.parse(await project.readText('js/developer/tools/distribution.json')); const current = baseUrl(distribution.baseUrl); - const {waiver, warning} = pinOrigin(url, current, distribution.previousBase); + const {waiver, warning} = pinOrigin(url, current, distribution.previousBase, version, distribution.baseSince); // (i) The bytes, fetched where the distribution is served now: the pinned integrity proves the file. const served = new URL(marker, current).href; const response = await context.fetch(served, {signal: context.signal}); diff --git a/js/developer/tools/PUBLISHING.md b/js/developer/tools/PUBLISHING.md index 5a19be17..158d18dc 100644 --- a/js/developer/tools/PUBLISHING.md +++ b/js/developer/tools/PUBLISHING.md @@ -44,8 +44,11 @@ run, which publishes the same bytes, and a defect found at that point requires t version. A failed `verify` opens no pull request and changes neither `develop` nor `master`. `pin.mjs` (`wf run pin`) fails when the pinned URL is not on the origin of `baseUrl`, redirects, or lacks CORS headers. The only -exception is a migration, declared by `previousBase` in `distribution.json` while the header still pins a version published -under that address; it prints a warning, and is refused as soon as the header pins a version published under the new address. +exception is a migration, declared in `distribution.json` by `previousBase` (the former address) together with `baseSince` (the +first version published under `baseUrl`). It is bounded: it covers only a header under `previousBase` whose version precedes +`baseSince`, prints a warning, and is refused for any later version, for a `previousBase` without `baseSince`, and as soon as the +header pins a version published under the new address (the two fields must then be removed). `baseSince` completes the ADR-021 +decision, which names `previousBase` only. **Repository settings the workflow needs** (made by a maintainer, not by the workflow): diff --git a/test/developer/specs/distribution-specs.mjs b/test/developer/specs/distribution-specs.mjs index 34c8b03c..def4ffaa 100644 --- a/test/developer/specs/distribution-specs.mjs +++ b/test/developer/specs/distribution-specs.mjs @@ -1,7 +1,7 @@ // Specs of the developer distribution: the starters, the Pages staging and the pinned bootstrap header. import {tar} from '../../../js/developer/tools/archive.mjs'; import {bootstrapHeader, versionPath, distributionFiles, customDomain} from '../../../js/developer/tools/distribution.mjs'; -import {pinOrigin} from '../../../js/developer/scripts/pin.mjs'; +import {pinOrigin, precedes} from '../../../js/developer/scripts/pin.mjs'; import stageSite from '../../../js/developer/scripts/site.mjs'; import {compress} from '../../../js/developer/environment/embed.mjs'; import {createStarter} from '../../../js/developer/environment/starter.mjs'; @@ -185,32 +185,51 @@ describe('The developer distribution', () => { const base = 'https://dist.webfront.fr/'; const previous = 'https://ambroise-leclerc.github.io/WebFront/'; const onBase = 'https://dist.webfront.fr/developer/0.6.5/environment.tgz'; - const onPrevious = 'https://ambroise-leclerc.github.io/WebFront/developer/0.6.4/environment.tgz'; + const onPrevious = version => `https://ambroise-leclerc.github.io/WebFront/developer/${version}/environment.tgz`; it('accepts a pin on the origin of baseUrl without a waiver', () => { - expect(pinOrigin(onBase, base)).toEqual({waiver: false}); + expect(pinOrigin(onBase, base, undefined, '0.6.5')).toEqual({waiver: false}); }); it('refuses a pin off the origin of baseUrl when no migration is declared', () => { - throws(() => pinOrigin(onPrevious, base), /declares no previousBase/); + throws(() => pinOrigin(onPrevious('0.6.4'), base, undefined, '0.6.4'), /declares no previousBase/); }); - it('tolerates a pin under the declared previousBase with a warning that names the waiver', () => { - const result = pinOrigin(onPrevious, base, previous); + it('tolerates a pin before baseSince under the declared previousBase, with a warning that names the waiver', () => { + const result = pinOrigin(onPrevious('0.6.4'), base, previous, '0.6.4', '0.6.5'); expect(result.waiver).toBe(true); expect(result.warning).toMatch(/migration waiver/); }); + it('refuses the waiver for the first version published under the new base and for any later one', () => { + for (const version of ['0.6.5', '0.6.6', '0.7.0', '1.0.0']) + throws(() => pinOrigin(onPrevious(version), base, previous, version, '0.6.5'), /covers only versions before 0.6.5/); + }); + + it('orders versions numerically, not as text, and a prerelease before its release', () => { + expect(precedes('0.6.4', '0.6.10')).toBe(true); + expect(precedes('0.6.10', '0.6.4')).toBe(false); + expect(precedes('0.6.5-rc.1', '0.6.5')).toBe(true); + expect(precedes('0.6.5', '0.6.5')).toBe(false); + expect(precedes('0.6.5', '0.6.5-rc.1')).toBe(false); + throws(() => precedes('0.6', '0.6.5'), /Invalid version/); + }); + + it('requires baseSince with previousBase, and previousBase with baseSince', () => { + throws(() => pinOrigin(onPrevious('0.6.4'), base, previous, '0.6.4'), /requires baseSince/); + throws(() => pinOrigin(onBase, base, undefined, '0.6.5', '0.6.5'), /only meaningful with previousBase/); + }); + it('refuses a pin outside both the base and the declared previousBase', () => { - throws(() => pinOrigin('https://elsewhere.example/developer/0.6.4/environment.tgz', base, previous), /neither/); + throws(() => pinOrigin('https://elsewhere.example/developer/0.6.4/environment.tgz', base, previous, '0.6.4', '0.6.5'), /neither/); }); it('refuses a stale waiver once the header pins a version published under the new base', () => { - throws(() => pinOrigin(onBase, base, previous), /Stale migration waiver/); + throws(() => pinOrigin(onBase, base, previous, '0.6.5', '0.6.5'), /Stale migration waiver/); }); it('refuses a previousBase on the origin of baseUrl', () => { - throws(() => pinOrigin(onBase, base, base), /another origin/); + throws(() => pinOrigin(onBase, base, base, '0.6.5', '0.6.5'), /another origin/); }); }); }); From af02d55bc3436902c81d3dd4ceb9b722cfe70b6b Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Mon, 9 Nov 2026 19:46:56 +0100 Subject: [PATCH 10/13] Compare prereleases by SemVer in the migration waiver of wf run pin (#482) The text comparison put 0.7.0-rc.10 before 0.7.0-rc.2, so a pin past a prerelease baseSince kept the waiver and skipped the redirection and CORS checks. Compare the dot-separated identifiers as SemVer 2.0.0 does (numbers numerically, below text, a prefix before its extension), with the SemVer example order and the rc.10 case as regressions. --- js/developer/scripts/pin.mjs | 38 ++++++++++++++++----- test/developer/specs/distribution-specs.mjs | 16 +++++++++ 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/js/developer/scripts/pin.mjs b/js/developer/scripts/pin.mjs index 1101452b..8042d23d 100644 --- a/js/developer/scripts/pin.mjs +++ b/js/developer/scripts/pin.mjs @@ -6,21 +6,41 @@ // The header must be exactly the one generated for its version, and the archive at its URL must have its integrity. import {baseUrl, bootstrapHeader, sriOf} from '../tools/distribution.mjs'; -/** The numeric core and the prerelease of a version: an earlier prerelease precedes its release. */ +/** The numeric core and the dot-separated prerelease identifiers of a version (the names of distribution.json). */ function versionOrder(version) { - const match = /^(\d+)\.(\d+)\.(\d+)(?:-(.+))?$/.exec(version); + const match = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/.exec(version); if (!match) throw new Error(`Invalid version ${version}`); - return {core: match.slice(1, 4).map(Number), prerelease: match[4]}; + return {core: match.slice(1, 4).map(Number), prerelease: match[4]?.split('.')}; } -/** Whether version a precedes version b. */ -export function precedes(a, b) { +const numeric = identifier => /^\d+$/.test(identifier); + +/** The precedence of two prerelease identifiers (SemVer 2.0.0, 11.4): numbers numerically, below text, text in ASCII order. */ +function compareIdentifiers(a, b) { + if (numeric(a) && numeric(b)) return Math.sign(Number(a) - Number(b)); + if (numeric(a)) return -1; + if (numeric(b)) return 1; + return a < b ? -1 : a > b ? 1 : 0; +} + +/** The SemVer 2.0.0 precedence of two versions: negative when a precedes b, 0 when they are equal, positive otherwise. */ +export function compareVersions(a, b) { const left = versionOrder(a); const right = versionOrder(b); - for (let index = 0; index < 3; index++) if (left.core[index] !== right.core[index]) return left.core[index] < right.core[index]; - if (left.prerelease === right.prerelease) return false; - if (left.prerelease === undefined) return false; - return right.prerelease === undefined || left.prerelease < right.prerelease; + for (let index = 0; index < 3; index++) if (left.core[index] !== right.core[index]) return Math.sign(left.core[index] - right.core[index]); + // A prerelease precedes its release. + if (!left.prerelease || !right.prerelease) return (left.prerelease ? -1 : 0) - (right.prerelease ? -1 : 0); + for (let index = 0; index < Math.min(left.prerelease.length, right.prerelease.length); index++) { + const order = compareIdentifiers(left.prerelease[index], right.prerelease[index]); + if (order !== 0) return order; + } + // With equal leading identifiers, the shorter list precedes the longer one. + return Math.sign(left.prerelease.length - right.prerelease.length); +} + +/** Whether version a precedes version b. */ +export function precedes(a, b) { + return compareVersions(a, b) < 0; } /** diff --git a/test/developer/specs/distribution-specs.mjs b/test/developer/specs/distribution-specs.mjs index def4ffaa..4e3e40ae 100644 --- a/test/developer/specs/distribution-specs.mjs +++ b/test/developer/specs/distribution-specs.mjs @@ -215,6 +215,22 @@ describe('The developer distribution', () => { throws(() => precedes('0.6', '0.6.5'), /Invalid version/); }); + it('orders prereleases by SemVer: numeric identifiers as numbers, below text, and a prefix before its extension', () => { + // The SemVer 2.0.0 example: 1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0 + const ordered = ['1.0.0-alpha', '1.0.0-alpha.1', '1.0.0-alpha.beta', '1.0.0-beta', '1.0.0-beta.2', '1.0.0-beta.11', '1.0.0-rc.1', '1.0.0']; + for (let low = 0; low < ordered.length; low++) + for (let high = 0; high < ordered.length; high++) + expect(precedes(ordered[low], ordered[high])).withContext(`${ordered[low]} before ${ordered[high]}`).toBe(low < high); + expect(precedes('0.7.0-rc.2', '0.7.0-rc.10')).toBe(true); + expect(precedes('0.7.0-rc.10', '0.7.0-rc.2')).toBe(false); + }); + + it('does not tolerate a pin past a prerelease baseSince through the order of its identifiers', () => { + const version = '0.7.0-rc.10'; + throws(() => pinOrigin(onPrevious(version), base, previous, version, '0.7.0-rc.2'), /covers only versions before 0.7.0-rc.2/); + expect(pinOrigin(onPrevious('0.7.0-rc.2'), base, previous, '0.7.0-rc.2', '0.7.0-rc.10').waiver).toBe(true); + }); + it('requires baseSince with previousBase, and previousBase with baseSince', () => { throws(() => pinOrigin(onPrevious('0.6.4'), base, previous, '0.6.4'), /requires baseSince/); throws(() => pinOrigin(onBase, base, undefined, '0.6.5', '0.6.5'), /only meaningful with previousBase/); From 11821de64afdb6614bc685c698fb8b1d79fa7161 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Mon, 9 Nov 2026 19:53:54 +0100 Subject: [PATCH 11/13] Order the versions of the pin check by SemVer (#482) CMake's VERSION_GREATER and VERSION_EQUAL ignore the prerelease: sources 0.7.0-rc.1 with a 0.7.0-rc.2 header passed as equal, and a bootstrap 0.7.0-rc.1 under a 0.7.0 header was refused as inconsistent. SemVer.cmake implements the SemVer 2.0.0 precedence (as pin.mjs does); CheckDeveloperPin.cmake uses it, with regressions for both cases and SemVerOrdering for the order itself. --- test/cmake/CheckDeveloperPin.cmake | 12 ++-- test/cmake/CheckDeveloperPinTests.cmake | 8 +++ test/cmake/CheckSemVer.cmake | 27 +++++++ test/cmake/SemVer.cmake | 95 +++++++++++++++++++++++++ test/unit/CMakeLists.txt | 4 +- 5 files changed, 141 insertions(+), 5 deletions(-) create mode 100644 test/cmake/CheckSemVer.cmake create mode 100644 test/cmake/SemVer.cmake diff --git a/test/cmake/CheckDeveloperPin.cmake b/test/cmake/CheckDeveloperPin.cmake index 0dec9fa5..d147b333 100644 --- a/test/cmake/CheckDeveloperPin.cmake +++ b/test/cmake/CheckDeveloperPin.cmake @@ -7,6 +7,7 @@ # with another URL or integrity. The bytes and the origin of the pinned URL are checked by `wf run pin`; a header equal to a # fresh build, by the comparison of the Developer packages workflow. ROOT is the repository (or a fixture of it). cmake_minimum_required(VERSION 3.31) +include("${CMAKE_CURRENT_LIST_DIR}/SemVer.cmake") if(NOT ROOT) message(FATAL_ERROR "ROOT is required") endif() @@ -30,7 +31,10 @@ foreach(field VERSION URL INTEGRITY) set(bootstrap_${field} "${CMAKE_MATCH_1}") endforeach() -if(header_version VERSION_GREATER sources_version) +# SemVer precedence: CMake's VERSION_* comparisons ignore the prerelease (0.7.0-rc.2 against 0.7.0-rc.1). +webfront_semver_compare("${header_version}" "${sources_version}" header_to_sources) +webfront_semver_compare("${bootstrap_VERSION}" "${header_version}" bootstrap_to_header) +if(header_to_sources GREATER 0) message(FATAL_ERROR "DeveloperReleaseData.hpp pins ${header_version}, newer than distribution.json ${sources_version}") endif() # Literal dots: a version or a suffix with another character in their place is another path. @@ -39,18 +43,18 @@ string(REPLACE "." "[.]" bootstrap_pattern "${bootstrap_VERSION}") if(NOT header_environment MATCHES "/developer/${header_pattern}/environment[.]tgz$") message(FATAL_ERROR "DeveloperReleaseData.hpp is not the header of its version ${header_version}: ${header_environment}") endif() -if(bootstrap_VERSION VERSION_GREATER header_version) +if(bootstrap_to_header GREATER 0) message(FATAL_ERROR "The bootstrap ${bootstrap_VERSION} is ahead of the header ${header_version}") endif() if(NOT bootstrap_URL MATCHES "/developer/${bootstrap_pattern}/environment[.]tgz$") message(FATAL_ERROR "The bootstrap URL is not the one of its version ${bootstrap_VERSION}: ${bootstrap_URL}") endif() -if(bootstrap_VERSION VERSION_EQUAL header_version +if(bootstrap_to_header EQUAL 0 AND (NOT bootstrap_URL STREQUAL header_environment OR NOT bootstrap_INTEGRITY STREQUAL header_integrity)) message(FATAL_ERROR "The bootstrap and the header both name ${header_version} with a different URL or integrity") endif() -if(header_version VERSION_EQUAL sources_version) +if(header_to_sources EQUAL 0) set(state "(b) sources equal to the header") else() set(state "(a) sources ${sources_version} ahead of the header") diff --git a/test/cmake/CheckDeveloperPinTests.cmake b/test/cmake/CheckDeveloperPinTests.cmake index a754d9a6..b491459c 100644 --- a/test/cmake/CheckDeveloperPinTests.cmake +++ b/test/cmake/CheckDeveloperPinTests.cmake @@ -73,3 +73,11 @@ check("header whose version has other characters in place of its dots" refuse "n check("header whose file name has another character in place of its dot" refuse "not the header of its version" 0.6.6 0.6.5:0.6.5:a:environmentXtgz 0.6.4) check("bootstrap whose version has other characters in place of its dots" refuse "not the one of its version" 0.6.6 0.6.5 0.6.4:0x6x4) check("bootstrap whose file name has another character in place of its dot" refuse "not the one of its version" 0.6.6 0.6.5 0.6.4:0.6.4:a:environmentXtgz) +# Prereleases follow SemVer, not the numeric core alone. +check("a header newer than the sources by its prerelease" refuse "newer than distribution.json" 0.7.0-rc.1 0.7.0-rc.2 0.6.5) +check("a header newer than the sources by a longer prerelease number" refuse "newer than distribution.json" 0.7.0-rc.2 0.7.0-rc.10 0.6.5) +check("a bootstrap ahead of the header by its prerelease" refuse "ahead of the header" 0.7.0-rc.2 0.7.0-rc.1 0.7.0-rc.2) +check("sources that are a prerelease ahead of the header" accept "Developer pin: [(]a[)]" 0.7.0-rc.2 0.7.0-rc.1 0.6.5) +check("sources equal to a prerelease header" accept "Developer pin: [(]b[)]" 0.7.0-rc.2 0.7.0-rc.2 0.7.0-rc.1) +check("a bootstrap that is an earlier prerelease of the header's release" accept "bootstrap 0.7.0-rc.1" 0.7.0 0.7.0 0.7.0-rc.1) +check("a bootstrap that is the release of a header prerelease" refuse "ahead of the header" 0.7.0 0.7.0-rc.1 0.7.0) diff --git a/test/cmake/CheckSemVer.cmake b/test/cmake/CheckSemVer.cmake new file mode 100644 index 00000000..d4e8258d --- /dev/null +++ b/test/cmake/CheckSemVer.cmake @@ -0,0 +1,27 @@ +# SemVer.cmake orders the versions as SemVer 2.0.0 does, in particular the prereleases that VERSION_LESS ignores. +cmake_minimum_required(VERSION 3.31) +include("${CMAKE_CURRENT_LIST_DIR}/SemVer.cmake") + +# The SemVer 2.0.0 example, then releases, in increasing order. +set(ordered 0.6.4 0.6.10 0.7.0-alpha 0.7.0-alpha.1 0.7.0-alpha.beta 0.7.0-beta 0.7.0-beta.2 0.7.0-beta.11 0.7.0-rc.1 0.7.0-rc.2 + 0.7.0-rc.10 0.7.0 0.7.1 1.0.0) +list(LENGTH ordered count) +math(EXPR last "${count} - 1") +foreach(low RANGE ${last}) + foreach(high RANGE ${last}) + list(GET ordered ${low} a) + list(GET ordered ${high} b) + webfront_semver_compare("${a}" "${b}" order) + if(low LESS high) + set(expected -1) + elseif(low GREATER high) + set(expected 1) + else() + set(expected 0) + endif() + if(NOT order EQUAL expected) + message(FATAL_ERROR "${a} against ${b}: got ${order}, expected ${expected}") + endif() + endforeach() +endforeach() +message(STATUS "${count} versions ordered as SemVer 2.0.0 does") diff --git a/test/cmake/SemVer.cmake b/test/cmake/SemVer.cmake new file mode 100644 index 00000000..c7950c0b --- /dev/null +++ b/test/cmake/SemVer.cmake @@ -0,0 +1,95 @@ +# SemVer 2.0.0 precedence of the versions of the developer distribution (MAJOR.MINOR.PATCH[-prerelease], the names of +# distribution.json). CMake's VERSION_LESS and VERSION_EQUAL ignore the prerelease, so they cannot order 0.7.0-rc.2 and 0.7.0. +# webfront_semver_compare( ) sets the variable to -1 (a precedes b), 0 (equal) or 1 +# The same rules as compareVersions of js/developer/scripts/pin.mjs. + +function(webfront_semver_parse version prefix) + if(NOT version MATCHES "^([0-9]+)[.]([0-9]+)[.]([0-9]+)(-([0-9A-Za-z.-]+))?$") + message(FATAL_ERROR "Invalid version '${version}'") + endif() + set(${prefix}_core "${CMAKE_MATCH_1};${CMAKE_MATCH_2};${CMAKE_MATCH_3}" PARENT_SCOPE) + set(has_prerelease FALSE) + if(CMAKE_MATCH_4) + set(has_prerelease TRUE) + endif() + set(${prefix}_has_prerelease ${has_prerelease} PARENT_SCOPE) + string(REPLACE "." ";" identifiers "${CMAKE_MATCH_5}") + set(${prefix}_prerelease "${identifiers}" PARENT_SCOPE) +endfunction() + +function(webfront_semver_compare a b result) + webfront_semver_parse("${a}" left) + webfront_semver_parse("${b}" right) + foreach(index IN ITEMS 0 1 2) + list(GET left_core ${index} x) + list(GET right_core ${index} y) + if(x LESS y) + set(${result} -1 PARENT_SCOPE) + return() + elseif(x GREATER y) + set(${result} 1 PARENT_SCOPE) + return() + endif() + endforeach() + # A prerelease precedes its release. + if(NOT left_has_prerelease AND NOT right_has_prerelease) + set(${result} 0 PARENT_SCOPE) + return() + elseif(left_has_prerelease AND NOT right_has_prerelease) + set(${result} -1 PARENT_SCOPE) + return() + elseif(NOT left_has_prerelease AND right_has_prerelease) + set(${result} 1 PARENT_SCOPE) + return() + endif() + list(LENGTH left_prerelease left_length) + list(LENGTH right_prerelease right_length) + if(left_length LESS right_length) + set(shared ${left_length}) + else() + set(shared ${right_length}) + endif() + math(EXPR last "${shared} - 1") + foreach(index RANGE ${last}) + list(GET left_prerelease ${index} x) + list(GET right_prerelease ${index} y) + set(x_numeric FALSE) + set(y_numeric FALSE) + if(x MATCHES "^[0-9]+$") + set(x_numeric TRUE) + endif() + if(y MATCHES "^[0-9]+$") + set(y_numeric TRUE) + endif() + # Numbers compare as numbers and precede text; text compares in ASCII order. + if(x_numeric AND y_numeric) + if(x LESS y) + set(${result} -1 PARENT_SCOPE) + return() + elseif(x GREATER y) + set(${result} 1 PARENT_SCOPE) + return() + endif() + elseif(x_numeric) + set(${result} -1 PARENT_SCOPE) + return() + elseif(y_numeric) + set(${result} 1 PARENT_SCOPE) + return() + elseif(x STRLESS y) + set(${result} -1 PARENT_SCOPE) + return() + elseif(x STRGREATER y) + set(${result} 1 PARENT_SCOPE) + return() + endif() + endforeach() + # With equal leading identifiers, the shorter list precedes the longer one. + if(left_length LESS right_length) + set(${result} -1 PARENT_SCOPE) + elseif(left_length GREATER right_length) + set(${result} 1 PARENT_SCOPE) + else() + set(${result} 0 PARENT_SCOPE) + endif() +endfunction() diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index ec1ba939..ed966990 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -178,11 +178,13 @@ add_test(NAME ReleaseDeveloperWorkflow add_test(NAME ReleaseDeveloperWorkflowRegression COMMAND ${CMAKE_COMMAND} -DROOT=${PROJECT_SOURCE_DIR} -DWORK=${CMAKE_CURRENT_BINARY_DIR}/release-workflow-regression -P ${PROJECT_SOURCE_DIR}/test/cmake/CheckReleaseWorkflowTests.cmake) +add_test(NAME SemVerOrdering + COMMAND ${CMAKE_COMMAND} -P ${PROJECT_SOURCE_DIR}/test/cmake/CheckSemVer.cmake) add_test(NAME DeveloperCompatibilityTable COMMAND ${CMAKE_COMMAND} -DROOT=${PROJECT_SOURCE_DIR} -DWORK=${CMAKE_CURRENT_BINARY_DIR}/developer-compatibility -P ${PROJECT_SOURCE_DIR}/test/cmake/CheckDeveloperCompatibility.cmake) set_tests_properties(DeveloperPinConsistency DeveloperPinRegression ReleaseDeveloperWorkflow ReleaseDeveloperWorkflowRegression - DeveloperCompatibilityTable + DeveloperCompatibilityTable SemVerOrdering PROPERTIES TIMEOUT 60 LABELS fast) add_test(NAME BootstrapProvisioning COMMAND ${CMAKE_COMMAND} -DROOT=${PROJECT_SOURCE_DIR} -DWORK=${CMAKE_CURRENT_BINARY_DIR}/bootstrap-provisioning From 79ee25b9b98d4af188ad89ac4966e455b5532fe3 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Mon, 9 Nov 2026 19:58:04 +0100 Subject: [PATCH 12/13] Close a domain migration with the release and check it before publishing (#482) A release that changes baseUrl regenerates the pin on the new domain but kept previousBase and baseSince, so wf run pin refused the stale waiver after the tag and the publication, with no way to resume. The release commit now removes both fields, and CheckDeveloperPin.cmake, run before anything is published, refuses a stale or incomplete waiver and a header off baseUrl without one. --- .github/workflows/ReleaseDeveloper.yml | 6 ++-- js/developer/tools/PUBLISHING.md | 4 ++- test/cmake/CheckDeveloperPin.cmake | 32 ++++++++++++++++++++++ test/cmake/CheckDeveloperPinTests.cmake | 26 ++++++++++++++++-- test/cmake/CheckReleaseWorkflow.cmake | 9 ++++++ test/cmake/CheckReleaseWorkflowTests.cmake | 4 +++ 6 files changed, 76 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ReleaseDeveloper.yml b/.github/workflows/ReleaseDeveloper.yml index 240dc45a..c3971aa8 100644 --- a/.github/workflows/ReleaseDeveloper.yml +++ b/.github/workflows/ReleaseDeveloper.yml @@ -64,9 +64,11 @@ jobs: fi - uses: ./.github/actions/remove-node - uses: ./.github/actions/wf-driver - - name: Set the version + - name: Set the version and close a migration run: | - jq --arg version "$VERSION" '.version = $version' js/developer/tools/distribution.json > "$RUNNER_TEMP/distribution.json" + # The header generated below pins this version under baseUrl: a migration waiver (previousBase and baseSince) + # would then be stale, and wf run pin refuses it after the publication. The release commit removes it. + jq --arg version "$VERSION" '.version = $version | del(.previousBase, .baseSince)' js/developer/tools/distribution.json > "$RUNNER_TEMP/distribution.json" cp "$RUNNER_TEMP/distribution.json" js/developer/tools/distribution.json - name: Restore the locked build dependencies run: wf restore diff --git a/js/developer/tools/PUBLISHING.md b/js/developer/tools/PUBLISHING.md index 158d18dc..d160246b 100644 --- a/js/developer/tools/PUBLISHING.md +++ b/js/developer/tools/PUBLISHING.md @@ -48,7 +48,9 @@ exception is a migration, declared in `distribution.json` by `previousBase` (the first version published under `baseUrl`). It is bounded: it covers only a header under `previousBase` whose version precedes `baseSince`, prints a warning, and is refused for any later version, for a `previousBase` without `baseSince`, and as soon as the header pins a version published under the new address (the two fields must then be removed). `baseSince` completes the ADR-021 -decision, which names `previousBase` only. +decision, which names `previousBase` only. The release workflow removes both fields from the release commit, since the header it +generates is under `baseUrl`, and `CheckDeveloperPin.cmake` (run before anything is published) refuses a waiver that is stale, +incomplete, or whose header is off `baseUrl` without one. **Repository settings the workflow needs** (made by a maintainer, not by the workflow): diff --git a/test/cmake/CheckDeveloperPin.cmake b/test/cmake/CheckDeveloperPin.cmake index d147b333..7ec12ef0 100644 --- a/test/cmake/CheckDeveloperPin.cmake +++ b/test/cmake/CheckDeveloperPin.cmake @@ -54,6 +54,38 @@ if(bootstrap_to_header EQUAL 0 message(FATAL_ERROR "The bootstrap and the header both name ${header_version} with a different URL or integrity") endif() +# The origin of the pinned URL (ADR-021, decision 2, criterion 7), offline: on baseUrl, or under the declared migration +# waiver (previousBase with baseSince), which covers only a header whose version precedes baseSince. A waiver that the +# header has outgrown is stale: the release workflow removes it with the pin it generates, and this check, which it runs +# before anything is published, stops a release that would leave it. +string(JSON base_url GET "${distribution}" baseUrl) +if(NOT base_url MATCHES "/$") + string(APPEND base_url "/") +endif() +string(JSON previous_base ERROR_VARIABLE no_previous GET "${distribution}" previousBase) +string(JSON base_since ERROR_VARIABLE no_since GET "${distribution}" baseSince) +if(no_previous AND NOT no_since) + message(FATAL_ERROR "distribution.json has baseSince without previousBase") +elseif(NOT no_previous AND no_since) + message(FATAL_ERROR "distribution.json has previousBase without baseSince, the first version published under baseUrl") +elseif(NOT no_previous) + if(NOT previous_base MATCHES "/$") + string(APPEND previous_base "/") + endif() + webfront_semver_compare("${header_version}" "${base_since}" header_to_base_since) + string(FIND "${header_environment}" "${previous_base}" on_previous) + if(NOT on_previous EQUAL 0 OR NOT header_to_base_since LESS 0) + message(FATAL_ERROR "The migration waiver of distribution.json is stale: the header ${header_version} must be under " + "${previous_base} and precede ${base_since}; remove previousBase and baseSince") + endif() +else() + string(FIND "${header_environment}" "${base_url}" on_base) + if(NOT on_base EQUAL 0) + message(FATAL_ERROR "The header pins ${header_environment}, which is not under baseUrl ${base_url}, and distribution.json " + "declares no migration") + endif() +endif() + if(header_to_sources EQUAL 0) set(state "(b) sources equal to the header") else() diff --git a/test/cmake/CheckDeveloperPinTests.cmake b/test/cmake/CheckDeveloperPinTests.cmake index b491459c..de0ea57f 100644 --- a/test/cmake/CheckDeveloperPinTests.cmake +++ b/test/cmake/CheckDeveloperPinTests.cmake @@ -4,6 +4,8 @@ if(NOT ROOT OR NOT WORK) message(FATAL_ERROR "ROOT and WORK are required") endif() +set(HEADER_BASE "https://dist.example/") +set(extra_json "") string(REPEAT "A" 86 digest_a) string(REPEAT "B" 86 digest_b) @@ -11,7 +13,10 @@ function(fixture directory sources header bootstrap) file(REMOVE_RECURSE "${WORK}/${directory}") file(MAKE_DIRECTORY "${WORK}/${directory}/js/developer/tools" "${WORK}/${directory}/include/webfront/system" "${WORK}/${directory}/cmake") - file(WRITE "${WORK}/${directory}/js/developer/tools/distribution.json" "{\"version\": \"${sources}\", \"baseUrl\": \"https://dist.example/\"}") + file(WRITE "${WORK}/${directory}/js/developer/tools/distribution.json" "{\"version\": \"${sources}\", \"baseUrl\": \"https://dist.example/\"${extra_json}}") + # The header is served from header_base (the base URL by default); extra_json adds fields to distribution.json. + set(header_base "${HEADER_BASE}") + set(bootstrap_base "https://dist.example/") # header and bootstrap are "[:[:[:]]]". foreach(kind header bootstrap) string(REPLACE ":" ";" parts "${${kind}}") @@ -31,7 +36,7 @@ function(fixture directory sources header bootstrap) list(GET parts 3 suffix) endif() set(${kind}_version "${version}") - set(${kind}_url "https://dist.example/developer/${url_version}/${suffix}") + set(${kind}_url "${${kind}_base}developer/${url_version}/${suffix}") set(${kind}_digest "sha512-${digest}==") endforeach() file(WRITE "${WORK}/${directory}/include/webfront/system/DeveloperReleaseData.hpp" @@ -81,3 +86,20 @@ check("sources that are a prerelease ahead of the header" accept "Developer pin: check("sources equal to a prerelease header" accept "Developer pin: [(]b[)]" 0.7.0-rc.2 0.7.0-rc.2 0.7.0-rc.1) check("a bootstrap that is an earlier prerelease of the header's release" accept "bootstrap 0.7.0-rc.1" 0.7.0 0.7.0 0.7.0-rc.1) check("a bootstrap that is the release of a header prerelease" refuse "ahead of the header" 0.7.0 0.7.0-rc.1 0.7.0) +# The origin of the pinned URL and the migration waiver. +set(old_base "https://old.example/") +set(waiver ", \"previousBase\": \"https://old.example/\", \"baseSince\": \"0.6.6\"") +set(extra_json "${waiver}") +set(HEADER_BASE "${old_base}") +check("a header under previousBase before baseSince" accept "Developer pin: [(]a[)]" 0.6.6 0.6.5 0.6.4) +check("a header under previousBase at baseSince" refuse "waiver of distribution.json is stale" 0.6.6 0.6.6 0.6.4) +set(HEADER_BASE "https://dist.example/") +check("a waiver that the pin generated by the release outgrew" refuse "waiver of distribution.json is stale" 0.6.6 0.6.6 0.6.5) +set(extra_json ", \"previousBase\": \"https://old.example/\"") +check("a previousBase without baseSince" refuse "without baseSince" 0.6.6 0.6.5 0.6.4) +set(extra_json ", \"baseSince\": \"0.6.6\"") +check("a baseSince without previousBase" refuse "without previousBase" 0.6.6 0.6.5 0.6.4) +set(extra_json "") +set(HEADER_BASE "${old_base}") +check("a header off baseUrl without a declared migration" refuse "not under baseUrl" 0.6.6 0.6.5 0.6.4) +set(HEADER_BASE "https://dist.example/") diff --git a/test/cmake/CheckReleaseWorkflow.cmake b/test/cmake/CheckReleaseWorkflow.cmake index 41b76303..b4dad98e 100644 --- a/test/cmake/CheckReleaseWorkflow.cmake +++ b/test/cmake/CheckReleaseWorkflow.cmake @@ -133,3 +133,12 @@ list(LENGTH sandbox_settings sandbox_count) if(NOT sandbox_count EQUAL 2) message(FATAL_ERROR "The rehearsal and the public smoke test must each set the WebKitGTK sandbox opt-out (${sandbox_count} found)") endif() + +# A migration is closed by the release commit: the pin it generates is under baseUrl, so the waiver would be stale. +if(NOT content MATCHES "del[(][.]previousBase, [.]baseSince[)]") + message(FATAL_ERROR "The release does not remove the migration fields of distribution.json") +endif() +# The offline check of the pin, which refuses a stale waiver, runs before anything is published. +if(NOT content MATCHES "test/cmake/CheckDeveloperPin[.]cmake") + message(FATAL_ERROR "The release does not run CheckDeveloperPin.cmake before publishing") +endif() diff --git a/test/cmake/CheckReleaseWorkflowTests.cmake b/test/cmake/CheckReleaseWorkflowTests.cmake index 87770a87..63a75797 100644 --- a/test/cmake/CheckReleaseWorkflowTests.cmake +++ b/test/cmake/CheckReleaseWorkflowTests.cmake @@ -55,3 +55,7 @@ check("a tag step that fails on an existing tag" refuse "not rerunnable" "already points at the release commit\"\n elif" "exists\"\n elif") check("a public smoke test without the sandbox opt-out" refuse "must each set" " env:\n WEBKIT_DISABLE_SANDBOX_THIS_IS_DANGEROUS: '1'\n run: |\n cmake -S . -B build-public" " run: |\n cmake -S . -B build-public") +check("a release that keeps the migration fields" refuse "does not remove" + " | del(.previousBase, .baseSince)" "") +check("a release that skips the offline pin check" refuse "does not run CheckDeveloperPin" + "test/cmake/CheckDeveloperPin.cmake" "test/cmake/Other.cmake") From 6adfa725ff40a7cc17fadd6d665b2fe4a67c42d4 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Mon, 9 Nov 2026 22:09:45 +0100 Subject: [PATCH 13/13] Make the workflow mutations precise and the closed-list header exact (#482) --- js/developer/tools/check-release-paths.sh | 2 +- test/cmake/CheckReleaseWorkflowTests.cmake | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/js/developer/tools/check-release-paths.sh b/js/developer/tools/check-release-paths.sh index f7d5018c..b30b70e3 100755 --- a/js/developer/tools/check-release-paths.sh +++ b/js/developer/tools/check-release-paths.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # Fails when the working tree differs from HEAD on a path outside the closed list of the release commit (ADR-021, decision 1), -# or when an untracked file exists. The list is the arguments: the release-developer workflow declares it once. +# or when an untracked file outside the list exists (the files of the list may be changed or new). The list is the arguments: the release-developer workflow declares it once. # check-release-paths.sh ... set -euo pipefail diff --git a/test/cmake/CheckReleaseWorkflowTests.cmake b/test/cmake/CheckReleaseWorkflowTests.cmake index 63a75797..0091f0cd 100644 --- a/test/cmake/CheckReleaseWorkflowTests.cmake +++ b/test/cmake/CheckReleaseWorkflowTests.cmake @@ -8,7 +8,7 @@ file(READ "${workflow}" original) file(MAKE_DIRECTORY "${WORK}") function(check description expected message) - # Each mutation is a "from" then a "to" text (the first occurrence of "from" is replaced). + # Each mutation is a "from" then a "to" text; "from" must occur exactly once, so that a mutation changes one place. set(content "${original}") set(arguments ${ARGN}) while(arguments) @@ -17,6 +17,10 @@ function(check description expected message) if(at EQUAL -1) message(FATAL_ERROR "${description}: the mutation target '${from}' is not in the workflow") endif() + string(FIND "${content}" "${from}" last REVERSE) + if(NOT at EQUAL last) + message(FATAL_ERROR "${description}: the mutation target '${from}' occurs more than once in the workflow") + endif() string(REPLACE "${from}" "${to}" content "${content}") endwhile() file(WRITE "${WORK}/ReleaseDeveloper.yml" "${content}")