Skip to content

Physical modularity: extract add-submodules.yml inline logic to shared shell library#42

Merged
wpak-ai merged 3 commits into
cppalliance:masterfrom
whisper67265:fix/extract-shell-library
Jun 30, 2026
Merged

Physical modularity: extract add-submodules.yml inline logic to shared shell library#42
wpak-ai merged 3 commits into
cppalliance:masterfrom
whisper67265:fix/extract-shell-library

Conversation

@whisper67265

@whisper67265 whisper67265 commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Close #34.

Summary by CodeRabbit

  • New Features
    • Added shared workflow helpers to centralize submodule syncing and translation workspace setup.
    • Enabled automatic library submodule discovery from upstream .gitmodules when explicit inputs aren’t provided.
  • Bug Fixes
    • Improved submodule failure tracking and exit-code precedence across sync and translation finalization.
    • Updated workflows to emit updated-submodule output only when the combined run succeeds.
  • Tests
    • Added Bats tests covering library submodule name extraction, batch processing behavior, exit-code rules, and workspace directory creation.
  • Chores
    • Extended ShellCheck linting to include the new shared workflow script.

@coderabbitai

coderabbitai Bot commented Jun 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 12445158-de02-4e80-b6c1-2d39737b9d67

📥 Commits

Reviewing files that changed from the base of the PR and between 91596ad and ba64644.

📒 Files selected for processing (2)
  • .github/workflows/assets/submodule_ops.sh
  • tests/test_submodule_ops.bats
💤 Files with no reviewable changes (1)
  • .github/workflows/assets/submodule_ops.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/test_submodule_ops.bats

📝 Walkthrough

Walkthrough

Inline submodule orchestration is extracted into .github/workflows/assets/submodule_ops.sh, and the workflows now source shared helpers for workspace setup, submodule resolution, processing, and exit-code handling. Tests and ShellCheck coverage were added for the new script.

Changes

Shared submodule orchestration refactor

Layer / File(s) Summary
Workspace and submodule resolution
.github/workflows/assets/submodule_ops.sh
Introduces workspace setup, gitmodules parsing, remote gitmodules fetch, submodule-name resolution, and translation branch preparation helpers.
Batch processing and entrypoint
.github/workflows/assets/submodule_ops.sh
Adds submodule batch processing, combined rc handling, and the add_submodules_main entry point.
Workflow delegation, tests, and lint
.github/workflows/add-submodules.yml, .github/workflows/start-translation.yml, tests/helpers/common.bash, tests/test_submodule_ops.bats, scripts/lint.sh
Workflows source the shared helpers and replace inline logic, the test helper loads the new script, the Bats suite covers helper behavior, and ShellCheck now includes the asset script.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • henry0816191
  • wpak-ai

Poem

🐇 Hop, the scripts are neatly spun,
One shared lib to rule them all has won.
Submodules march, the tests all cheer,
ShellCheck hops in without a fear.
The rabbit beams: “Done!” in the moonlit glow ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% 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 title clearly summarizes the main change: extracting add-submodules workflow logic into a shared shell library.
Linked Issues check ✅ Passed The changes satisfy #34 by delegating add-submodules, reusing helpers in start-translation, adding bats coverage, and updating shellcheck targets.
Out of Scope Changes check ✅ Passed The modifications stay within the shared-shell-library refactor and its supporting tests and lint updates.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
tests/test_submodule_ops.bats (2)

101-110: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add the mixed precedence case for exit-code composition.

The suite checks submodule_fatal and finalize_rc separately, but not together. The helper’s contract is that a non-zero finalize code overrides the batch fatal code, so this needs one explicit test.

Proposed follow-up
 `@test` "combine_batch_and_finalize_rc: finalize rc wins when non-zero" {
   submodule_fatal=0
   run combine_batch_and_finalize_rc 3
   [ "$status" -eq 3 ]
 }
