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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ on:
branches: [main]
pull_request:
workflow_dispatch:
inputs:
prepare-environment:
description: Prepare and publish CI environments instead of running the test matrix.
type: boolean
default: false

permissions:
contents: read
Expand All @@ -41,8 +46,19 @@ concurrency:
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
prepare-environment:
name: Prepare environments
if: >-
github.event_name == 'workflow_dispatch' && inputs.prepare-environment
&& github.repository == 'webcpporg/webcpp'
permissions:
contents: read
packages: write
uses: ./.github/workflows/prepare-environments.yml

ci:
name: CI
if: inputs.prepare-environment != true
uses: ./.github/workflows/library.yml

site:
Expand Down
35 changes: 5 additions & 30 deletions .github/workflows/library.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@
# emscripten lane emsdk and Node, which runs its programs, and a lane whose entry
# says external the libraries its libraries need, built with the lane's compilers.
# GCC 14 and Clang 18 run their b2 in a container with no network but the loopback,
# whose image (tools/ci/container/Dockerfile) they load from the cache.
# container when a lane runs in a container: builds that image once per run when the cache
# does not hold it, and saves it there; every lane waits for it.
# whose image is prepared separately and pulled by its immutable digest.
# own-lanes one job per own lane of a library and target it runs on, which runs the lane
# in every directory that declares it there. One that names no target, as an
# oracle, runs on Linux x86-64 with Clang 18, and with Node when it runs the
Expand Down Expand Up @@ -106,7 +104,6 @@ jobs:
has-emscripten: ${{ steps.plan.outputs.has-emscripten }}
external: ${{ steps.plan.outputs.external }}
lint-external: ${{ steps.plan.outputs.lint-external }}
has-container: ${{ steps.plan.outputs.has-container }}
steps:
# The superproject is the caller's commit when it calls this workflow itself, and main
# when a library does, the branch this workflow is called at.
Expand Down Expand Up @@ -169,11 +166,6 @@ jobs:
matrix="$(python3 tools/ci/matrix.py plan "${arguments[@]}")"
python3 -m json.tool <<< "$matrix"
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
# Whether a lane runs in a container, whose image the container job builds first.
has_container="$(python3 -c 'import json, sys
print(str(any(lane["container"] for lane in json.load(sys.stdin)["include"])).lower())' \
<<< "$matrix")"
echo "has-container=$has_container" >> "$GITHUB_OUTPUT"
own_lanes="$(python3 tools/ci/matrix.py own-lanes "${arguments[@]}")"
python3 -m json.tool <<< "$own_lanes"
echo "own-lanes=$own_lanes" >> "$GITHUB_OUTPUT"
Expand All @@ -194,27 +186,10 @@ jobs:
lint_external="$(python3 tools/ci/matrix.py external)"
echo "lint-external=$lint_external" >> "$GITHUB_OUTPUT"

# The container lanes' image, built once per run when the cache does not hold it, and saved
# there before any lane starts: two lanes that missed the cache together would each build it.
container:
name: Container image
needs: plan
if: needs.plan.outputs.has-container == 'true'
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- *superproject
- *superproject-for-library
- uses: ./tools/ci/actions/container

# Every lane waits for the container job, which builds the image a container lane loads, and
# runs when that job succeeded or was not needed.
# Only a container lane obtains its prepared image; other lanes do not wait for it.
lanes:
name: ${{ matrix.name }}
needs: [plan, container]
if: >-
!cancelled() && needs.plan.result == 'success'
&& (needs.container.result == 'success' || needs.container.result == 'skipped')
needs: plan
runs-on: ${{ matrix.os }}
timeout-minutes: 90
strategy:
Expand Down Expand Up @@ -275,8 +250,8 @@ jobs:
cc: ${{ matrix.cc }}
emscripten: ${{ matrix.emsdk }}

# The image a container lane runs b2 in (its entry's container), which the container job
# built and cached, restored from the cache, so that the lane builds none.
# Only a container lane obtains the separately prepared immutable image.
# No ordinary lane builds images or waits for an image-building job.
- if: matrix.container
uses: ./tools/ci/actions/container

Expand Down
143 changes: 143 additions & 0 deletions .github/workflows/prepare-environments.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# Copyright (c) 2026 WebCpp.org
#
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at
# https://www.boost.org/LICENSE_1_0.txt)

