Repository navigation
fix: sourced modules no longer overwrite the caller's SCRIPT_DIR - #79
Conversation
Every module that src/main.sh sources (utils/logging.sh and all of diagnostics/ and repairs/) began by assigning the global SCRIPT_DIR to its own directory. After main.sh sourced utils/logging.sh, SCRIPT_DIR was src/utils, so its next line sourced src/utils/utils/privileges.sh and `network-repair --help` exited 1 on every distribution in the matrix and in Tests. Each module now resolves the directory it needs into a name of its own: NR_UTILS_DIR (always src/utils, whichever module sets it) and, in repairs/routing.sh, NR_REPAIRS_DIR for the two interfaces.sh re-sources its functions do at run time. Those used to work only because repairs/networkmanager.sh happened to be sourced last and left SCRIPT_DIR at src/repairs. Checked locally against main (eed2f99): - `network-repair --help` and `--version`: exit 1 -> exit 0 - tests/run-tests.sh: 20/25 -> 24/25 - tests/integration/test-safe-mode.sh: 2 checks pass -> 9 - `bash -n` on every .sh: clean - shellcheck -S warning on src/: the same two pre-existing findings (SC1010, SC2064), none added Still failing, unrelated to this change: `diagnose` exits 1 under set -e when an interface has no address (diagnostics/interfaces.sh, `ip=$(get_interface_ip ...)`), and test-utils.sh expects COLOR_RED to be non-empty when stdout is not a terminal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y6FD63UrriRBHqmhhEca9t
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📜 Recent review details
📝 Summary
Merge Risk: ⚪ Minimal · up to
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Add Carrot credits or activate Agent usage billing to use Autofix |
|
✅ Coding Agent task started: View task and status The task will inspect the CI failures, validate its fix, and commit the fix to this branch automatically.
⏭️ Checks skipped: 2 · already failing on `main` (not caused by this PR)
|
|
🤖 Completed: Generate docstrings for PR #79 — View commit |
…nonterminal tests
test-utils.sh now sources logging.sh and every diagnostics and repairs module in a fresh shell, started from /, with SCRIPT_DIR preset, and fails if any module changes it. That is the bug this PR fixes, so the fix now has a test: on main the test fails at logging.sh. The test is the one CodeRabbit wrote for the same bug on #78 (fa99baa), moved here, where the fix lives. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y6FD63UrriRBHqmhhEca9t
fa99baa fixed the same bug as #79 with different variable names, so whichever PR merged second would conflict. src/ and tests/ now match #79 at 4270e56 exactly: NR_UTILS_DIR / NR_REPAIRS_DIR in the modules, diagnostics that report issues without tripping errexit, the safe-mode and colour test fixes, and the module-loading regression test that fa99baa introduced. Once #79 merges this change is a no-op. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y6FD63UrriRBHqmhhEca9t
|
CI status at 4270e56. Unit Tests, ShellCheck, Integration Tests (ubuntu 20.04/22.04/24.04, debian:12) and most distro jobs pass, with 4270e56 adding a SCRIPT_DIR regression test. Every remaining failure stops before any test runs, in a service this PR does not touch:
#80–#82 are workflow-only fixes, each in its own PR. Once they merge, I'll merge main into this branch. The scan and hypatia checks stay red until the standards re-pin. No job was re-run: these failures are deterministic. Generated by Claude Code |
CodeRabbit's CI-fix agent ported its own version of the SCRIPT_DIR fix into this PR. #79 is that fix, and the owner's order lands #79 first and keeps each PR to its own change rather than cross-porting. The port uses different variable names and tests from #79, so it would conflict with #79 in fourteen files once #79 merges. Its tests cover #79's change, not this one. This PR stays the distro install fix. Its jobs go green once #79 is in main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y6FD63UrriRBHqmhhEca9t
|
## Why Five distro jobs fail before any test runs, on main and on every PR. The failures are listed on #79. ## What | Job | Failure | Fix | |---|---|---| | `debian-11`, `Integration Tests - debian:11` | `bullseye-security` returns 404 for every package; Debian 11 is past end of life. | Removed from both workflow matrices, `tests/distro-matrix.json` and `tests/run-container-tests.sh`. `debian:12` stays. | | `rockylinux-9`, `almalinux-9` | `dnf` will not replace the image's `curl-minimal` with `curl`. | `dnf install -y --allowerasing …`, in the workflow and in the local runner's install line. | | `opensuse-leap-15.5`, `opensuse-tumbleweed` | `actions/checkout` cannot find `tar` in the image. | A step before checkout runs `zypper --non-interactive install tar gzip`. | `Matrix Summary` aggregates these jobs and should go green once they do. No action refs change, so `actions.lock` is untouched. ## Tested - The edited workflows parse with yq. The `tar` step is the first step of the openSUSE job, and both matrices now end at `debian:12`. - `tests/distro-matrix.json` parses with jq. `run-container-tests.sh` passes `bash -n`. Its one `shellcheck -S warning` hit (SC2207, line 280) was already there before this PR. - This session had no container runtime, so the jobs themselves were not run locally; this PR's CI run is the test. `CLAUDE.md` still lists "Debian 11, 12" among the system-test targets. It is the repository's own instruction file, so it is left for the owner to edit. --- _Generated by [Claude Code](https://claude.ai/code/session_01Y6FD63UrriRBHqmhhEca9t)_ --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
## Why Workflow Security Linter's "Check SHA-Pinned Actions" step requires an inline 40-hex SHA on every `uses:` line. This repository pins its actions with tag refs that `actions.lock` resolves, so the step rejects every one of them. That keeps the linter red on main whatever else it finds. This is the second failing step, after the SPDX check that #80 fixes. ## What - The step now runs `scripts/check-action-pinning.js`, copied unchanged from rsr-template-repo (ec33724). A ref passes when it is an inline SHA or when `actions.lock` resolves it. - The script runs under Bun 1.4.2, the estate pin. A new "Install verified Bun 1.4.2" step downloads it from the release archive and checks its sha256, as hyperpolymath/rsr-template-repo#249 now does in the template. - bf2a196 first used the template's `oven-sh/setup-bun@v2.2.0` with `bun-version: latest`. SonarCloud failed this PR on that tag-pinned third-party action ("C Security Rating"), and the runtime was unpinned. 9d13eba replaces it, on the owner's call. - `actions.lock` is unchanged from main. - One change from the template: the example in the error message now labels `actions/checkout@3d3c42e…` as v7.0.1, which is what this repository's lock records. The template says v6.0.1. ## Tested - The script passes on this branch's workflows: "all action refs are pinned". - It fails on a planted `uses: some-org/unlocked-action@v1`. - I extracted the Bun step from the workflow and ran it with a scratch `RUNNER_TEMP` whose path contains a space. The checksum printed `OK` and `bun --version` prints `1.4.2`. - standards' `validate-actions-lock.sh` (75bd599) passes on the lock. ## Merge order The owner's order is #79 → #82 → #80 → #81 → #78. This PR and #80 change different steps of the same workflow, so they don't conflict. The linter goes fully green only once both are in. scan and hypatia also need the estate re-pin to standards `75bd599`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Y6FD63UrriRBHqmhhEca9t --------- Co-authored-by: Claude <noreply@anthropic.com>



