fix(installer): prefer sha256sum over shasum for checksum verification (#3170)#3171
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe installer script now selects an available SHA-256 verifier at runtime (prefer ChangesDynamic Checksum Tool Selection
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/runner.test.ts (1)
644-730: ⚡ Quick winAdd explicit tests for the two newly introduced fallback branches.
Current updates validate the preferred
sha256sumpath, but the newshasumfallback and “neither tool available” failure branch should also be asserted to prevent regressions.Suggested test additions
+ it("install-openshell.sh falls back to shasum when sha256sum is unavailable", () => { + // stub command -v sha256sum => fail, command -v shasum => success + // stub shasum() to log args and return success + // assert checksum log contains: "SHASUM -a 256 -c -" + }); + + it("install-openshell.sh fails clearly when no SHA-256 tool is available", () => { + // stub command -v sha256sum => fail and command -v shasum => fail + // run script and assert non-zero status + // assert output contains: "No SHA-256 tool available (sha256sum/shasum)" + });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/runner.test.ts` around lines 644 - 730, Tests only cover the primary sha256sum path; add two new specs in test/runner.test.ts that exercise the shasum fallback and the "neither tool available" failure: (1) create a tmpBin stub where sha256sum is absent but shasum (or shasum -a 256) is present (write a small shim that logs invocations to checksumLog), source install-openshell.sh and assert output contains the shasum-fallback marker and that checksumLog contains the expected "-c -" invocation; (2) create a tmpBin with no sha256sum/shasum and with gh absent/failing, run the script and assert it exits non-zero (or prints the expected failure message such as "gh CLI download failed"), cleaning up tmpBin afterwards; use the existing scriptPath and checksumLog variables and mirror the style of the existing tests for spawnSync invocation and assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@test/runner.test.ts`:
- Around line 644-730: Tests only cover the primary sha256sum path; add two new
specs in test/runner.test.ts that exercise the shasum fallback and the "neither
tool available" failure: (1) create a tmpBin stub where sha256sum is absent but
shasum (or shasum -a 256) is present (write a small shim that logs invocations
to checksumLog), source install-openshell.sh and assert output contains the
shasum-fallback marker and that checksumLog contains the expected "-c -"
invocation; (2) create a tmpBin with no sha256sum/shasum and with gh
absent/failing, run the script and assert it exits non-zero (or prints the
expected failure message such as "gh CLI download failed"), cleaning up tmpBin
afterwards; use the existing scriptPath and checksumLog variables and mirror the
style of the existing tests for spawnSync invocation and assertions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: c987855a-0422-46f5-bc81-0aca8de606f8
📒 Files selected for processing (2)
scripts/install-openshell.shtest/runner.test.ts
|
✨ Thanks for submitting this PR that fixes the installer to prefer sha256sum over shasum for checksum verification. This change involves updating the install-openshell.sh script to use sha256sum when available, fall back to shasum, and fail with a clear error if neither is found. Related open issues: |
|
/ok to test 8b3df61 |
The install-openshell.sh script hardcoded shasum, which is less common on Linux. Use sha256sum when available, fall back to shasum, and fail with a clear error if neither is found — matching the existing pattern in check-installer-hash.sh. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Oliver Walsh <owalsh@redhat.com>
Summary
The install-openshell.sh script hardcoded shasum, which is less common on Linux. Use sha256sum when available, fall back to shasum, and fail with a clear error if neither is found — matching the existing pattern in check-installer-hash.sh.
Related Issue
Fixes #3170
Changes
Type of Change
Verification
npx prek run --all-filespassesnpm testpassesmake docsbuilds without warnings (doc changes only)Signed-off-by: Oliver Walsh owalsh@redhat.com
Summary by CodeRabbit
Bug Fixes
Tests