Skip to content

Make generate_fun_data.sh POSIX compliant#2

Merged
UncleGrumpy merged 2 commits into
mainfrom
WIP
May 17, 2026
Merged

Make generate_fun_data.sh POSIX compliant#2
UncleGrumpy merged 2 commits into
mainfrom
WIP

Conversation

@UncleGrumpy
Copy link
Copy Markdown
Owner

@UncleGrumpy UncleGrumpy commented May 17, 2026

Eliminate all bashisms and hard-coded tags and branch names.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 17, 2026

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

Run ID: b473e918-cd9b-4b74-bbc3-2fbecb2dee35

📥 Commits

Reviewing files that changed from the base of the PR and between 5ec61ef and ea27931.

📒 Files selected for processing (3)
  • .github/workflows/code_quality_check.yaml
  • generate_fun_data.sh
  • priv/supported_functions.data
✅ Files skipped from review due to trivial changes (1)
  • priv/supported_functions.data
🚧 Files skipped from review as they are similar to previous changes (2)
  • .github/workflows/code_quality_check.yaml
  • generate_fun_data.sh

📝 Walkthrough

Walkthrough

Convert generate_fun_data.sh from Bash to POSIX sh; use mktemp-backed cache with EXIT cleanup; rebuild spectrometer; scan main, latest origin/release-X.Y branch, and selected tags (release vs prerelease filtering); update tag scan loop; use cmp-based copy/backup; extend uart entries; add ShellCheck CI step.

Changes

POSIX migration + tag scanning

Layer / File(s) Summary
Shebang and POSIX runtime setup
generate_fun_data.sh
Interpreter changed to #!/bin/sh; initialization rewritten with set -e, $0-based SCRIPT_DIR, mktemp -d temp cache creation, EXIT trap, and escript rebuild.
Main branch scan
generate_fun_data.sh
OUTPUT_FILE written under temp cache; run spectrometer update for main with a guarded checkout.
Discover and scan latest remote release branch
generate_fun_data.sh
Fetch remotes, parse origin/release-X.Y branches to find highest version, verify remote ref, checkout it, and run spectrometer update.
Enumerate and filter git tags
generate_fun_data.sh
Fetch and classify tags into releases vs prereleases; for bases lacking releases, pick one prerelease using rc>beta>alpha precedence and highest numeric suffix; sort newest-first.
POSIX tag scanning loop
generate_fun_data.sh
Process the computed tag list line-by-line, checkout each tag, run spectrometer update --tag, continue on failures, and append results to OUTPUT_FILE.
Copy/backup decision and final cleanup
generate_fun_data.sh
Use cmp -s for content equality; back up differing destination with timestamped .bak and replace; rely on EXIT trap for temp cleanup; update completion message.
Add ShellCheck CI lint step
.github/workflows/code_quality_check.yaml
Install shellcheck on the runner and add a step to lint generate_fun_data.sh with configured flags.
Extend uart function catalog
priv/supported_functions.data
Add multiple rp2-specific UART APIs (init/deinit, putc/puts, blocking I/O, baud/format/flow-control, tx_wait) while preserving earlier all-platform entries.

Sequence Diagram(s)

sequenceDiagram
  participant Script as generate_fun_data.sh
  participant Git as git
  participant Spect as spectrometer
  participant FS as filesystem
  Script->>Git: fetch remotes & tags
  Script->>Git: checkout main / release branch / tag
  Script->>Spect: spectrometer update (--tag / branch) writing to OUTPUT_FILE in TMP_CACHE_DIR
  Spect->>FS: write generated data to TMP_CACHE_DIR/OUTPUT_FILE
  Script->>FS: cmp -s TMP_CACHE_DIR/OUTPUT_FILE priv/supported_functions.data
  alt different
    Script->>FS: mv priv/supported_functions.data -> .bak timestamped
    Script->>FS: cp TMP_CACHE_DIR/OUTPUT_FILE -> priv/supported_functions.data
  end
  Script->>FS: EXIT trap rm -rf TMP_CACHE_DIR
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