Summary
On main,
network-repair --helpexits 1 on every distribution in Distribution Matrix Tests and in Tests:Every module that
src/main.shsources starts by assigning the globalSCRIPT_DIRto its own directory. That coversutils/logging.shand everything indiagnostics/andrepairs/. Once main.sh has sourcedutils/logging.sh,SCRIPT_DIRissrc/utils, so main.sh's nextsourceresolves undersrc/utils/utils/.Changes
SCRIPT_DIRtomain.sh:NR_UTILS_DIRis alwayssrc/utils, whichever module sets it.repairs/routing.shsetsNR_REPAIRS_DIR, because two of its functions re-sourceinterfaces.shat run time.diagnoseunderset -e.diagnose's output once.repairs/routing.sh.SCRIPT_DIRalone. The test fails on main.Testing
./network-repair --help/--versiontests/run-tests.shtests/test-utils.shshellcheck -S warningonsrc/Still red here, fixed elsewhere
lint-workflows: fixed by fix(ci): SPDX check accepts the licence after the actions-lock banner #80 (SPDX) and fix(ci): the pinning check accepts refs that actions.lock resolves #81 (pinning).scan / *andhypatia: these need the estate re-pin of the standards workflows (75bd599).🤖 Generated with Claude Code
https://claude.ai/code/session_01Y6FD63UrriRBHqmhhEca9t