The cache only works when the job container shares the host network (a bridge job cannot reach the runner's cache server through a host firewall); record that, force_pull and node_download so the runner can be rebuilt without rediscovering them.
7.7 KiB
Development
How to build Regent, run it from a build tree, and test it.
Scope: local setup, building, running, tests and deployment. For running the signer unattended and pairing a client from the command line, see Advanced usage; for cutting a release, see Releasing.
Prerequisites
You will need the following things properly installed on your computer.
- Rust (
cargo) - Meson and Ninja
- GTK 4 and libadwaita development headers
- blueprint-compiler
appstreamclianddesktop-file-validate(for the validation commands below)nak(optional; only for the relay-level tests and the acceptance script)
On Arch Linux:
pacman -S rust meson ninja gtk4 libadwaita blueprint-compiler appstream
Building
cargo generate-lockfile # once, so --locked builds work
meson setup _build
meson compile -C _build
meson install -C _build # optional; needs to write to /usr/local
Run it from the build directory (GSETTINGS_SCHEMA_DIR is needed because the
schema is not installed system-wide yet; REGENT_GRESOURCE points at the
generated GResource):
GSETTINGS_SCHEMA_DIR=_build/data \
REGENT_GRESOURCE=_build/data/resources/org.kosmos.raucao.Regent.gresource \
./_build/regent
Nightly (development) build
A development build is a separate application identity — the app id carries a
.Devel suffix, so the desktop file, icon, GSettings schema, GResource bundle,
D-Bus name and data directories all follow, and the binary is regent-devel.
That lets it install and run beside the stable one:
meson setup _build -Dprofile=development
meson compile -C _build
GSETTINGS_SCHEMA_DIR=_build/data \
REGENT_GRESOURCE=_build/data/resources/org.kosmos.raucao.Regent.Devel.gresource \
./_build/regent-devel
The nightly uses the banded nightly app icon and libadwaita's striped devel
header bar, so it is obvious at a glance which build you are looking at.
Cargo is driven by Meson (
custom_target). Every source file must be listed as an input inmeson.build, otherwise edits don't trigger a rebuild.
Testing
The unit and integration tests run on a plain cargo test:
cargo test
The relay-level nak_* tests are ignored by default and need a real relay. Each
spins up its own local nak serve, and together they cover the NIP-46 approval
paths end to end:
CARGO_TARGET_DIR=_build/cargo-target REGENT_TEST_RELAY=wss://nostr.kosmos.org \
cargo test --release -- --ignored --nocapture nak
There is also a full end-to-end check (vault → responder → app) in a throwaway
HOME, using gtk4-broadwayd and nak:
dbus-run-session -- build-aux/acceptance.sh
Continuous integration
Gitea Actions runs cargo test --locked,
cargo clippy --all-targets --locked -- -D warnings and cargo deny check on
every push and pull request (.gitea/workflows/ci.yaml). The job runs on the
regent-ci runner, which is registered with the label
regent-ci:docker://gitea.kosmos.org/raucao/regent-ci:latest
so it executes inside the image built from build-aux/ci/Dockerfile. That image
is Arch-based and bakes in the GTK/libadwaita development headers, the pinned
Rust toolchain (1.99.1) and cargo-deny, so the job installs nothing at run time.
Arch is required because Regent's crate features ask for GTK ≥ 4.23 /
libadwaita ≥ 1.10, which is newer than the latest stable GNOME release.
Rebuild and push it from the build host after changing the Dockerfile or the pinned toolchain:
docker login gitea.kosmos.org
build-aux/ci/build-image.sh
The package must stay public (linked to raucao/regent): a label-based runner
cannot pass pull credentials. NO_PUSH=1 build-aux/ci/build-image.sh builds
without pushing, for trying the Dockerfile locally.
The runner
The runner is an ordinary Gitea runner registered at repository level with that
one label; it needs Docker and nothing else installed. A few settings in its
config.yaml are not defaults, and matter:
container.force_pull: true— the registry's:lateststays authoritative instead of a stale local copy.runner.node_download: false— use the node baked into the image instead of downloading one per job.container.network: hostwithcache.host: 127.0.0.1— the runner's cache server listens on the host, and a job container on an auto-created bridge network cannot reach it when a host firewall filters container→host traffic. The cache step then times out on every run (five retries with backoff — about a minute wasted) and nothing is ever cached. Host networking puts the job on127.0.0.1, where the cache works: a run with a warm cache is ~50 s, against ~3m 40s without one.
Validating the package metadata
appstreamcli validate --no-net _build/data/org.kosmos.raucao.Regent.metainfo.xml
desktop-file-validate _build/data/org.kosmos.raucao.Regent.desktop
glib-compile-schemas --strict --dry-run _build/data/
Deploying to another machine
If you build on one machine and run on another — a fast build host and the desktop
you test on — two helper scripts move a build across. build-aux/deploy-dev.sh
runs on the build host; build-aux/regent-deploy.sh runs on the machine you test
on. The test machine pulls the build over SSH, so neither side has to listen for
inbound connections. You need SSH from the test machine to the build host.
Install the wrapper once, on the test machine:
mkdir -p ~/.local/bin
ssh BUILD_HOST 'cat PATH/TO/regent/build-aux/regent-deploy.sh' > ~/.local/bin/regent-deploy
chmod +x ~/.local/bin/regent-deploy
Then point it at your build host and repository path — either export them or edit the script:
export REGENT_BUILD_HOST=user@build-host # required
export REGENT_REPO_PATH='~/src/regent' # default: ~/src/regent
After every change, on the test machine:
regent-deploy
It asks the build host which GTK/libadwaita it builds against and warns if the two
machines have drifted (a mismatch surfaces later as a symbol lookup error), pulls
the install tree, unpacks it into ~/.local (no root needed), recompiles the
GSettings schema, and prints the version it installed. The wrapper keeps itself
current — it fetches its own copy from the build host and re-execs if it changed,
so the one-time install above never goes stale (REGENT_DEPLOY_NO_UPDATE=1 skips
that; the previous copy is kept as regent-deploy.bak).
Options:
REGENT_DEPLOY_PKG=1 regent-deploy— build and install a realregent-devpackage instead (asks forsudo).REGENT_PROFILE=development regent-deploy— install the nightly.Develidentity instead; it has its own app id, desktop file and data directories, so it runs beside a stable install rather than replacing it.
Directly on the build host, with no test machine:
build-aux/deploy-dev.sh # write a tarball to /tmp/regent-dev/
build-aux/deploy-dev.sh --emit # stream the install tree to stdout
build-aux/deploy-dev.sh --pkg # build the regent-dev pacman package
build-aux/deploy-dev.sh --versions # GTK/libadwaita this host builds against
build-aux/deploy-dev.sh --help