Skip to content

test: cover the release build scripts (lint + hermetic tests)#90

Closed
skjnldsv wants to merge 2 commits into
mainfrom
feature/build-script-tests
Closed

test: cover the release build scripts (lint + hermetic tests)#90
skjnldsv wants to merge 2 commits into
mainfrom
feature/build-script-tests

Conversation

@skjnldsv

@skjnldsv skjnldsv commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Why

10 of the 12 scripts in .github/scripts/ had no lint and no tests — including the release build chain (assemble, package, sign-release, update-version-php, …) and tag-repo. This adds a global shellcheck plus hermetic tests for the cheap, high-value ones, reusing the existing snapshot-harness pattern.

What

Lint — new test-build-scripts.yml shellchecks every script + test harness. Fixed the warnings that surfaced (SC2155/SC2053/SC2086).

Bug found & fixedupdate-version-php.sh read its target dir via getenv('NC') but never exported NC, so it silently always operated on /tmp/nextcloud regardless of the argument. Now exported.

Hermetic tests (tests/build-scripts/, offline — no network/sudo/keys):

  • Snapshot scenarios (manifest of the resulting tree): assemble.sh (apps placed, updater filtered to index.php+phar, skeleton replaced, docs placed, cleanup), clean-dev-files.sh and clean-server-dev-files.sh (KEEP preserved, dev/ignore/sidecar removed).
  • update-version-php.sh: snapshot the rewritten version.php (build date normalized) — stable/master/upgrade-from.
  • Pure-helper unit tests: extracted generate_checksums (package.sh), default_cert (sign-release.sh), wrap_metadata (generate-metadata.sh) behind a "stop when sourced" guard; tested without sudo/tar/zip/occ/DB. Direct-execution behaviour unchanged.

Testing

  • bash tests/build-scripts/run.sh → 6 pass; bash tests/build-scripts/unit.sh → 3 pass
  • shellcheck over all scripts + harnesses → clean
  • Negative control: breaking the assemble updater-filter (or a clean rule) fails the matching scenario
  • Existing milestone/updater suites unaffected

Out of scope (this round)

tag-repo.sh and fetch-all.sh need GH=/GIT= wrapper injection to test their control flow — left shellcheck-only for a follow-up. The HARD scripts keep shellcheck + the extracted-helper unit tests (full behaviour needs sudo/occ/gpg).

skjnldsv added 2 commits June 9, 2026 09:39
update-version-php.sh read the target dir via getenv('NC') in its inline PHP
but never exported NC, so it always fell back to /tmp/nextcloud regardless of
the argument. Export NC so the argument is honoured (and the script is testable
against any directory).

Also fix the warnings that surfaced once all scripts are shellchecked:
- update-version-php.sh: declare/assign BUILD_STRING separately (SC2155)
- clean-dev-files.sh: document the intentional glob match (SC2053)
- fetch-all.sh: pass composer args via an array instead of word-splitting (SC2086)

Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
The build scripts in .github/scripts/ had no tests and no lint. Add a
hermetic harness (tests/build-scripts/) reusing the snapshot pattern:

- assemble.sh, clean-dev-files.sh, clean-server-dev-files.sh: run on a fixture
  tree, snapshot a manifest of the result.
- update-version-php.sh: snapshot the rewritten version.php (build date
  normalized).
- package.sh / sign-release.sh / generate-metadata.sh: extract the pure bits
  (generate_checksums, default_cert, wrap_metadata) behind a "stop when sourced"
  guard and unit-test them - no sudo, tar/zip, occ or database needed.

A new workflow lints every script + harness with shellcheck and runs both
suites (offline; PHP only). Behaviour of the extracted scripts is unchanged
when executed directly.

Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
@skjnldsv skjnldsv added the enhancement New feature or request label Jun 9, 2026
@skjnldsv skjnldsv marked this pull request as draft June 9, 2026 07:51
@skjnldsv skjnldsv closed this Jun 9, 2026
@skjnldsv skjnldsv deleted the feature/build-script-tests branch June 9, 2026 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Development

Successfully merging this pull request may close these issues.

1 participant