From a2ea9d944ba6fe2537ac0b3aed6123da00271ed8 Mon Sep 17 00:00:00 2001 From: Kinflou Date: Mon, 16 Nov 2026 02:53:10 +0800 Subject: [PATCH 1/6] Add ci-flatpak: Flatpak, bubblewrap and Flathub's VSCodium at pinned commits --- .github/workflows/build.yml | 62 ++++++++++++++++++++++++++++----- images/Dockerfile | 59 ++++++++++++++++++++++++++++++- images/flatpak-install.sh | 44 +++++++++++++++++++++++ images/flatpak-sandbox-check.sh | 38 ++++++++++++++++++++ images/smoke.sh | 34 +++++++++++++++--- 5 files changed, 223 insertions(+), 14 deletions(-) create mode 100755 images/flatpak-install.sh create mode 100755 images/flatpak-sandbox-check.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 630d356..8896bbf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,11 +1,13 @@ name: build -# Four images (bench, fuzz, wasm, tools: images/Dockerfile, one target each), -# each for both architectures. Pull requests build and smoke-test them and run -# core's bench in ci-bench; they never push. Pushes to main and manual runs on -# main also publish ghcr.io/comlineproject/ci-{bench,fuzz,wasm,tools}, with a -# build provenance attestation, and then run core's bench in the published -# ci-bench as a real `container:` job. +# Five images (bench, fuzz, wasm, tools, flatpak: images/Dockerfile, one target +# each), each for both architectures except ci-flatpak (amd64 only: Flathub's +# VSCodium). Pull requests build and smoke-test them, run core's bench in +# ci-bench and the sandbox check in ci-flatpak; they never push. Pushes to main +# and manual runs on main also publish +# ghcr.io/comlineproject/ci-{bench,fuzz,wasm,tools,flatpak}, with a build +# provenance attestation, and then run core's bench in the published ci-bench +# and the sandbox check in the published ci-flatpak as real `container:` jobs. # # The images are reproducible: the same inputs give the same digest (the # "Reproducible builds" section of images/versions.md). A pull request proves it @@ -47,8 +49,12 @@ jobs: strategy: fail-fast: false matrix: - image: [bench, fuzz, wasm, tools] + image: [bench, fuzz, wasm, tools, flatpak] arch: [amd64, arm64] + exclude: + # Flathub's VSCodium is built here for x86_64 only. + - image: flatpak + arch: arm64 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -73,6 +79,11 @@ jobs: run: docker run --rm --network none -v "$PWD/images/smoke.sh:/smoke.sh:ro" ci-${{ matrix.image }}:test bash /smoke.sh ${{ matrix.image }} - name: Smoke test (uid 1001) run: docker run --rm --network none --user 1001:1001 -e HOME=/tmp -v "$PWD/images/smoke.sh:/smoke.sh:ro" ci-${{ matrix.image }}:test bash /smoke.sh ${{ matrix.image }} + # Flatpak's sandbox needs more than the smoke test's container gives: + # `--privileged`, which is also what a job's `container:` options say. + - name: Sandbox check (privileged) + if: matrix.image == 'flatpak' + run: docker run --rm --privileged --network none -v "$PWD/images/flatpak-sandbox-check.sh:/check.sh:ro" ci-flatpak:test bash /check.sh # The same image again as an OCI archive (from the build cache, so it is # quick): the layers' sizes there are what a pull transfers, and its # manifest digest is what the registry will hold. @@ -170,8 +181,12 @@ jobs: strategy: fail-fast: false matrix: - image: [bench, fuzz, wasm, tools] + image: [bench, fuzz, wasm, tools, flatpak] arch: [amd64, arm64] + exclude: + # Flathub's VSCodium is built here for x86_64 only. + - image: flatpak + arch: arm64 env: IMAGE: ghcr.io/comlineproject/ci-${{ matrix.image }} steps: @@ -206,6 +221,11 @@ jobs: run: | docker pull "$IMAGE@$DIGEST" docker run --rm --network none -v "$PWD/images/smoke.sh:/smoke.sh:ro" "$IMAGE@$DIGEST" bash /smoke.sh ${{ matrix.image }} + - name: Sandbox check the pushed image (privileged) + if: matrix.image == 'flatpak' + env: + DIGEST: ${{ steps.build.outputs.digest }} + run: docker run --rm --privileged --network none -v "$PWD/images/flatpak-sandbox-check.sh:/check.sh:ro" "$IMAGE@$DIGEST" bash /check.sh - name: Record the digest env: DIGEST: ${{ steps.build.outputs.digest }} @@ -236,7 +256,7 @@ jobs: strategy: fail-fast: false matrix: - image: [bench, fuzz, wasm, tools] + image: [bench, fuzz, wasm, tools, flatpak] env: IMAGE: ghcr.io/comlineproject/ci-${{ matrix.image }} steps: @@ -370,3 +390,27 @@ jobs: - name: Bench working-directory: core-src run: sh "$GITHUB_WORKSPACE/images/bench-check.sh" + + # The published ci-flatpak as a real `container:` job: the way a consuming + # repository runs its sandbox tests. --privileged, because bubblewrap makes + # namespaces and mounts /proc. + flatpak-container: + name: sandbox in the published ci-flatpak + needs: merge + runs-on: ubuntu-24.04 + timeout-minutes: 30 + permissions: + contents: read + packages: read + container: + image: ghcr.io/comlineproject/ci-flatpak:sha-${{ github.sha }} + credentials: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + options: --privileged + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: Sandbox check + run: bash images/flatpak-sandbox-check.sh diff --git a/images/Dockerfile b/images/Dockerfile index f4892d5..8df96ee 100644 --- a/images/Dockerfile +++ b/images/Dockerfile @@ -6,10 +6,11 @@ # fuzz Rust nightly, cargo-fuzz, gh # wasm Rust stable + wasm32 (browser and WASI), wasm-bindgen, wasm-pack, binaryen # tools Rust stable + musl, cue, cbindgen, musl-tools, make, jq +# flatpak Flatpak, bubblewrap, a session bus, and Flathub's VSCodium (amd64 only) # # docker build --target bench images # -# All four start from the `base` stage: Debian 13 (trixie) slim, by digest, with +# All start from the `base` stage: Debian 13 (trixie) slim, by digest, with # apt pointed at a dated snapshot of the archive. images/versions.md says what # each version is for. Every downloaded binary is checked against the SHA-256 # hash below, per architecture, before it is used; a version bump changes the @@ -49,6 +50,15 @@ ARG GH_VERSION=2.103.3 ARG GH_SHA256_AMD64=4c806978ffce1cec70853302a56d70ac6da4f19bae7adca4e1a8ab00633dd91d ARG GH_SHA256_ARM64=ee32df2323c8847f5fac6cb6b4b69ca75828e9329a8f22f677021f7b3306ce63 +# The flatpak image: Flathub's VSCodium and its runtime, by exact commit (the +# Flathub history keeps them). Bump together, in step with what the consumers' +# e2e should run on: images/versions.md says how to find the commits. +ARG FLATHUB_REPO_SHA256=3371dd250e61d9e1633630073fefda153cd4426f72f4afa0c3373ae2e8fea03a +ARG VSCODIUM_REF=app/com.vscodium.codium/x86_64/stable +ARG VSCODIUM_COMMIT=b63788f25cee55b738d5aa6df3b864c237bda087ce0ee43e803e5a7b207a25ab +ARG RUNTIME_REF=runtime/org.freedesktop.Sdk/x86_64/26.08 +ARG RUNTIME_COMMIT=a1b744b072d9f55d061e35382547ae80dad8d92abecc1da7dc1818de2daabfd3 + # Built from source (no prebuilt binary for both architectures), --locked. ARG CARGO_FUZZ_VERSION=0.13.2 ARG CBINDGEN_VERSION=0.29.2 @@ -158,6 +168,13 @@ RUN --mount=type=bind,source=fetch.sh,target=/fetch.sh \ chmod 755 /out/* +FROM dl-base AS dl-flathub +ARG FLATHUB_REPO_SHA256 +RUN --mount=type=bind,source=fetch.sh,target=/fetch.sh \ + set -eu; mkdir -p /out; \ + sh /fetch.sh "https://dl.flathub.org/repo/flathub.flatpakrepo" "$FLATHUB_REPO_SHA256" /out/flathub.flatpakrepo + + # --------------------------------------------------------------------------- # rust-base: base plus a C toolchain (rustc links with cc, build scripts and # cargo-fuzz's libFuzzer build need it). The toolchain itself is installed per @@ -265,3 +282,43 @@ COPY --from=dl-cue /out/ /usr/local/bin/ ENV CI_RUST_STABLE=${RUST_STABLE} LABEL org.opencontainers.image.source="https://github.com/ComlineProject/ci-images" \ org.opencontainers.image.description="ComlineProject CI: Rust stable with musl, cue and cbindgen (see images/versions.md)" + + +# --------------------------------------------------------------------------- +# flatpak: the sandbox tests of the VSCodium extension (comline-vscode). Flatpak +# with bubblewrap and xdg-dbus-proxy, a session bus (`dbus-run-session`), procps +# (`pgrep`, which the tests use on the "host"), and Flathub's com.vscodium.codium +# with its runtime as a system installation, at the commits above. Flathub's +# VSCodium is x86_64, so this image is amd64 only. +# +# Run its container with `--privileged`: bubblewrap needs to create namespaces +# and mount /proc, which Docker's default seccomp and masked paths forbid. +# Root is the default user, as for every job container: the workspace is +# mounted from the runner, and flatpak runs as root without a helper. +# +# dbus-run-session -- flatpak run --command=/app/share/codium/com.vscodium.codium \ +# --env=ELECTRON_RUN_AS_NODE=1 com.vscodium.codium script.js +FROM base AS flatpak +ARG TARGETARCH +ARG VSCODIUM_REF +ARG VSCODIUM_COMMIT +ARG RUNTIME_REF +ARG RUNTIME_COMMIT +# ostree: to pull the pinned commits (flatpak itself cannot install by commit). +# The machine id apt's postinst writes differs in every build, so it is removed: +# the first dbus-daemon that needs one makes it. +RUN --mount=type=bind,source=apt-install.sh,target=/apt-install.sh \ + set -eu; [ "$TARGETARCH" = amd64 ] || { echo "ci-flatpak is amd64 only" >&2; exit 1; }; \ + sh /apt-install.sh flatpak bubblewrap xdg-dbus-proxy dbus-daemon procps ostree; \ + rm -f /etc/machine-id /var/lib/dbus/machine-id +RUN --mount=type=bind,from=dl-flathub,source=/out,target=/dl \ + --mount=type=bind,source=flatpak-install.sh,target=/flatpak-install.sh \ + sh /flatpak-install.sh +# flatpak wants a runtime directory, which a container has no login session to +# make. +RUN mkdir -p /run/user/0 && chmod 700 /run/user/0 +ENV XDG_RUNTIME_DIR=/run/user/0 +LABEL org.opencontainers.image.source="https://github.com/ComlineProject/ci-images" \ + org.opencontainers.image.description="ComlineProject CI: Flatpak, bubblewrap, a session bus and Flathub's VSCodium, for the sandbox tests (see images/versions.md)" \ + org.comlineproject.ci-flatpak.vscodium-commit="${VSCODIUM_COMMIT}" \ + org.comlineproject.ci-flatpak.runtime-commit="${RUNTIME_COMMIT}" diff --git a/images/flatpak-install.sh b/images/flatpak-install.sh new file mode 100755 index 0000000..7873e55 --- /dev/null +++ b/images/flatpak-install.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# flatpak-install.sh: the Flatpak half of the ci-flatpak image. Run at build +# time, as root, with the Flathub remote file at /dl/flathub.flatpakrepo (hash- +# checked) and the ARGs of the Dockerfile in the environment: +# +# VSCODIUM_REF, VSCODIUM_COMMIT the app, and the exact build of it +# RUNTIME_REF, RUNTIME_COMMIT its runtime, and the exact build of it +# +# Both are pulled by commit (`ostree pull REMOTE REF@COMMIT`, signature-checked +# against Flathub's key like any pull) and then installed from that local copy, +# so the image holds what the ARGs say whatever Flathub's current build is. A +# SYSTEM installation (/var/lib/flatpak), so every uid sees it and nothing +# depends on a home directory. No dependencies or related extensions (the base +# app is part of the app's files already; GL, locale and codecs are for windows +# the image never opens). What varies from one build to the next (caches, +# summaries, appstream data) is removed: see "Reproducible builds" in +# images/versions.md. +set -eu + +: "${VSCODIUM_REF:?}" "${VSCODIUM_COMMIT:?}" "${RUNTIME_REF:?}" "${RUNTIME_COMMIT:?}" +repo=/var/lib/flatpak/repo + +flatpak remote-add --system flathub /dl/flathub.flatpakrepo + +pull_and_install() { + ref=$1 commit=$2 + ostree --repo="$repo" pull flathub "$ref@$commit" + flatpak install --system --noninteractive --assumeyes --no-pull --no-deps --no-related flathub "$ref" + have=$(flatpak info --system --show-commit "${ref#*/}") + [ "$have" = "$commit" ] || { echo "installed $ref is $have, not $commit" >&2; exit 1; } +} +pull_and_install "$RUNTIME_REF" "$RUNTIME_COMMIT" +pull_and_install "$VSCODIUM_REF" "$VSCODIUM_COMMIT" + +flatpak list --system --columns=ref,commit,installation + +# What a job logs, and what the smoke test compares to the labels. +mkdir -p /etc/ci-flatpak +printf '%s\n' "$VSCODIUM_COMMIT" > /etc/ci-flatpak/vscodium-commit +printf '%s\n' "$RUNTIME_COMMIT" > /etc/ci-flatpak/runtime-commit + +# Not part of the installation, and not the same twice: ostree's cache of the +# remote's summary and its temporary files, flatpak's lock files. +rm -rf "$repo"/tmp/* "$repo"/.lock /var/lib/flatpak/.changed /var/tmp/flatpak-cache-* 2> /dev/null || true diff --git a/images/flatpak-sandbox-check.sh b/images/flatpak-sandbox-check.sh new file mode 100755 index 0000000..efc33c0 --- /dev/null +++ b/images/flatpak-sandbox-check.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +# Flatpak's sandbox, for real, in the ci-flatpak image: what its consumers do. +# Needs the container started with `--privileged` (bubblewrap makes namespaces +# and mounts /proc), as root: +# docker run --rm --privileged -v "$PWD/images/flatpak-sandbox-check.sh:/check.sh:ro" IMAGE bash /check.sh +# It runs VSCodium's Electron as plain Node inside the sandbox, through a +# session bus (`flatpak-spawn --host` talks to the session helper over it), and +# has the sandbox start a program on the "host" (here, the container). +set -euo pipefail + +app=com.vscodium.codium +electron=/app/share/codium/com.vscodium.codium +# The runtime directory the image's ENV names; a job may have another HOME. +export XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR:-/run/user/$(id -u)} +mkdir -p "$XDG_RUNTIME_DIR" +chmod 700 "$XDG_RUNTIME_DIR" + +echo "VSCodium commit: $(cat /etc/ci-flatpak/vscodium-commit)" +echo "runtime commit: $(cat /etc/ci-flatpak/runtime-commit)" +echo "uid $(id -u), XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR" + +echo "+ Electron, as Node, in the sandbox" +version=$(dbus-run-session -- flatpak run --command="$electron" --env=ELECTRON_RUN_AS_NODE=1 "$app" \ + -e 'console.log(process.versions.electron)') +echo "electron $version" +[[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]] || { echo "FAILED: no Electron version: $version" >&2; exit 1; } + +echo "+ the sandbox is not the container, and reaches it through flatpak-spawn --host" +marker=$(mktemp /usr/local/bin/sandbox-check.XXXXXX) +trap 'rm -f "$marker"' EXIT +dbus-run-session -- flatpak run --command=sh "$app" -c ' + set -eu + echo "inside the sandbox: $FLATPAK_ID" + test ! -e "$1" || { echo "FAILED: $1 is visible in the sandbox" >&2; exit 1; } + flatpak-spawn --host test -e "$1" + echo "the host sees it" +' sh "$marker" +echo "sandbox check passed" diff --git a/images/smoke.sh b/images/smoke.sh index 09d949b..576d1c2 100755 --- a/images/smoke.sh +++ b/images/smoke.sh @@ -1,10 +1,10 @@ #!/usr/bin/env bash # Smoke test for the CI images: run inside one, with no network. Prints each # tool's version and fails if one is missing or does not work. -# docker run --rm --network none -v "$PWD/images/smoke.sh:/smoke.sh:ro" IMAGE bash /smoke.sh bench|fuzz|wasm|tools +# docker run --rm --network none -v "$PWD/images/smoke.sh:/smoke.sh:ro" IMAGE bash /smoke.sh bench|fuzz|wasm|tools|flatpak set -euo pipefail -mode=${1:?usage: smoke.sh bench|fuzz|wasm|tools} +mode=${1:?usage: smoke.sh bench|fuzz|wasm|tools|flatpak} host=$(uname -m)-unknown-linux-gnu musl=$(uname -m)-unknown-linux-musl @@ -28,13 +28,16 @@ builds() { echo "== Base" run git --version run zstd --version -run cc --version test -s /etc/ssl/certs/ca-certificates.crt || fail "no CA certificates" # The apt sources are the dated snapshot, not today's archive. grep -q '^URIs: mirror+file:' /etc/apt/sources.list.d/debian.sources || fail "apt is not pointed at the snapshot" grep -q 'snapshot.debian.org/archive/debian/[0-9]\{8\}T[0-9]\{6\}Z/' /etc/apt/mirrors/debian.txt || fail "no snapshot date in the apt mirrors" cat /etc/apt/mirrors/debian.txt -run rustup show +# The Rust images have a C toolchain and rustup; the flatpak image has neither. +if [[ "$mode" != flatpak ]]; then + run cc --version + run rustup show +fi case "$mode" in bench) @@ -99,6 +102,29 @@ tools) absent valgrind cargo-fuzz wasm-pack gh builds "" "$musl" ;; +flatpak) + echo "== flatpak" + run flatpak --version + run bwrap --version + run xdg-dbus-proxy --version + run dbus-run-session --version + run pgrep --version + # The app and its runtime are the commits the image says it has, as any uid. + app=$(cat /etc/ci-flatpak/vscodium-commit) + runtime=$(cat /etc/ci-flatpak/runtime-commit) + [[ "$(flatpak info --system --show-commit com.vscodium.codium)" == "$app" ]] || fail "installed VSCodium is not $app" + installed_runtime=$(flatpak list --system --runtime --columns=application,commit | awk '$1 == "org.freedesktop.Sdk" { print $2 }') + [[ "$installed_runtime" == "$runtime"* ]] || fail "installed runtime is $installed_runtime, not $runtime" + run flatpak list --system --columns=ref,commit,installation + # The two permissions the extension's host mode relies on, as the installed + # app has them: if Flathub's build of a pinned commit lost either, it shows here. + permissions=$(flatpak info --system --show-permissions com.vscodium.codium) + grep -E '^filesystems=.*\bhost\b' <<< "$permissions" || fail "VSCodium has no --filesystem=host" + grep -E '^org\.freedesktop\.Flatpak=talk' <<< "$permissions" || fail "VSCodium cannot talk to org.freedesktop.Flatpak" + test -x /var/lib/flatpak/app/com.vscodium.codium/x86_64/stable/active/files/share/codium/com.vscodium.codium || fail "no Electron binary in the app" + absent rustc cargo gh node python3 curl + # The sandbox itself needs `docker run --privileged`: images/flatpak-sandbox-check.sh. + ;; *) fail "unknown mode: $mode" ;; From 03eb0d9321bb588fd46eaf0fdd1c59d069451316 Mon Sep 17 00:00:00 2001 From: Kinflou Date: Mon, 16 Nov 2026 02:55:49 +0800 Subject: [PATCH 2/6] ci-flatpak: install the latest, then update to the pinned commit (Flathub refuses the ostree client) --- images/Dockerfile | 2 +- images/flatpak-install.sh | 36 +++++++++++++++++++++--------------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/images/Dockerfile b/images/Dockerfile index 8df96ee..5c1d513 100644 --- a/images/Dockerfile +++ b/images/Dockerfile @@ -304,7 +304,7 @@ ARG VSCODIUM_REF ARG VSCODIUM_COMMIT ARG RUNTIME_REF ARG RUNTIME_COMMIT -# ostree: to pull the pinned commits (flatpak itself cannot install by commit). +# ostree: to prune what the pinned commits leave behind. # The machine id apt's postinst writes differs in every build, so it is removed: # the first dbus-daemon that needs one makes it. RUN --mount=type=bind,source=apt-install.sh,target=/apt-install.sh \ diff --git a/images/flatpak-install.sh b/images/flatpak-install.sh index 7873e55..5e0f58f 100755 --- a/images/flatpak-install.sh +++ b/images/flatpak-install.sh @@ -6,15 +6,17 @@ # VSCODIUM_REF, VSCODIUM_COMMIT the app, and the exact build of it # RUNTIME_REF, RUNTIME_COMMIT its runtime, and the exact build of it # -# Both are pulled by commit (`ostree pull REMOTE REF@COMMIT`, signature-checked -# against Flathub's key like any pull) and then installed from that local copy, -# so the image holds what the ARGs say whatever Flathub's current build is. A -# SYSTEM installation (/var/lib/flatpak), so every uid sees it and nothing -# depends on a home directory. No dependencies or related extensions (the base -# app is part of the app's files already; GL, locale and codecs are for windows -# the image never opens). What varies from one build to the next (caches, -# summaries, appstream data) is removed: see "Reproducible builds" in -# images/versions.md. +# Installed by the latest Flathub has, then moved to the exact commit with +# `flatpak update --commit` (Flathub keeps the history of a ref), and the +# commits nobody refers to any more are pruned. The commit is what the image +# holds, whatever Flathub's current build is. (ostree's own `pull REF@COMMIT` +# would fetch the commit directly, but Flathub answers 403 to the `ostree` +# client's user agent: only flatpak's is let through.) A SYSTEM installation +# (/var/lib/flatpak), so every uid sees it and nothing depends on a home +# directory. No dependencies or related extensions: the base app is part of the +# app's files already, and GL, locale and codecs are for windows the image never +# opens. What varies from one build to the next (caches, summaries, appstream +# data) is removed: see "Reproducible builds" in images/versions.md. set -eu : "${VSCODIUM_REF:?}" "${VSCODIUM_COMMIT:?}" "${RUNTIME_REF:?}" "${RUNTIME_COMMIT:?}" @@ -22,15 +24,19 @@ repo=/var/lib/flatpak/repo flatpak remote-add --system flathub /dl/flathub.flatpakrepo -pull_and_install() { +install_pinned() { ref=$1 commit=$2 - ostree --repo="$repo" pull flathub "$ref@$commit" - flatpak install --system --noninteractive --assumeyes --no-pull --no-deps --no-related flathub "$ref" - have=$(flatpak info --system --show-commit "${ref#*/}") + flatpak install --system --noninteractive --assumeyes --no-deps --no-related flathub "$ref" + flatpak update --system --noninteractive --assumeyes --no-deps --no-related --commit="$commit" "$ref" + have=$(flatpak info --system --show-commit "$ref") [ "$have" = "$commit" ] || { echo "installed $ref is $have, not $commit" >&2; exit 1; } } -pull_and_install "$RUNTIME_REF" "$RUNTIME_COMMIT" -pull_and_install "$VSCODIUM_REF" "$VSCODIUM_COMMIT" +install_pinned "$RUNTIME_REF" "$RUNTIME_COMMIT" +install_pinned "$VSCODIUM_REF" "$VSCODIUM_COMMIT" + +# The latest builds the installs started from: no ref points at them now. +ostree --repo="$repo" prune --refs-only --depth=0 +ostree --repo="$repo" refs flatpak list --system --columns=ref,commit,installation From 811ab8f003da0d9256deead433bce36867cc5f43 Mon Sep 17 00:00:00 2001 From: Kinflou Date: Mon, 16 Nov 2026 02:55:57 +0800 Subject: [PATCH 3/6] ci-flatpak: refs as NAME/ARCH/BRANCH --- images/flatpak-install.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/images/flatpak-install.sh b/images/flatpak-install.sh index 5e0f58f..d53d7fa 100755 --- a/images/flatpak-install.sh +++ b/images/flatpak-install.sh @@ -26,9 +26,11 @@ flatpak remote-add --system flathub /dl/flathub.flatpakrepo install_pinned() { ref=$1 commit=$2 - flatpak install --system --noninteractive --assumeyes --no-deps --no-related flathub "$ref" - flatpak update --system --noninteractive --assumeyes --no-deps --no-related --commit="$commit" "$ref" - have=$(flatpak info --system --show-commit "$ref") + # NAME/ARCH/BRANCH, which every flatpak command takes. + name=${ref#*/} + flatpak install --system --noninteractive --assumeyes --no-deps --no-related flathub "$name" + flatpak update --system --noninteractive --assumeyes --no-deps --no-related --commit="$commit" "$name" + have=$(flatpak info --system --show-commit "$name") [ "$have" = "$commit" ] || { echo "installed $ref is $have, not $commit" >&2; exit 1; } } install_pinned "$RUNTIME_REF" "$RUNTIME_COMMIT" From 24b41c728a0f2bd7b91cb68709378673af9e4239 Mon Sep 17 00:00:00 2001 From: Kinflou Date: Mon, 16 Nov 2026 02:57:18 +0800 Subject: [PATCH 4/6] ci-flatpak: README and versions --- README.md | 37 +++++++++++++++++++++++++++++-------- images/versions.md | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 73 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 05d27d8..d420f12 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,12 @@ One image per kind of job, each carrying only what those jobs use: | `ghcr.io/comlineproject/ci-fuzz` | the cargo-fuzz jobs | Rust nightly, cargo-fuzz, gh | | `ghcr.io/comlineproject/ci-wasm` | the WebAssembly build | Rust stable with wasm32, wasm-bindgen, wasm-pack, binaryen | | `ghcr.io/comlineproject/ci-tools` | cue, cbindgen and the musl build | Rust stable with musl, cue, cbindgen, musl-tools, make, jq | +| `ghcr.io/comlineproject/ci-flatpak` | the sandbox tests of the VSCodium extension | Flatpak, bubblewrap, xdg-dbus-proxy, a session bus, Flathub's VSCodium and its runtime (amd64 only) | All are Debian 13 (trixie) slim, by digest, with every apt package pinned to -one snapshot.debian.org date, for `linux/amd64` and `linux/arm64`. They all -have git and a C toolchain. [`images/versions.md`](images/versions.md) lists +one snapshot.debian.org date, for `linux/amd64` and `linux/arm64` (`ci-flatpak`: +`linux/amd64` only, as Flathub's VSCodium is built for x86_64 here). The four +Rust images have git and a C toolchain; `ci-flatpak` has git and no compiler. [`images/versions.md`](images/versions.md) lists every version and why it is that one; [`docs/base-choice.md`](docs/base-choice.md) says why Debian. @@ -48,6 +50,20 @@ default seccomp profile refuses. options: --security-opt seccomp=unconfined ``` +The flatpak job's container needs `--privileged`: bubblewrap makes namespaces +and mounts `/proc`, which Docker's default seccomp profile and masked paths +refuse. It runs as root, as every job container does, with `XDG_RUNTIME_DIR` +(`/run/user/0`) set; the job's `dbus-run-session -- flatpak run ...` is its own +session bus. VSCodium is installed for the whole system at an exact Flathub +commit, which `/etc/ci-flatpak/vscodium-commit` (and the image's +`org.comlineproject.ci-flatpak.vscodium-commit` label) holds, so a job can log it. + +```yaml + container: + image: ghcr.io/comlineproject/ci-flatpak@sha256: + options: --privileged +``` + Renovate bumps the digest: the tags (`latest`, `sha-`) exist for it to follow. A bump is a pull request in the consuming repository, so it runs that repository's CI against the new image before it merges. @@ -77,18 +93,23 @@ gh attestation verify oci://ghcr.io/comlineproject/ci-bench@sha256: --ow [`images/Dockerfile`](images/Dockerfile) is one file with a `base` stage and a build target per image (`docker build --target bench images`). -[`build.yml`](.github/workflows/build.yml) builds the four images for both -architectures natively (`ubuntu-24.04` and `ubuntu-24.04-arm`). Every build +[`build.yml`](.github/workflows/build.yml) builds the five images for both +architectures natively (`ubuntu-24.04` and `ubuntu-24.04-arm`; `ci-flatpak` +only on the first). Every build smoke-tests the image ([`images/smoke.sh`](images/smoke.sh), one mode per image: each tool's version, a build for each target, with no network, as root and as -another uid), prints its compressed size, and `ci-bench` runs core's bench at a -fixed commit. Pull requests stop there. Pushes to `main` and manual runs on +another uid), prints its compressed size, `ci-bench` runs core's bench at a +fixed commit, and `ci-flatpak` runs VSCodium's Electron inside Flatpak's +sandbox in a `--privileged` container ([`images/flatpak-sandbox-check.sh`](images/flatpak-sandbox-check.sh)). Pull requests stop there. Pushes to `main` and manual runs on `main` push each architecture by digest, smoke-test what was pushed, join the two into one manifest tagged `sha-` and `latest`, attest it, and run -core's bench in the published `ci-bench` as a real `container:` job. +core's bench in the published `ci-bench` and the sandbox check in the published +`ci-flatpak` as real `container:` jobs. There is no scheduled rebuild: the apt packages are fixed by date, so a rebuild would change nothing. To update them, move `DEBIAN_SNAPSHOT` (and the base digest) in the Dockerfile. To update a tool, change the `ARG` and its hashes in [`images/Dockerfile`](images/Dockerfile), and its row in -[`images/versions.md`](images/versions.md). +[`images/versions.md`](images/versions.md). `ci-flatpak`'s VSCodium and runtime +are bumped the same way, by commit ([`images/versions.md`](images/versions.md#flatpak) +says how to find them). diff --git a/images/versions.md b/images/versions.md index 60ad890..32ec9e2 100644 --- a/images/versions.md +++ b/images/versions.md @@ -12,9 +12,11 @@ specification. Why Debian: [`../docs/base-choice.md`](../docs/base-choice.md). | `ci-fuzz` | the cargo-fuzz jobs (core, runtime) | nightly-2026-11-10, minimal | cargo-fuzz 0.13.2, gh, python3 (the Observatory `report-fuzz` action) | | `ci-wasm` | the WebAssembly build (simulator, playground), core's `ir_only` job | stable 1.99.1, minimal, `wasm32-unknown-unknown`, `wasm32-wasip1` | wasm-bindgen 0.2.127, wasm-pack 0.15.1, binaryen, jq, clang (C sources compiled for wasm32: tree-sitter, psm) | | `ci-tools` | cue, cbindgen and the musl build (runtime, specification) | stable 1.99.1, minimal, the musl target | cue v0.17.1, cbindgen 0.29.2, musl-tools, make, jq | +| `ci-flatpak` | the sandbox tests of the VSCodium extension (comline-vscode's `flatpak.yml`), amd64 only | none | flatpak, bubblewrap, xdg-dbus-proxy, dbus-daemon, procps, ostree; Flathub's `com.vscodium.codium` and its runtime `org.freedesktop.Sdk//26.08` | -All four have, from the base: git, ca-certificates, zstd (for `actions/cache`), -and `build-essential` (rustc links with `cc`). +The four Rust images have, from the base: git, ca-certificates, zstd (for +`actions/cache`), and `build-essential` (rustc links with `cc`). `ci-flatpak` has +the base only (git, ca-certificates, zstd): it builds nothing. ## Base @@ -53,6 +55,46 @@ python3 3.13.5, git 2.47.3. The smoke test prints the rest. | jq | wasm | Debian's | apt (snapshot) | simulator's wasm-bindgen version check. | | gh | bench, fuzz | 2.103.3 | release binary | The fuzz, nightly and CI workflows use `gh issue` and `gh api`, which a job container does not have. | +### Flatpak + +| What | Version | Why | +|---|---|---| +| flatpak, bubblewrap, xdg-dbus-proxy, dbus-daemon, procps | Debian's (the snapshot's) | The sandbox under test is Flatpak's; `dbus-run-session` (dbus-daemon) is the session bus `flatpak-spawn --host` talks to; `pgrep`/`pkill` (procps) are what the tests run on the "host". Debian's flatpak is 1.16, newer than Ubuntu 24.04's 1.14 the VM ran. ostree is only for pruning what an update leaves in the repository. | +| Flathub remote | `flathub.flatpakrepo`, SHA-256 `FLATHUB_REPO_SHA256` | The remote's file carries Flathub's signing key; it is hash-checked like a release binary. | +| `com.vscodium.codium` | `VSCODIUM_COMMIT` (Flathub's build of 2026-11-10) | The real app with the permissions Flathub gives it, as a system installation. An exact commit, so the image says which build the tests ran on, and a new Flathub build is a reviewed change here. Recorded in `/etc/ci-flatpak/vscodium-commit` and an image label. | +| `org.freedesktop.Sdk//26.08` | `RUNTIME_COMMIT` (2026-10-26) | The runtime VSCodium's manifest names (`runtime=org.freedesktop.Sdk/x86_64/26.08`); 659 MB to download, 1.8 GB installed, which is most of the image. Recorded in `/etc/ci-flatpak/runtime-commit`. | + +How the commits are installed (`images/flatpak-install.sh`): Flatpak installs the +ref as Flathub has it now, `flatpak update --commit` moves it to the pinned commit +(Flathub keeps the history of a ref, so this is a downgrade the day a newer build +exists), and `ostree prune` drops the objects only the newer build had. ostree's +own `pull REF@COMMIT` would fetch it directly, but Flathub's CDN answers HTTP 403 +to the `ostree` client's user agent (`libostree/...`) and lets flatpak's through. +No dependencies and no related refs are installed: no GL, locale or codec +extensions, because nothing opens a window. + +To bump them, find the commits: + +```sh +flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo +flatpak remote-info --user flathub com.vscodium.codium # Commit: +flatpak remote-info --user flathub runtime/org.freedesktop.Sdk/x86_64/26.08 # Commit: (the runtime the app names) +``` + +and change `VSCODIUM_COMMIT` and `RUNTIME_COMMIT` (and `RUNTIME_REF` when the app +moves to a new runtime branch) in the Dockerfile. `flatpak remote-info --log` +lists the older commits of a ref. The smoke test fails if the app lost +`--filesystem=host` or `--talk-name=org.freedesktop.Flatpak`, the two permissions +comline-vscode's host mode relies on. + +Why root and `--privileged`: a job container runs as root with the runner's +workspace mounted, and Flatpak needs no helper process as root. bubblewrap +creates namespaces and mounts a fresh `/proc` in the sandbox, which Docker's +default seccomp profile and masked `/proc` paths refuse, so the container is +started with `--privileged`. `images/flatpak-sandbox-check.sh` proves the whole +chain in the image's own build: Electron as Node in the sandbox, and the sandbox +starting a program on the "host" (the container) through `flatpak-spawn --host`. + Not in any image: Node (GitHub mounts its own into a job container for actions; a job that runs `node` in a step uses `actions/setup-node`), curl and unzip (only a build stage has curl), `pkg-config`, xz-utils. From 1cf93837f4903933ebd55d26935c3a8306941f94 Mon Sep 17 00:00:00 2001 From: Kinflou Date: Mon, 16 Nov 2026 02:59:42 +0800 Subject: [PATCH 5/6] TEMP: pin the previous runtime commit to exercise the downgrade path; fix list columns --- images/Dockerfile | 2 +- images/flatpak-install.sh | 2 +- images/smoke.sh | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/images/Dockerfile b/images/Dockerfile index 5c1d513..858d257 100644 --- a/images/Dockerfile +++ b/images/Dockerfile @@ -57,7 +57,7 @@ ARG FLATHUB_REPO_SHA256=3371dd250e61d9e1633630073fefda153cd4426f72f4afa0c3373ae2 ARG VSCODIUM_REF=app/com.vscodium.codium/x86_64/stable ARG VSCODIUM_COMMIT=b63788f25cee55b738d5aa6df3b864c237bda087ce0ee43e803e5a7b207a25ab ARG RUNTIME_REF=runtime/org.freedesktop.Sdk/x86_64/26.08 -ARG RUNTIME_COMMIT=a1b744b072d9f55d061e35382547ae80dad8d92abecc1da7dc1818de2daabfd3 +ARG RUNTIME_COMMIT=3311c13c67b602315c39cf5310de129dd3460d04b6c8cf5be1b2cbc42c51abd7 # Built from source (no prebuilt binary for both architectures), --locked. ARG CARGO_FUZZ_VERSION=0.13.2 diff --git a/images/flatpak-install.sh b/images/flatpak-install.sh index d53d7fa..e7dce74 100755 --- a/images/flatpak-install.sh +++ b/images/flatpak-install.sh @@ -40,7 +40,7 @@ install_pinned "$VSCODIUM_REF" "$VSCODIUM_COMMIT" ostree --repo="$repo" prune --refs-only --depth=0 ostree --repo="$repo" refs -flatpak list --system --columns=ref,commit,installation +flatpak list --system --columns=ref,active,origin,installation # What a job logs, and what the smoke test compares to the labels. mkdir -p /etc/ci-flatpak diff --git a/images/smoke.sh b/images/smoke.sh index 576d1c2..6872b87 100755 --- a/images/smoke.sh +++ b/images/smoke.sh @@ -113,9 +113,9 @@ flatpak) app=$(cat /etc/ci-flatpak/vscodium-commit) runtime=$(cat /etc/ci-flatpak/runtime-commit) [[ "$(flatpak info --system --show-commit com.vscodium.codium)" == "$app" ]] || fail "installed VSCodium is not $app" - installed_runtime=$(flatpak list --system --runtime --columns=application,commit | awk '$1 == "org.freedesktop.Sdk" { print $2 }') - [[ "$installed_runtime" == "$runtime"* ]] || fail "installed runtime is $installed_runtime, not $runtime" - run flatpak list --system --columns=ref,commit,installation + installed_runtime=$(flatpak info --system --show-commit org.freedesktop.Sdk) + [[ "$installed_runtime" == "$runtime" ]] || fail "installed runtime is $installed_runtime, not $runtime" + run flatpak list --system --columns=ref,active,origin,installation # The two permissions the extension's host mode relies on, as the installed # app has them: if Flathub's build of a pinned commit lost either, it shows here. permissions=$(flatpak info --system --show-permissions com.vscodium.codium) From 2f51d65d68ebc6b73e32ed05ddaedef64c197b20 Mon Sep 17 00:00:00 2001 From: Kinflou Date: Mon, 16 Nov 2026 03:16:14 +0800 Subject: [PATCH 6/6] ci-flatpak: back to the current runtime commit; size --- images/Dockerfile | 2 +- images/versions.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/images/Dockerfile b/images/Dockerfile index 858d257..5c1d513 100644 --- a/images/Dockerfile +++ b/images/Dockerfile @@ -57,7 +57,7 @@ ARG FLATHUB_REPO_SHA256=3371dd250e61d9e1633630073fefda153cd4426f72f4afa0c3373ae2 ARG VSCODIUM_REF=app/com.vscodium.codium/x86_64/stable ARG VSCODIUM_COMMIT=b63788f25cee55b738d5aa6df3b864c237bda087ce0ee43e803e5a7b207a25ab ARG RUNTIME_REF=runtime/org.freedesktop.Sdk/x86_64/26.08 -ARG RUNTIME_COMMIT=3311c13c67b602315c39cf5310de129dd3460d04b6c8cf5be1b2cbc42c51abd7 +ARG RUNTIME_COMMIT=a1b744b072d9f55d061e35382547ae80dad8d92abecc1da7dc1818de2daabfd3 # Built from source (no prebuilt binary for both architectures), --locked. ARG CARGO_FUZZ_VERSION=0.13.2 diff --git a/images/versions.md b/images/versions.md index 32ec9e2..e12c089 100644 --- a/images/versions.md +++ b/images/versions.md @@ -158,5 +158,6 @@ publish run prints the registry's own figure. | `ci-fuzz` | 402.6 MB | 1115 MB | 359.0 MB | 1020 MB | | `ci-wasm` | 442.5 MB | 1253 MB | 400.1 MB | 1161 MB | | `ci-tools` | 467.5 MB | 1354 MB | 402.3 MB | 1183 MB | +| `ci-flatpak` | 941 MB (pull request #8) | 2571 MB | none | none | (For comparison, the ci-rust image was about 2.9 GB uncompressed on amd64.)