+
+@test "combine_batch_and_finalize_rc: finalize rc overrides submodule_fatal" {
+  submodule_fatal=2
+  run combine_batch_and_finalize_rc 3
+  [ "$status" -eq 3 ]
+}
🤖 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 `@tests/test_submodule_ops.bats` around lines 101 - 110, Add a new test in
combine_batch_and_finalize_rc coverage that exercises the mixed precedence case
where both submodule_fatal and finalize_rc are set; use the
combine_batch_and_finalize_rc helper to verify that a non-zero finalize_rc takes
precedence over the batch fatal exit code. Place it alongside the existing
combine_batch_and_finalize_rc tests in tests/test_submodule_ops.bats so the
contract is explicitly covered.

72-87: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert the fatal-path return code too.

This test locks in the summary buckets, but not the non-zero status that process_submodule_list is supposed to emit when any processor returns 2. A regression there would still pass this test while changing workflow control flow.

Proposed follow-up
 `@test` "process_submodule_list: records updates and fatals by exit code" {
   stub_processor() {
     case "$1" in
       ok) return 0 ;;
       skip) return 1 ;;
       fail) return 2 ;;
     esac
   }

   process_submodule_list stub_processor ok skip fail
   [ "${`#UPDATES`[@]}" -eq 1 ]
   [ "${UPDATES[0]}" = "ok" ]
   [ "${`#SUBMODULE_FATAL`[@]}" -eq 1 ]
   [ "${SUBMODULE_FATAL[0]}" = "fail" ]
   [ "$submodule_fatal" -eq 1 ]
 }
+
+@test "process_submodule_list: returns non-zero when any submodule is fatal" {
+  stub_processor() {
+    case "$1" in
+      fail) return 2 ;;
+      *) return 0 ;;
+    esac
+  }
+
+  set +e
+  process_submodule_list stub_processor ok fail
+  status=$?
+  set -e
+
+  [ "$status" -ne 0 ]
+}
🤖 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 `@tests/test_submodule_ops.bats` around lines 72 - 87, The
process_submodule_list test covers the updates and fatal buckets but does not
assert the overall non-zero exit status when stub_processor returns 2. Update
the existing test case to capture and check the return code from
process_submodule_list, alongside the current UPDATES, SUBMODULE_FATAL, and
submodule_fatal assertions, so the fatal-path control flow is locked in.
🤖 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/assets/submodule_ops.sh:
- Around line 107-108: The final success path in process_submodule_list is
falling through with a nonzero status because the trailing conditional using
submodule_fatal only runs phase_err on failures and otherwise returns 1. Update
the end of the batch handling in process_submodule_list so it explicitly returns
success when no submodule failures occurred, while still calling phase_err for
the submodule_fatal error case, ensuring callers under set -e do not abort
before finalization.

---

Nitpick comments:
In `@tests/test_submodule_ops.bats`:
- Around line 101-110: Add a new test in combine_batch_and_finalize_rc coverage
that exercises the mixed precedence case where both submodule_fatal and
finalize_rc are set; use the combine_batch_and_finalize_rc helper to verify that
a non-zero finalize_rc takes precedence over the batch fatal exit code. Place it
alongside the existing combine_batch_and_finalize_rc tests in
tests/test_submodule_ops.bats so the contract is explicitly covered.
- Around line 72-87: The process_submodule_list test covers the updates and
fatal buckets but does not assert the overall non-zero exit status when
stub_processor returns 2. Update the existing test case to capture and check the
return code from process_submodule_list, alongside the current UPDATES,
SUBMODULE_FATAL, and submodule_fatal assertions, so the fatal-path control flow
is locked in.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1c8b0ae7-3c07-453f-bb0b-2c34cd11751e

📥 Commits

Reviewing files that changed from the base of the PR and between 0c2babb and a463339.

📒 Files selected for processing (6)
  • .github/workflows/add-submodules.yml
  • .github/workflows/assets/submodule_ops.sh
  • .github/workflows/start-translation.yml
  • scripts/lint.sh
  • tests/helpers/common.bash
  • tests/test_submodule_ops.bats

Comment thread .github/workflows/assets/submodule_ops.sh Outdated
Comment thread .github/workflows/assets/submodule_ops.sh
@whisper67265 whisper67265 requested a review from wpak-ai June 30, 2026 14:53
@wpak-ai wpak-ai merged commit a9a3f15 into cppalliance:master Jun 30, 2026
3 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.

Physical modularity: extract add-submodules.yml inline logic to shared shell library

3 participants