Skip to content

ci(shellcheck): add PR shell script linting#15

Merged
elibosley merged 1 commit into
mainfrom
codex/pr-shellcheck
May 20, 2026
Merged

ci(shellcheck): add PR shell script linting#15
elibosley merged 1 commit into
mainfrom
codex/pr-shellcheck

Conversation

@elibosley

@elibosley elibosley commented Apr 29, 2026

Copy link
Copy Markdown
Member

Summary

  • Add a ShellCheck workflow that runs on every pull request and can be run manually.
  • Install ShellCheck from Ubuntu packages and lint all git-tracked scripts/*.sh files.
  • Pin actions/checkout to the current v4 tag target SHA instead of adding another mutable action tag.
  • Fix existing ShellCheck findings so the new PR gate starts green.

Validation

  • bash -n scripts/create_flash_boot.sh scripts/create_internal_boot_user.sh scripts/menu_gui_common.sh scripts/zip.sh
  • shellcheck $(git ls-files 'scripts/*.sh')
  • git diff --check HEAD~1..HEAD

Summary by CodeRabbit

  • Chores

    • Added automated ShellCheck validation in CI to catch shell script issues earlier.
    • Improved package discovery to more reliably locate the latest release.
    • Clarified script comments and lint exceptions to avoid accidental shell expansions.
  • Bug Fixes

    • Fixed download progress display and ensured saved messages end on a new line.
  • Stability

    • Refined UI sizing and poweroff/reboot handling for more reliable shutdown behavior.

@coderabbitai

coderabbitai Bot commented Apr 29, 2026

Copy link
Copy Markdown

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro (Legacy)

Run ID: c256e554-d080-4ddd-8e14-cfe0a53bf629

📥 Commits

Reviewing files that changed from the base of the PR and between bcb2ee8 and c28f274.

📒 Files selected for processing (5)
  • .github/workflows/shellcheck.yml
  • scripts/create_flash_boot.sh
  • scripts/create_internal_boot_user.sh
  • scripts/menu_gui_common.sh
  • scripts/zip.sh
✅ Files skipped from review due to trivial changes (1)
  • .github/workflows/shellcheck.yml
🚧 Files skipped from review as they are similar to previous changes (4)
  • scripts/create_flash_boot.sh
  • scripts/create_internal_boot_user.sh
  • scripts/zip.sh
  • scripts/menu_gui_common.sh

📝 Walkthrough

Walkthrough

Adds a ShellCheck GitHub Actions workflow and updates shell scripts to use bounded find for ZIP discovery, parse UI dimensions via locals, guard sysrq writes, fix spinner quoting, add a shellcheck suppression, and ensure final output newline.

Main cohort

Layer / File(s) Summary
CI Workflow
.github/workflows/shellcheck.yml
Adds a ShellCheck workflow (pull_request, workflow_dispatch): pinned checkout, install shellcheck, discover scripts/*.sh via git ls-files, run shellcheck, handle empty set gracefully.
ZIP discovery
scripts/create_flash_boot.sh, scripts/create_internal_boot_user.sh
Replace glob/ls discovery with find "$ZIP_DIR" -maxdepth 1 -type f -name 'unRAIDServer-*-x86_64.zip' then `sort -V
UI dims & sysrq guards
scripts/menu_gui_common.sh
ui_set_dims reads up to three space-separated fields into local vars and assigns UI_DIM_1..3; do_poweroff/do_reboot use `if [ -w FILE ]; then echo ...
Quoting & lint annotations
scripts/zip.sh
Spinner string switched to double quotes so backslash is preserved, added SC2016 suppression and comment for intentionally single-quoted php -r, and ensure final "Saved to ..." prints with a trailing newline.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through scripts with gentle paws and cheer,
Replaced wild globs with find to make things clear,
Quoted spinners, silenced lints with a careful nudge,
Captured dims in locals — no more positional smudge,
A tiny rabbit dance for code that’s tidy here. 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title follows the conventional commits format with the 'ci' type and a clear, descriptive subject about adding ShellCheck linting.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands and usage tips.

@elibosley elibosley force-pushed the codex/pr-shellcheck branch from 19e73c5 to bcb2ee8 Compare April 29, 2026 20:45

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
scripts/menu_gui_common.sh (1)

295-296: ⚠️ Potential issue | 🟠 Major

Fix remaining SC2015 patterns to unblock ShellCheck.

Line 295, Line 296, Line 311, and Line 312 still use A && B || C, which triggers the pipeline warnings and can mask command failure semantics.

Proposed fix
-    [ -w /proc/sys/kernel/sysrq ] && echo 1 > /proc/sys/kernel/sysrq || true
-    [ -w /proc/sysrq-trigger ] && echo o > /proc/sysrq-trigger || true
+    if [ -w /proc/sys/kernel/sysrq ]; then
+        echo 1 > /proc/sys/kernel/sysrq || true
+    fi
+    if [ -w /proc/sysrq-trigger ]; then
+        echo o > /proc/sysrq-trigger || true
+    fi
@@
-    [ -w /proc/sys/kernel/sysrq ] && echo 1 > /proc/sys/kernel/sysrq || true
-    [ -w /proc/sysrq-trigger ] && echo b > /proc/sysrq-trigger || true
+    if [ -w /proc/sys/kernel/sysrq ]; then
+        echo 1 > /proc/sys/kernel/sysrq || true
+    fi
+    if [ -w /proc/sysrq-trigger ]; then
+        echo b > /proc/sysrq-trigger || true
+    fi

Also applies to: 311-312

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/menu_gui_common.sh` around lines 295 - 296, Replace the problematic
"A && B || true" pipeline patterns with explicit if statements to avoid masking
failures (ShellCheck SC2015); e.g. change "[ -w /proc/sys/kernel/sysrq ] && echo
1 > /proc/sys/kernel/sysrq || true" and "[ -w /proc/sysrq-trigger ] && echo o >
/proc/sysrq-trigger || true" (and the similar pair at lines 311–312) to "if [ -w
/proc/sys/kernel/sysrq ]; then echo 1 > /proc/sys/kernel/sysrq; fi" and "if [ -w
/proc/sysrq-trigger ]; then echo o > /proc/sysrq-trigger; fi" respectively so
the write is attempted only when writable without using the && || pattern.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@scripts/menu_gui_common.sh`:
- Around line 295-296: Replace the problematic "A && B || true" pipeline
patterns with explicit if statements to avoid masking failures (ShellCheck
SC2015); e.g. change "[ -w /proc/sys/kernel/sysrq ] && echo 1 >
/proc/sys/kernel/sysrq || true" and "[ -w /proc/sysrq-trigger ] && echo o >
/proc/sysrq-trigger || true" (and the similar pair at lines 311–312) to "if [ -w
/proc/sys/kernel/sysrq ]; then echo 1 > /proc/sys/kernel/sysrq; fi" and "if [ -w
/proc/sysrq-trigger ]; then echo o > /proc/sysrq-trigger; fi" respectively so
the write is attempted only when writable without using the && || pattern.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro (Legacy)

Run ID: b19aa874-e7ce-412e-b116-3afdbd11a7a4

📥 Commits

Reviewing files that changed from the base of the PR and between a598445 and 19e73c5.

📒 Files selected for processing (5)
  • .github/workflows/shellcheck.yml
  • scripts/create_flash_boot.sh
  • scripts/create_internal_boot_user.sh
  • scripts/menu_gui_common.sh
  • scripts/zip.sh

- Purpose: ensure every pull request runs ShellCheck against tracked installer shell scripts.
- Before: shell script linting was manual, and several existing informational ShellCheck findings would make a new gate fail immediately.
- Problem: PRs could introduce shell issues without an automated signal, and adding the workflow without cleanup would create a permanently failing check.
- Change: add a PR-level ShellCheck workflow using Ubuntu's shellcheck package and a SHA-pinned checkout action.
- How: run ShellCheck over git-tracked scripts/*.sh files, fix existing ShellCheck findings in ZIP selection, menu dimension parsing, and zip metadata parsing comments.
@elibosley elibosley force-pushed the codex/pr-shellcheck branch from bcb2ee8 to c28f274 Compare May 7, 2026 14:31
@elibosley elibosley marked this pull request as ready for review May 20, 2026 13:28
@elibosley elibosley merged commit 8de1c01 into main May 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant