Skip to content

[quality] build/00-image-info.sh and build/10-build.sh are untestable — no filesystem root override #287

Description

@kubestellar-hive

Finding

After PR #285, build/clean-stage.sh and build/copr-helpers.sh have BATS coverage. The other two build scripts do not, and cannot be unit tested as written:

build/00-image-info.sh (93 lines) — writes to hardcoded absolute paths:

  • IMAGE_INFO="/usr/share/ublue-os/image-info.json"
  • OS_RELEASE="/usr/lib/os-release"

Untested logic worth covering: the IMAGE_FLAVOR derivation (nvidia vs main from a regex on IMAGE_NAME), the IMAGE_REF string used by bootc as the upgrade source, JSON field correctness, the VERSION vs UBLUE_IMAGE_TAG fallback for IMAGE_VERSION, and the VARIANT_ID guard that makes the os-release append idempotent. A malformed image-ref here silently breaks bootc upgrade for every user of the image.

build/10-build.sh (67 lines) — sources /ctx/build/copr-helpers.sh by absolute path and calls rsync, dnf5, systemctl, cp, find against /ctx and /usr. Untested behaviour: nullglob is enabled specifically so the custom/brew/*.Brewfile and custom/flatpaks/*.preinstall copies do not fail on empty matches — but cp with an unmatched glob under nullglob receives no source argument and fails anyway, which no test would currently catch.

Recommendation

Adopt the same prefix hook clean-stage.sh already uses (CLEAN_ROOT):

  1. In 00-image-info.sh, introduce a defaulted prefix, e.g.
    IMAGE_ROOT="${IMAGE_ROOT:-/}", and build IMAGE_INFO/OS_RELEASE from it. Production behaviour is unchanged (prefix defaults to /); tests can point it at a temp dir.
  2. In 10-build.sh, take the context dir from ${CTX_DIR:-/ctx} and the install prefix from ${BUILD_ROOT:-} so the copy/consolidate section can run in a sandbox with stubbed dnf5/systemctl/rsync.
  3. Add tests/unit/00-image-info_test.bats and tests/unit/10-build_test.bats following the stub-PATH pattern established in [quality] test: add BATS unit tests for build/clean-stage.sh and build/copr-helpers.sh #285.

Step 1 and 2 are production edits, so the quality agent is not opening a PR for them — a maintainer should make the hook change, after which the tests can be contributed.

Priority

  • Impact: high (image-ref and os-release correctness gate bootc upgrades)
  • Effort: medium

Related


Filed by quality agent (hold-gated mode)

🐝 Hive Agent: quality | Instance: hosted-projectbluefin-knuckle-gjvq | SHA: unknown

— hive: agent=quality backend=copilot model=claude-opus-5

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    2-discussingWork requiring discussion or a clarified design.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions