Nostro/.forgejo/workflows/flatpak.yaml
Jorijn van der Graaf 3cf9e091a9
build(shell): name Crafter.Graphics at a commit of its master, and answer a compositor's resize with a frame
The app was built against a checkout of Crafter.Graphics given with
--graphics=, because the text-input purposes it asks the input method for
were uncommitted work in one checkout. They are on Crafter.Graphics' master
since a9ce1a0, so project.cpp names the library as a GitProject at that
commit, as it names Crafter.Network and Crafter.DB. --graphics= is gone, and
with it $NOSTRO_GRAPHICS in build-aarch64.sh and the workflow's step that
cloned the branch claude/nostro-app, which the forge never had: neither job
of the workflow could have built the app.

That master also has 89111e0, which the window was not written against. A
size the compositor configures is no longer taken in the configure's
listener. The listener keeps it and fires onFrameOwed, and the next Render()
makes the swapchain again, fires onResize from inside itself, and answers
the configure with that frame's buffer. The window draws on demand, so:

- Shell::Window asks for a frame from onFrameOwed. Without it nothing draws
  the frame that answers the configure, and the window keeps its old size
  until something else changes on it.
- Canvas::Reconcile no longer turns the compositor's sizes into
  Resize(pixels). The library takes the size asked for last, whoever asked,
  so that call took the configured size's place, and with it came back the
  surface a dp larger than configured that 89111e0 had ended
  (Crafter.Graphics #201). It now sizes the window only where the library
  does not: the app's own size (--size, SetSize, --scale); the size that
  comes with a new window (#166), handed over in deferredLogicalWidth, where
  the library's listener keeps every later one; and a scale the display
  changes to by itself (#165), through RebuildSwapchain. The last two reach
  into the library's own state, and go once the library does them.

The text-input API on master is the one the app was written against:
nothing changed there.

Looked at on 2026-11-20 on the made-up system, on a desktop (KWin at a
scale of 1.85), with WAYLAND_DEBUG=1 on the app:

- The accounts at 420x760: the start, and resize:600,800 from --poke, the
  app's own size. Each size reaches the surface once, with the first buffer
  drawn for it.
- The same window given 760x532 by the compositor (a KWin script that sets
  its frameGeometry): the configure is kept, a frame is asked for, and
  set_destination(760, 532), the acknowledgement and the first buffer of
  1406x985 go out together. A temporary probe had that frame's draw list
  reach 1406x985: it is laid out for the new size.
- 421x761, whose pixels at 1.85 are no whole number: it opens as 422x762,
  since the app's own size goes through Resize in pixels. The notes say so.
- --scale 2 --size 360x760, the cards and the pay form filled in from
  --poke, with resize:400,700: the compositor's sizes are passed over.
- The --debug-api build driven with crafter-debug: Window_Resize, Ui_Tap,
  ui.texts and a screenshot.

The two paths that are a phone's, a size in the first configure and a scale
named after the first frames, were tried only with the values put in by
hand in a temporary probe. Nothing was looked at on a phone, and what the
input method is told was not read off the wire: the test window never had
the keyboard.

17 tests pass and the four lint passes report nothing. The app, its
--debug-api build, the fake system, the x86_64 Flatpak bundle and both
aarch64 Flatpaks (build-aarch64.sh) build.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 06:00:54 +01:00

269 lines
14 KiB
YAML

# SPDX-License-Identifier: LGPL-3.0-only
# SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
name: Flatpak
# Nostro's two Flatpaks for aarch64, a phone's architecture: the service with the nostro command
# (net.catcrafts.Nostrod) and the app (net.catcrafts.Nostro). They are built after the tests for a pull request, when
# started by hand, and for a pushed tag X.Y.Z. Only the tag's run publishes: both as the `stable` branch of the
# Catcrafts Flatpak repository (flatpak.catcrafts.net), each with its ref file beside it, and release X.Y.Z on the forge.
#
# A release is a tag: the owner signs it locally and pushes it with the master it releases, and a push without one runs
# nothing. The tag names the version, which NOSTRO_VERSION in project.cpp and the app's metainfo's newest <release>
# have to carry; that entry's description is the release notes (packaging/flatpak/release-version.sh).
#
# Two jobs, by trust, as imsd-messages' workflow has them, which this one follows step for step. `check` builds what is
# no release (a pull request, a run by hand) cold: no host volume, neither the published repository nor its key.
# `publish` builds a pushed tag with the four volumes it mounts: the crafter-build installation every consumer
# repository's publish job on the runner shares (crafter-flatpak-org-system: crafter-build //stable and its runtime),
# Nostro's own build cache (crafter-flatpak-nostro-cache: the aarch64 Sdk, the sysroot and the build directories, kept
# between runs), /var/www/flatpak (the published repository) and /etc/crafter-flatpak (its signing key, which never
# enters the forge): the repository and the key Crafter.Build's workflow publishes with. The shared installation is for
# publish jobs only: a pull request's job runs as root in a privileged container and must never reach it.
#
# What a run needs, none of which this file can bring about:
# - Both jobs run on the privileged runner labelled `flatpak` (bubblewrap needs the privilege). That is the Catcrafts
# organisation's, which serves the organisation's repositories, of which this is one.
# - The repository is public by the time a tag is pushed: the release checks read the forge without a login, and a
# private repository answers them with a 404.
# - The runner's config has to allow the four volumes of `publish`, of which crafter-flatpak-nostro-cache is new.
#
# Crafter.Build's, Crafter.Review's and imsd-messages' workflows publish into the same repository: each holds
# /var/www/flatpak/.publish.lock while it commits and updates the summary, and so does this one.
#
# Written on 2026-11-19 and not run before it was pushed: the first run is its test.
on:
pull_request:
branches: [master]
push:
# Bare semver tags, spelled with globs so it means the same whether the forge reads it as a workflow pattern or as
# a plain glob.
tags: ['[0-9]*.[0-9]*.[0-9]*']
workflow_dispatch:
# Pushes are tags only, so every release run is in one group and queues behind the one before it. A pull request's
# group also holds its number, which only a pull request's event carries, so a new push to it cancels its own outdated
# run and no other.
concurrency:
group: flatpak-${{ github.event_name }}-${{ github.event.pull_request.number }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
APP_ID: net.catcrafts.Nostro
SERVICE_ID: net.catcrafts.Nostrod
ARCH: aarch64
BRANCH: stable
CRAFTER_REF: net.catcrafts.CrafterBuild//stable
REPO_DIR: /srv/flatpak/repo
# A release tag carries a signature Forgejo verifies for this address.
RELEASE_SIGNER: jorijnvdgraaf@catcrafts.net
jobs:
check:
if: github.event_name != 'push'
runs-on: flatpak
timeout-minutes: 210
container:
image: archlinux:latest
steps:
- name: Install tools
# A mirror answering 502 can fail a pacman transaction even with another mirror behind it; a retry starts over.
run: |
retry() { for i in 1 2 3 4 5; do "$@" && return 0; echo "attempt $i of 5 failed: $*" >&2; [ "$i" = 5 ] || sleep 30; done; return 1; }
pacman-key --init
pacman-key --populate archlinux
retry pacman -Sy --noconfirm --needed archlinux-keyring
retry pacman -Syu --noconfirm --needed flatpak ostree appstream binutils curl xz gnupg git nodejs util-linux python jq
git config --global --add safe.directory '*'
- name: crafter-build
# The Crafter.Build Flatpak's stable branch, which moves only with its releases; its Sdk comes from Flathub.
# Flathub's CDN answers 502 now and then, which flatpak reports as a missing runtime: each of these gets five
# tries.
run: |
retry() { for i in 1 2 3 4 5; do "$@" && return 0; echo "attempt $i of 5 failed: $*" >&2; [ "$i" = 5 ] || sleep 30; done; return 1; }
retry flatpak remote-add --if-not-exists catcrafts https://flatpak.catcrafts.net/catcrafts.flatpakrepo
retry flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
retry flatpak install -y --noninteractive catcrafts "$CRAFTER_REF"
retry flatpak update -y --noninteractive
flatpak info "$CRAFTER_REF" | sed -n 's/^ *\(Version\|Commit\|Date\): */crafter-build \1: /p'
- name: Checkout
# No step pushes, so the token is not kept in the checkout.
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Build user
# crafter-build and the scripts run as a user; root installs.
run: |
id build >/dev/null 2>&1 || useradd -m build
chown -R build: "$GITHUB_WORKSPACE" /home/build
- name: Version
run: runuser -u build -- packaging/flatpak/release-version.sh
- name: Tests
# Against the fake bunq and the fake system bus the tests bring: no bank and no system bus is reached.
run: runuser -u build -- flatpak run "$CRAFTER_REF" test --banks=bunq
- name: Lint
# The library, the command and the tests, which the step before built. The headers are named through the
# environment until Crafter.Build's issue #46 is fixed (AGENTS.template.md, Code style).
run: runuser -u build -- flatpak run --env=CPLUS_INCLUDE_PATH=/app/include/c++/v1 "$CRAFTER_REF" lint --banks=bunq
- name: Sysroot
run: runuser -u build -- packaging/flatpak/make-aarch64-sysroot.sh
- name: Build
run: runuser -u build -- packaging/flatpak/build-aarch64.sh repo "$BRANCH"
publish:
if: github.event_name == 'push'
runs-on: flatpak
timeout-minutes: 210
container:
image: archlinux:latest
options: >-
-v crafter-flatpak-org-system:/var/lib/flatpak
-v crafter-flatpak-nostro-cache:/home/build/.cache
-v /var/www/flatpak:/srv/flatpak
-v /etc/crafter-flatpak:/run/crafter-flatpak:ro
steps:
- name: Install tools
# A mirror answering 502 can fail a pacman transaction even with another mirror behind it; a retry starts over.
run: |
retry() { for i in 1 2 3 4 5; do "$@" && return 0; echo "attempt $i of 5 failed: $*" >&2; [ "$i" = 5 ] || sleep 30; done; return 1; }
pacman-key --init
pacman-key --populate archlinux
retry pacman -Sy --noconfirm --needed archlinux-keyring
retry pacman -Syu --noconfirm --needed flatpak ostree appstream binutils curl xz gnupg git nodejs util-linux python jq
git config --global --add safe.directory '*'
- name: crafter-build
# The Crafter.Build Flatpak's stable branch, which moves only with its releases; its Sdk comes from Flathub.
# Flathub's CDN answers 502 now and then, which flatpak reports as a missing runtime: each of these gets five
# tries.
run: |
retry() { for i in 1 2 3 4 5; do "$@" && return 0; echo "attempt $i of 5 failed: $*" >&2; [ "$i" = 5 ] || sleep 30; done; return 1; }
retry flatpak remote-add --if-not-exists catcrafts https://flatpak.catcrafts.net/catcrafts.flatpakrepo
retry flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
retry flatpak install -y --noninteractive catcrafts "$CRAFTER_REF"
retry flatpak update -y --noninteractive
flatpak info "$CRAFTER_REF" | sed -n 's/^ *\(Version\|Commit\|Date\): */crafter-build \1: /p'
- name: Checkout
# Every branch and tag, for the release checks; no step pushes, so the token is not kept in the checkout.
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Build user
# crafter-build and the scripts run as a user; root installs and publishes.
run: |
id build >/dev/null 2>&1 || useradd -m build
chown -R build: "$GITHUB_WORKSPACE" /home/build
- name: Version
id: meta
# The release checks, before anything is built; the notes go to release-notes.md, for the release.
env:
RELEASE_NOTES: release-notes.md
run: |
set -eu
version=$(runuser -u build -- packaging/flatpak/release-version.sh "$GITHUB_REF_NAME")
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "version $version"
- name: Tests
# Against the fake bunq and the fake system bus the tests bring: no bank and no system bus is reached.
run: runuser -u build -- flatpak run "$CRAFTER_REF" test --banks=bunq
- name: Sysroot
run: runuser -u build -- packaging/flatpak/make-aarch64-sysroot.sh
- name: Build
# repo is made anew, as dist is below: root bundles and publishes from it.
run: |
rm -rf repo
runuser -u build -- packaging/flatpak/build-aarch64.sh repo "$BRANCH"
- name: Bundle
# dist is made anew: the release carries every file in it, and a checkout can bring a dist of its own, or a
# link by that name.
run: |
rm -rf dist
mkdir dist
flatpak build-bundle --arch="$ARCH" --runtime-repo=https://dl.flathub.org/repo/flathub.flatpakrepo \
repo "dist/nostrod-${{ steps.meta.outputs.version }}-$ARCH.flatpak" "$SERVICE_ID" "$BRANCH"
flatpak build-bundle --arch="$ARCH" --runtime-repo=https://dl.flathub.org/repo/flathub.flatpakrepo \
repo "dist/nostro-${{ steps.meta.outputs.version }}-$ARCH.flatpak" "$APP_ID" "$BRANCH"
- name: Upload bundles
uses: actions/upload-artifact@v3
with:
name: nostro-${{ steps.meta.outputs.version }}-aarch64
path: dist/*.flatpak
if-no-files-found: error
- name: Publish to the Catcrafts repository
run: |
set -eu
if [ ! -s /run/crafter-flatpak/signing-key.asc ] || [ ! -s /run/crafter-flatpak/key-id ]; then
echo "no signing key under /etc/crafter-flatpak on the runner host" >&2
exit 1
fi
export GNUPGHOME=$(mktemp -d)
gpg --batch --quiet --import /run/crafter-flatpak/signing-key.asc
key_id=$(cat /run/crafter-flatpak/key-id)
# The other workflows that publish into this repository each hold this lock while they do, so a commit and
# the summary update of one never interleave with another's.
exec 9> /srv/flatpak/.publish.lock
flock 9
# The repository's catcrafts.flatpakrepo, which an install adds, is Crafter.Build's to write, so a repository
# that is not there is not this workflow's to start; it commits its own refs and then updates the repository
# as the others do.
[ -f "$REPO_DIR/config" ] || { echo "no published repository at $REPO_DIR" >&2; exit 1; }
# Each one's ref file, the repository's key in it: the checkout's, read as the build user like every file of
# the checkout. They are made before anything is published, so a file that cannot carry the key publishes
# nothing, and moved beside the repository after it.
key=$(gpg --export "$key_id" | base64 --wrap=0)
[ -n "$key" ] || { echo "the signing key did not export" >&2; exit 1; }
for id in "$SERVICE_ID" "$APP_ID"; do
runuser -u build -- sed "s|^GPGKey=.*|GPGKey=$key|" "packaging/flatpak/$id.flatpakref" > "/srv/flatpak/.$id.flatpakref.new"
grep -qx "GPGKey=$key" "/srv/flatpak/.$id.flatpakref.new"
done
# The service and the app in one commit to the repository: the app is of no use without the service of its
# release.
flatpak build-commit-from --src-repo=repo \
--gpg-sign="$key_id" --gpg-homedir="$GNUPGHOME" \
"$REPO_DIR" "app/$SERVICE_ID/$ARCH/$BRANCH" "app/$APP_ID/$ARCH/$BRANCH"
flatpak build-update-repo --gpg-sign="$key_id" --gpg-homedir="$GNUPGHOME" \
--generate-static-deltas --prune "$REPO_DIR"
for id in "$SERVICE_ID" "$APP_ID"; do
mv "/srv/flatpak/.$id.flatpakref.new" "/srv/flatpak/$id.flatpakref"
done
flock -u 9
- name: Release files
# The ref files as published, with the repository's key (the checkout's have a placeholder), and the checksums
# of what the release carries.
run: |
set -eu
cp "/srv/flatpak/$SERVICE_ID.flatpakref" "/srv/flatpak/$APP_ID.flatpakref" dist/
(cd dist && sha256sum * > SHA256SUMS && ls -la)
- name: Publish release
# The notes are release-notes.md, which the Version step wrote. No `override`: it would delete a tag that has
# moved off this commit since the Version step and tag the old commit instead.
uses: https://code.forgejo.org/actions/forgejo-release@v2
with:
direction: upload
url: ${{ github.server_url }}
repo: ${{ github.repository }}
tag: ${{ steps.meta.outputs.version }}
title: Nostro ${{ steps.meta.outputs.version }}
release-notes-file: release-notes.md
release-dir: dist
token: ${{ secrets.GITHUB_TOKEN }}