# Invoked explicitly through CI's prepare-environment input. Normal pull requests
# never publish packages or build images. Verified output is promoted in a source PR.
name: Prepare CI environments

on:
workflow_call:
workflow_dispatch:

permissions:
contents: read

defaults:
run:
shell: bash

jobs:
publish:
name: Publish ${{ matrix.key }}
if: github.event_name == 'workflow_dispatch' && github.repository == 'webcpporg/webcpp'
runs-on: ubuntu-24.04
timeout-minutes: 60
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix: &environments
include:
- {key: native-linux-x64, tool: '', variant: ''}
- {key: wasi-sdk-linux-x64, tool: wasi-sdk, variant: ''}
- {key: wasmtime-linux-x64, tool: wasmtime, variant: ''}
- {key: wit-bindgen-linux-x64, tool: wit-bindgen, variant: ''}
- {key: wasi-wit-linux-x64, tool: wasi-wit, variant: ''}
- {key: mrdocs-linux-x64, tool: mrdocs, variant: ''}
env:
WEBCPP_PREPARE_ENVIRONMENT: '1'
TOOL: ${{ matrix.tool }}
VARIANT: ${{ matrix.variant }}
KEY: ${{ matrix.key }}
WEBCPP_DOWNLOAD_CACHE: .local/environment-archives
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

# Deliberately no cache restore in the publisher. It verifies upstream bytes afresh.
- name: Fetch and exercise the pinned installer
if: matrix.tool != ''
env:
WEBCPP_CHROME_PRODUCT: ${{ matrix.variant }}
run: bash "tools/ci/actions/$TOOL/install.sh"

- name: Authenticate the publisher
env:
GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: printf '%s' "$GHCR_TOKEN" | docker login ghcr.io --username "$GITHUB_ACTOR" --password-stdin

- name: Publish candidate
run: >-
python3 tools/ci/environment.py publish --tool "$TOOL" --variant "$VARIANT"
--cache "$WEBCPP_DOWNLOAD_CACHE" --out ".local/environment-candidates/$KEY.json"

- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: candidate-${{ matrix.key }}
path: .local/environment-candidates/${{ matrix.key }}.json
if-no-files-found: error
retention-days: 30

- name: Remove registry credentials
if: always()
run: docker logout ghcr.io