I hopped through shells and tags tonight,
Swapped Bash for POSIX, tidy and light,
Temp folders vanish with a gentle trap,
We scan releases, tags — then copy the wrap,
UART lines new — a rabbit's tiny delight 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Make generate_fun_data.sh POSIX compliant' directly and accurately describes the primary objective of the changeset, which is to port the bash script to POSIX sh.
Description check ✅ Passed The description 'Eliminate all bashisms and hard-coded tags and branch names' is directly related to the changeset, addressing the core changes made to the script.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch WIP

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@generate_fun_data.sh`:
- Around line 23-26: TMP_CACHE_DIR is set to a non-existent child of the mktemp
dir and the EXIT trap deletes only that child, leaking the real temp directory;
change the logic to capture the mktemp base dir (e.g. TMP_BASE_DIR="$(mktemp
-d)"), set TMP_CACHE_DIR="${TMP_BASE_DIR}/spectrometer_version_cache", create
the child with mkdir -p "${TMP_CACHE_DIR}", and update the trap to rm -rf
"${TMP_BASE_DIR}" so the actual temp directory is always cleaned up; reference
TMP_CACHE_DIR, TMP_BASE_DIR, mktemp and the EXIT trap when making the change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4ece2e23-f4db-4431-9855-bfe43aa2bbb4

📥 Commits

Reviewing files that changed from the base of the PR and between 464c2c4 and cd40bc8.

📒 Files selected for processing (1)
  • generate_fun_data.sh

Comment thread generate_fun_data.sh Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

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

⚠️ Outside diff range comments (1)
generate_fun_data.sh (1)

260-270: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Handle spectrometer update failures inside the loop.

With set -e, a single non-zero exit from "$SPECTROMETER" update aborts the whole script. One bad tag prevents the remaining tags from being scanned. The git checkout already demonstrates the error-handling pattern used elsewhere in the script.

Suggested fix
 while IFS= read -r TAG; do
     [ -z "$TAG" ] && continue
     echo "=== Scanning tag: $TAG ==="
     git checkout "$TAG" --quiet 2>/dev/null || { echo "Warning: Could not checkout $TAG"; continue; }
-    "$SPECTROMETER" update \
-        --atomvm-dir "$ATOMVM_DIR" \
-        --tag "$TAG" \
-        --cache "$TMP_CACHE_DIR" \
-        --output "$OUTPUT_FILE" \
-        --force \
-        --no-tests
+    if ! "$SPECTROMETER" update \
+        --atomvm-dir "$ATOMVM_DIR" \
+        --tag "$TAG" \
+        --cache "$TMP_CACHE_DIR" \
+        --output "$OUTPUT_FILE" \
+        --force \
+        --no-tests
+    then
+        echo "Warning: spectrometer update failed for $TAG, continuing..."
+        continue
+    fi
     echo ""
 done < "$TMP_TAG_FILE"
🤖 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 `@generate_fun_data.sh` around lines 260 - 270, The loop currently runs
"$SPECTROMETER" update which can abort the whole script under set -e; change the
call inside the while IFS= read -r TAG loop to check the command's exit status
and handle failures like the git checkout does: use an if ! "$SPECTROMETER"
update --atomvm-dir "$ATOMVM_DIR" --tag "$TAG" --cache "$TMP_CACHE_DIR" --output
"$OUTPUT_FILE" --force --no-tests; then echo a warning including the tag and any
stderr info and continue to the next tag (or capture $?) — this preserves the
existing retry/continue pattern and prevents one bad tag from stopping the whole
script.
🤖 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.

Inline comments:
In `@generate_fun_data.sh`:
- Around line 139-154: The loop over tags uses the GNU-only sort -V which breaks
POSIX portability; update the tag enumeration to avoid sort -V by using git's
built-in sorting (e.g. replace git tag -l "v*.*.*" 2>/dev/null | sort -V with
git tag -l --sort=v:refname "v*.*.*" 2>/dev/null) so the for TAG loop (and
writes to TMP_PRERELEASE_TAGS / TMP_RELEASE_TAGS) remains portable, and
optionally add a fallback path that detects lack of --sort and falls back to a
simple numeric/lexical sort or a shell-based version-compare function.

---

Outside diff comments:
In `@generate_fun_data.sh`:
- Around line 260-270: The loop currently runs "$SPECTROMETER" update which can
abort the whole script under set -e; change the call inside the while IFS= read
-r TAG loop to check the command's exit status and handle failures like the git
checkout does: use an if ! "$SPECTROMETER" update --atomvm-dir "$ATOMVM_DIR"
--tag "$TAG" --cache "$TMP_CACHE_DIR" --output "$OUTPUT_FILE" --force
--no-tests; then echo a warning including the tag and any stderr info and
continue to the next tag (or capture $?) — this preserves the existing
retry/continue pattern and prevents one bad tag from stopping the whole script.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ccb6086e-1a65-4dc3-887f-8195f206a610

📥 Commits

Reviewing files that changed from the base of the PR and between cd40bc8 and 7d6b205.

📒 Files selected for processing (2)
  • generate_fun_data.sh
  • priv/supported_functions.data

Comment thread generate_fun_data.sh Outdated
@UncleGrumpy UncleGrumpy force-pushed the WIP branch 2 times, most recently from 85ed636 to 5ec61ef Compare May 17, 2026 02:36
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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.

Inline comments:
In @.github/workflows/code_quality_check.yaml:
- Around line 29-33: The "Install shellcheck" CI step can hang on prompts;
update the run block for that step to perform a non-interactive install by
setting DEBIAN_FRONTEND=noninteractive and passing automatic flags to apt-get
(e.g., use apt-get install -y --no-install-recommends and combine update/install
into a single command). Modify the workflow step named "Install shellcheck" (the
run section that currently calls "sudo apt-get update" and "sudo apt-get install
shellcheck") to use those non-interactive flags so the CI step is deterministic.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0851e993-c00b-49b7-a0f3-8dc6e35b0e67

📥 Commits

Reviewing files that changed from the base of the PR and between 7d6b205 and 5ec61ef.

📒 Files selected for processing (3)
  • .github/workflows/code_quality_check.yaml
  • generate_fun_data.sh
  • priv/supported_functions.data
✅ Files skipped from review due to trivial changes (1)
  • priv/supported_functions.data
🚧 Files skipped from review as they are similar to previous changes (1)
  • generate_fun_data.sh

Comment thread .github/workflows/code_quality_check.yaml
Eliminate all bashisms, and include the latest function data updates generated
by generate_fun_data.sh.

Signed-off-by: Winford <winford@object.stream>
…a.sh

Replace the hard-coded list of release tags to scan with a programmatically
generated list, only including the most recent pre-release tag for any not yet
released versions.

Replace the hard-coded use of "release-0.7" with code to determine the latest
release-X.X branch at runtime.

Signed-off-by: Winford <winford@object.stream>
@UncleGrumpy
Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 17, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@UncleGrumpy UncleGrumpy merged commit 95318de into main May 17, 2026
8 checks passed
@UncleGrumpy UncleGrumpy deleted the WIP branch May 17, 2026 03:40
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