Files
effectcraft/packaging/linux/nightly-launch-test.sh
0ce27fe728 packaging(linux): start every Nightly format the flavor's way, and close the port's gaps
Second commit on top of Dylan Taylor's #4154; his commits, names and files stay his.

The Nightly build refuses EFFECTCRAFT_CONFIG_DIR (its state root comes from the Launcher), so his
wrappers, which export that variable, would have been refused at startup. Every one of them now
passes the protocol instead - `--launch-profile nightly-v1 --profile-root <dir> --`:

- the deb/rpm GUI wrapper in packaging/linux/package.sh, plus a wrapper for its headless CLI;
- the AppImage AppRun (a script, not the stable symlink), and its CLI;
- the Flatpak wrapper in packaging/linux/flatpak-bundle.sh;
- the Arch launcher, with its test updated;
- and a new launcher inside the flat Nightly tar (packaging/linux/nightly-launch.sh), which stages
  the GUI as `effectcraft-bin`; the archive helper allows and requires exactly that one extra member.

The profile folder is `${XDG_DATA_HOME:-$HOME/.local/share}/effectcraft-nightly` everywhere: outside
every stable boundary and inside the Nightly Flatpak's own sandbox home. Each launcher passes a
first-argument --version/-V, and an already-supplied --launch-profile, through unchanged, because
after the injected `--` both would be file names.

build.rs now reads EFFECTCRAFT_VERSION and falls back to EFFECTCRAFT_OVERRIDE_VERSION, which is what
this repo's packaging scripts export, so the binary reports the prepared identity and
nightly-common.sh's exact `EffectCraft <version> (nightly-v1)` check can pass.

profile_root accepts exactly the Nightly's own Flatpak instance (ai.storyteller.effectcraft.nightly)
and refuses every other, with a test; before, any FLATPAK_ID was refused and the Nightly Flatpak
could not start inside its own sandbox.

Cargo.lock's effectcraft entry names thiserror and winsafe, which the flavor added to the manifest,
so `cargo check --locked` resolves again.

With his enabled callers kept whole, the flavor's `.github/actionlint.yaml` (a suppression for a
`queue:` key his signer no longer sets) and its `packaging-lint.yml` path entry are gone; nothing in
the tree names `queue:` or the `macos-release` label.

Already right here: the window class matches the Nightly desktop entry's StartupWMClass, the
metainfo declares no mediatypes, the Nightly build needs no extra features, and
sonar.coverage.exclusions already covers packaging/**.

The flavor itself had three compile errors that only a real `cargo check` finds, fixed here: the
user-preset folder asked `effectcraft_host` for the profile root from a crate that does not depend on
it (the UI now carries the profile's `Presets` folder through `channel::set_profile_presets`, set from
`prepare_launch`), `channel::channel_label` was `const` while it reads a non-const atomic identity,
and a test built `"--launch-profile="` with `+` on `&str`s.

Tests: packaging/nightly-tests.py (71 suite tests plus the two Linux launcher argv tests),
bash -n over every changed script, rustfmt --edition 2024 --check on the changed Rust, and
`cargo check --locked -p effectcraft --tests` / `-p effectcraft-cli --tests`, both green locally (with
a check-only alsa.pc, because this host has no libasound outside the Nix dev shell). package.sh was
also rendered with stub binaries and a stub nfpm, and the installed deb tree read back.

Co-authored-by: dylanmtaylor <[email protected]>
Co-authored-by: skylartaylor <[email protected]>
2026-11-24 23:33:37 +01:00

54 lines
2.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Validate the launcher inside the flat Nightly tar without building or opening EffectCraft.
set -euo pipefail
HERE="$(cd "$(dirname "$0")" && pwd)"
work="$(mktemp -d)"
trap 'rm -rf "$work"' EXIT
stage="$work/unpacked"
mkdir -p "$stage"
# A local argv recorder stands in for the compiled GUI, which the launcher starts as `effectcraft-bin`.
cat >"$stage/effectcraft-bin" <<'RECORDER'
#!/bin/sh
printf '<%s>\n' "$@"
RECORDER
chmod 755 "$stage/effectcraft-bin"
cp "$HERE/nightly-launch.sh" "$stage/effectcraft"
chmod 755 "$stage/effectcraft"
# A fixed profile base keeps the recorded arguments exactly comparable.
export XDG_DATA_HOME="$work/xdg-data"
profile() {
printf '<%s>\n' --launch-profile nightly-v1 --profile-root "$XDG_DATA_HOME/effectcraft-nightly" -- "$@"
}
expect() {
expected="$1"
shift
actual=$("$stage/effectcraft" "$@")
if [[ "$actual" != "$expected" ]]; then
printf 'expected:\n%s\nactual:\n%s\n' "$expected" "$actual" >&2
exit 1
fi
}
expect "$(profile)"
expect "$(profile 'project with spaces.ec' '--other-name.ec')" 'project with spaces.ec' '--other-name.ec'
# A version query and an already selected profile pass through: after `--` both would be files.
expect '<--version>' --version
expect '<-V>' -V
expect "$(printf '<%s>\n' --launch-profile nightly-v1 --profile-root "$work/launcher-root" --version)" \
--launch-profile nightly-v1 --profile-root "$work/launcher-root" --version
# HOME is the only other base, and the profile root is never optional.
home_run=$(env -u XDG_DATA_HOME HOME="$work/home" "$stage/effectcraft")
expected_home=$(printf '<%s>\n' --launch-profile nightly-v1 --profile-root "$work/home/.local/share/effectcraft-nightly" --)
if [[ "$home_run" != "$expected_home" ]]; then
printf 'expected:\n%s\nactual:\n%s\n' "$expected_home" "$home_run" >&2
exit 1
fi
if env -u XDG_DATA_HOME -u HOME "$stage/effectcraft" >/dev/null 2>&1; then
echo 'a launcher without HOME must refuse rather than start with the stable profile' >&2
exit 1
fi
echo "PASS: the flat Nightly tar's launcher starts the GUI through the Nightly launch profile"