# These fresh runners have no publishing credentials. GHCR must be public before
# this succeeds; linking a package to a public repository does not make it public.
verify:
name: Verify ${{ matrix.key }} anonymously
needs: publish
runs-on: ubuntu-24.04
timeout-minutes: 30
strategy:
fail-fast: false
matrix: *environments
env:
TOOL: ${{ matrix.tool }}
VARIANT: ${{ matrix.variant }}
KEY: ${{ matrix.key }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: candidate-${{ matrix.key }}
path: .local/environment-candidates

- name: Verify anonymous pull and offline installation
run: >-
python3 tools/ci/environment.py verify --tool "$TOOL" --variant "$VARIANT"
--cache "$RUNNER_TEMP/verified-archives"
--candidate ".local/environment-candidates/$KEY.json"

- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: verified-${{ matrix.key }}
path: .local/environment-candidates/${{ matrix.key }}.json
if-no-files-found: error
retention-days: 30

manifest:
name: Assemble verified environment pins
needs: verify
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
pattern: verified-*
path: .local/environment-candidates
merge-multiple: true

- name: Assemble pins for review
run: >-
python3 tools/ci/environment.py merge --directory .local/environment-candidates
--out .local/prepared/environments.json

- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: ci-environments
path: .local/prepared/environments.json
if-no-files-found: error
retention-days: 30
77 changes: 58 additions & 19 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1516,11 +1516,6 @@ jobs:
`--library` it says whether any library of `libs/` needs them: the plan's
output `lint-external`, on which the lint job, which analyses every
library, installs them.
- **container:** when the plan has a container lane (its output
`has-container`), the `container` action on ubuntu-24.04, which builds
the container lanes' image when the cache does not hold it and saves it
there, once per run; every lane's job waits for it (`needs: [plan,
container]`), and runs when it succeeded or was skipped.
- **lanes,** one job each, which run `matrix.py lane <entry>`: it registers
the lane's toolset in `.local/user-config.jam` with its version, prints the
lane command and runs it, and the job uploads `<lane>.xml`:
Expand Down Expand Up @@ -1568,13 +1563,13 @@ jobs:
produced incompatible OpenSSL package versions; the image keeps all packages
on the same snapshot. Consumer OpenSSL is now built from the pinned sources.
Ubuntu keeps no snapshot of `ports.ubuntu.com`, so the image builds for
x86-64 alone (measured: apt 2.8.3 refuses arm64's sources). It is tagged
`webcpp-lane:<the first 16 hex digits of the Dockerfile's SHA-256>`. The
`container` job, which every lane waits for, runs the `container` action
once per run, which builds it when the cache does not hold it and saves it
there under that digest; each container lane's job runs the action too,
which then loads it, and `matrix.py lane` builds it only when no image of
that tag is there. Then it runs b2 by its path, `docker run --rm --network
x86-64 alone (measured: apt 2.8.3 refuses arm64's sources).
`tools/ci/environments.json` pins the public GHCR image by its full digest
and binds it to the Dockerfile recipe. The container action pulls that
digest; a missing or stale pin fails with preparation instructions. It
never runs apt or builds an image during an ordinary lane. Every lane
depends only on the plan, so an unavailable image blocks its two consumers
while the other configurations continue. Then it runs b2 by its path, `docker run --rm --network
none`, as the runner's user, with the superproject and b2's prefix, where
the Boost action installs Boost's headers too, mounted at their own paths,
and the variables of the external libraries passed on; the XML is the
Expand Down Expand Up @@ -1807,12 +1802,53 @@ wrapper each quoted as one word of Jam.
isolated profile trust store. Test CAs are installed only in disposable
profiles; no host trust store or certificate-validation bypass is used.
The drivers disable background networking and operate against local fixtures.
- `container` gives a job the container lanes' image (above): built from
`tools/ci/container/Dockerfile` when the cache does not hold it, saved
there under the Dockerfile's digest, and loaded from there otherwise.
- `tools/ci/download.sh <url> <sha256> <file>` downloads each pinned file,
and leaves no file and exits 1 when the download fails or the digest
differs.
- `container` gives a job the checked immutable image above. Registry access
happens before the lane; the test container still has `--network none`.
- `tool-archives` restores the SHA-256 addressed archives for wasi-sdk,
Wasmtime, wit-bindgen, WASI WIT, MrDocs and Chrome. The installer still runs
on every job, preserving its version checks and environment exports.
Cache service failures do not fail a job: a miss uses the prepared bundle,
and a failed save leaves the validated installation usable.
Linux-X64 cold caches for the five open-source tools come from the prepared
public OCI bundles. The bundle is copied from a stopped container and every
file is verified before publication in the local cache. Normal installations
of those tools require verified cache entries and never fall back to upstream.
Other supported hosts keep their checked upstream downloads. Chrome uses its
official download and the same verified cache, without public redistribution
of its binaries: the upstream maintainer distinguishes the binary terms from
the repository license in
[issue 21](https://github.com/GoogleChromeLabs/chrome-for-testing/issues/21).
- `tools/ci/download.sh <url> <sha256> <file>` verifies downloaded or cached
bytes, publishes complete files atomically, and leaves no output after failure.
`WEBCPP_DOWNLOAD_CACHE` selects a content-addressed cache;
`WEBCPP_DOWNLOAD_OFFLINE=1` forbids curl on a missing or corrupt entry.
Connection, transfer and retry windows are bounded. No test verdict is cached.

**Preparing and updating environments.** An owner explicitly dispatches CI
with `prepare-environment=true` at the reviewed source commit. The preparation
workflow builds the native image from the dated Ubuntu snapshot and downloads
the pinned tool archives afresh. Only its publisher has `packages: write`.
The package `ghcr.io/webcpporg/ci-environment` must be made public once after
initial creation; a public repository does not imply public package visibility.
Separate runners prove anonymous digest pulls, offline tool installation and
native C++20 compilation before producing the `ci-environments` artifact.
Download that artifact's generated `environments.json` into `tools/ci/`, review
and commit it with the recipe changes, then run the complete normal CI. Do not
edit generated digests or merge a recipe without its verified pins. A failed
preparation leaves the previous checked-in environments in use.

```sh
gh workflow run ci.yml --repo webcpporg/webcpp --ref <reviewed-branch> \
-f prepare-environment=true
gh run download <successful-preparation-run> --repo webcpporg/webcpp \
--name ci-environments --dir tools/ci
```

This isolates the covered tools from upstream availability during ordinary CI,
not every dependency. Checkout, the GitHub registry/cache, setup-node and npm,
Emscripten's source fetch and the Rust/Cargo fixture remain prerequisites.
The full lane set, `b2 -a`, fresh XML and missing-result checks remain mandatory.

- `tools/ci/helpers.sh` holds what the actions share, which each
`install.sh` sources beside `download.sh`: `digest`, the SHA-256 of files
one after the other; `mixed`, a path as Windows programs read it;
Expand All @@ -1832,7 +1868,10 @@ unpinned, and an emcc that is not 6.0.11; the emsdk action's node wrapper,
`EM_CACHE`, warmed cache and system libraries; libsecp256k1's pinned archive,
compiler settings, install prefixes, exports, cache key and Windows runtime;
the chrome action's shell and its `--no-sandbox` wrapper; and the container
image, built and saved once, then loaded. Their refusal tests cover bad hashes
image, pulled by an immutable digest without a build fallback.
`tools/ci/environment_test.py` checks recipe identity, archive restoration and
publication boundaries; `tools/ci/download_cache_test.py` checks offline reuse,
corruption, interrupted transfers and atomic output. Their refusal tests cover bad hashes
and unsupported runners. Source-provider tests live in
`tools/openssl/build_test.py`, `tools/test/openssl_test.py` and
`tools/test/libdatachannel_test.py`: they cover source pins, staged content,
Expand Down
15 changes: 15 additions & 0 deletions CODING-GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -1384,6 +1384,21 @@ site's own decisions follow in the next sections.
there, which every library's tests hold and trystero's guarantee 6 rests on;
the snapshot makes one Dockerfile one set of packages.
Source: `AGENTS.md` (webcpp).
- **CI preparation is explicit and separate from ordinary pull-request tests.**
A trusted dispatch publishes native and Linux-X64 tool images, then separate
jobs verify anonymous digest pulls and smoke checks. Reviewed generated pins
bind the images to their recipes. Ordinary jobs neither build missing images
nor run apt; only their two container consumers need the native image.
The full lane set and report still fail on missing test results.
- **Tool caches hold verified input archives, never test verdicts.** Each cache
read verifies SHA-256 and each write is atomic. Linux-X64 wasi-sdk, Wasmtime,
wit-bindgen, WASI WIT and MrDocs cold caches use prepared public bundles and
installation stays offline. Other hosts and Chrome retain checked upstream
downloads with bounded retries. Chrome binaries are not republished as public
packages; their terms differ from the CfT repository's license. Every original
installer still runs, so PATH, environment exports and version checks remain.
Source: `tools/ci/environment.py`, `tools/ci/download.sh`,
`.github/workflows/prepare-environments.yml`, `AGENTS.md` (webcpp).
- **The native lanes are GCC 14 and 15, Clang 18 and 22 on libstdc++, Apple
Clang and MSVC 14.3 and 14.5, beside one lane each for emscripten, wasip2
and wasip3.** The Clang lanes on libstdc++ stay because a regression of
Expand Down
2 changes: 2 additions & 0 deletions doc/releases/0.1.0.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ None.
[#webcpp-0-1-0-tools-and-build]
== Tools and build

* Changed CI to consume verified prepared environments without rebuilding images in PR jobs.
* Added verified archive caches and isolated container availability from unrelated CI lanes.
* Fixed parallel builds truncating OpenSSL headers while compilers read them.
* Fixed driven-test execution and descendant cleanup on Windows.
* Fixed driven-test executable reuse for Windows and WASI builds.
Expand Down
8 changes: 4 additions & 4 deletions tools/ci/actions/chrome/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ runs:
using: composite
steps:
- name: Chrome for Testing 155.0.8059.39
shell: bash
env:
WEBCPP_CHROME_PRODUCT: ${{ inputs.product }}
run: bash tools/ci/actions/chrome/install.sh
uses: ./tools/ci/actions/tool-archives
with:
tool: chrome
variant: ${{ inputs.product }}
Loading
Loading