test: cover the release build scripts (lint + hermetic tests)#90
Closed
skjnldsv wants to merge 2 commits into
Closed
test: cover the release build scripts (lint + hermetic tests)#90skjnldsv wants to merge 2 commits into
skjnldsv wants to merge 2 commits into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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, …) andtag-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.ymlshellchecks every script + test harness. Fixed the warnings that surfaced (SC2155/SC2053/SC2086).Bug found & fixed —
update-version-php.shread its target dir viagetenv('NC')but never exportedNC, so it silently always operated on/tmp/nextcloudregardless of the argument. Now exported.Hermetic tests (
tests/build-scripts/, offline — no network/sudo/keys):assemble.sh(apps placed, updater filtered to index.php+phar, skeleton replaced, docs placed, cleanup),clean-dev-files.shandclean-server-dev-files.sh(KEEP preserved, dev/ignore/sidecar removed).update-version-php.sh: snapshot the rewrittenversion.php(build date normalized) — stable/master/upgrade-from.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 passshellcheckover all scripts + harnesses → cleanOut of scope (this round)
tag-repo.shandfetch-all.shneedGH=/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).