Skip to content

test(selfhost): cover env_get, compose_file_args, and require_cmd in the deploy-common lib - #7844

Closed
shin-core wants to merge 1 commit into
JSONbored:mainfrom
shin-core:test/selfhost-deploy-common-coverage-7769
Closed

test(selfhost): cover env_get, compose_file_args, and require_cmd in the deploy-common lib#7844
shin-core wants to merge 1 commit into
JSONbored:mainfrom
shin-core:test/selfhost-deploy-common-coverage-7769

Conversation

@shin-core

Copy link
Copy Markdown
Contributor

What & why

Closes #7769.

test/unit/selfhost-deploy-common.test.ts only exercised maybe_infisical_run (and, since #7766 landed, env_put). The other three functions in scripts/lib/selfhost-deploy-common.shenv_get, compose_file_args, and require_cmd — had no test seam, despite being sourced by five deploy/verify scripts and being where two other already-filed bugs in this file went undetected. This adds real unit coverage for them.

What's tested

A small parameterized runner (runLibFn) sources the lib in a scratch dir and invokes one function per case, mirroring the existing spawn-a-real-bash harness. Cases:

  • require_cmd: succeeds silently for a present command (bash); exits 1 with required command not found: … for a missing one.
  • env_get: plain unquoted value; strips surrounding double and single quotes; skips comment/blank lines and returns the first matching key with indentation and =-spacing trimmed; exit 1 for an absent key; exit 1 for a missing file; falls back to $ENV_FILE when no file arg is given.
  • compose_file_args: emits -f docker-compose.yml by default; adds docker-compose.override.yml when present; uses SELFHOST_COMPOSE_FILES verbatim when set; exits 1 with compose file not found: … for a listed-but-missing file.

Scope is exactly the remaining coverage — env_put (added by #7766) and maybe_infisical_run are left untouched, and this doesn't pre-empt the companion compose_file_args/env_put bug-fix issues (it tests the current behavior, not a fix).

Validation

  • test/unit/selfhost-deploy-common.test.ts: 20 tests pass (4 maybe_infisical_run + 4 env_put + 12 new), typecheck clean, git diff --check clean.
  • Tests genuinely bite: a mutation making compose_file_args emit the wrong flag fails 3 of the new cases.
  • Test-only change (test/**), additive after the existing blocks; branched off current main, mergeable-clean.

…the deploy-common lib

test/unit/selfhost-deploy-common.test.ts only exercised maybe_infisical_run
(and, since JSONbored#7766, env_put), leaving env_get, compose_file_args, and require_cmd
in scripts/lib/selfhost-deploy-common.sh with no test seam despite being sourced
by five deploy/verify scripts. Add a small parameterized runner that sources the
lib and invokes one function per case (mirroring the existing spawn-a-real-bash
harness) and cover: require_cmd present/missing; env_get plain/quoted values,
comment+blank skipping, first-match-wins, absent-key and missing-file exit 1, and
the $ENV_FILE fallback; compose_file_args default, override-present,
SELFHOST_COMPOSE_FILES override, and missing-file exit 1.
@shin-core
shin-core requested a review from JSONbored as a code owner July 21, 2026 14:56
@superagent-security superagent-security Bot added the contributor:flagged Contributor flagged for review by trust analysis. label Jul 21, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

🚨 Contributor flagged. Click here for more info: Superagent Dashboard

@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 21, 2026
@loopover-orb

loopover-orb Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Caution

🛑 LoopOver review result - fixes required

Review updated: 2026-07-21 15:07:22 UTC

1 file · 1 AI reviewer · no blockers · CI failing · blocked

🛑 Suggested Action - Fix Blockers

Review summary
This is a test-only addition that builds a parameterized spawn-a-real-bash harness (runLibFn) to cover require_cmd, env_get, and compose_file_args in scripts/lib/selfhost-deploy-common.sh, closing #7769. The cases look well-targeted at real behavior (quote-stripping, first-match-wins, ENV_FILE fallback, SELFHOST_COMPOSE_FILES override, missing-file failure paths) rather than fabricated scenarios, and the PR explicitly avoids touching env_put/maybe_infisical_run or pre-empting separate bug-fix issues, so scope is clean. The four failing 'validate'/'validate-tests' checks are unexplained by the diff itself and the branch is a commit behind default, which is the more likely cause per BASE BRANCH STATUS.

Nits — 5 non-blocking
  • The 'Contributor trust — Contributor flagged for review' check is a process/identity flag, not something this diff can fix, but it should be resolved before merge per repo policy.
  • test/unit/selfhost-deploy-common.test.ts: runLibFn's set -eo pipefail without set -u is explained by a comment, but consider asserting result.stdout is empty (not just status) in the require_cmd missing-command case for full symmetry with the success case's stderr check.
  • test/unit/selfhost-deploy-common.test.ts: the env_get 'skips comment and blank lines' test only exercises the first-match branch of the underlying awk; consider also asserting the returned value for a non-first, later-only key to fully pin the loop's early-exit semantics (already partially covered by the 'absent key' case, so this is minor).
  • Link the currently-unexplained 'validate'/'validate-tests (1/2/3)' CI failures to whether they reproduce on a rebase onto the 1-commit-newer default branch, per the BASE BRANCH STATUS note, before treating them as this PR's problem.
  • Consider adding one negative case for compose_file_args when SELFHOST_COMPOSE_FILES is set to an empty string, to confirm the fallback-to-default-discovery boundary (or document that it's intentionally out of scope).

CI checks failing

  • validate
  • validate-tests (1)
  • validate-tests (3)
  • validate-tests (2)
Flagged checks (non-blocking)
  • Contributor trust — Contributor flagged for review

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #7769
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 90 registered-repo PR(s), 50 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor shin-core; Gittensor profile; 90 PR(s), 0 issue(s).
Improvement ℹ️ Insufficient signal risk: clean · value: insufficient-signal · LLM: moderate
Linked issue satisfaction

Addressed
The PR adds parameterized tests for require_cmd (present/missing), env_get (plain, quoted, comment/blank skip, missing key, missing file, ENV_FILE fallback), and compose_file_args (default, override, SELFHOST_COMPOSE_FILES, missing-file exit 1), directly matching the issue's three deliverables and following the existing harness structure.

Review context
  • Author: shin-core
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: TypeScript, JavaScript, Solidity, Dart, Python, CSS, PHP, Rust
  • Official Gittensor activity: 90 PR(s), 0 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Triage stale or unlinked PRs.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask <question> answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat <question> answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb

loopover-orb Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

LoopOver is closing this pull request on the maintainer's behalf (CI is failing (validate, validate-tests (1), validate-tests (3), validate-tests (2))). This is an automated maintenance action — to pursue this change, please open a new pull request with the issues resolved. Closed PRs may be analyzed later to improve review accuracy, but they are not automatically reopened or re-reviewed.

@loopover-orb loopover-orb Bot closed this Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor:flagged Contributor flagged for review by trust analysis. gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

scripts/lib/selfhost-deploy-common.sh: 3 of 4 functions have zero test coverage

1 participant