Skip to content

ci(openemr-cmd): add macOS leg to BATS matrix; fix bash 3.2 compat#785

Merged
kojiromike merged 1 commit into
openemr:masterfrom
kojiromike:ci-bats-macos-matrix
Jun 6, 2026
Merged

ci(openemr-cmd): add macOS leg to BATS matrix; fix bash 3.2 compat#785
kojiromike merged 1 commit into
openemr:masterfrom
kojiromike:ci-bats-macos-matrix

Conversation

@kojiromike
Copy link
Copy Markdown
Member

Summary

openemr-cmd is a host CLI developers run on their Macs, but its BATS workflow only ran on ubuntu-22.04. So macOS-portability bugs reached users with zero CI coverage — most recently the BSD realpath failure fixed manually in #783. This adds a macos-14 leg to the BATS matrix, where the script runs under macOS system bash 3.2, the sharpest portability risk.

Adding that leg immediately surfaced two real bash 3.2 incompatibilities, both fixed here:

  • openemr-cmd used ${RESP,,} (bash 4+ case-modification), which throws bad substitution under bash 3.2. Replaced with a [Yy] glob match in [[ ]], preserving the [Y/n] default-yes semantics. (Verified identical behavior on bash 3.2 and 5.)
  • Test harness sourced the script via process substitution (source <(head -n …)), which silently defines no functions under macOS bash 3.2. Switched the three sites (helpers.bash, helpers_pure.bats, state.bats) to eval "$(head -n …)".

The repo is public, so GitHub-hosted macOS minutes are free. The macOS leg is advisory for now (fail-fast: false, not branch-protection-required) and can be promoted to required later.

Test plan

  • Full openemr-cmd BATS suite passes 39/39 under system bash 3.2 (macOS-runner equivalent)
  • Full suite passes 39/39 under bash 5 (Linux-runner equivalent)
  • ${RESP,,}[Yy] glob verified semantically identical across both shells (empty→pull, y/Y→pull, else→skip)
  • Workflow YAML validates; helpers.bash and openemr-cmd shellcheck-clean
  • CI: confirm both ubuntu-22.04 and macos-14 legs go green

Copilot AI review requested due to automatic review settings June 6, 2026 02:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves openemr-cmd portability coverage by extending the BATS CI workflow to run on both Linux and macOS, ensuring the host CLI is tested under macOS’s system bash 3.2 (a common source of portability regressions).

Changes:

  • Add a macos-14 leg to the test-bats-openemr-cmd GitHub Actions matrix (with fail-fast: false).
  • Fix bash 3.2 incompatibility in openemr-cmd by replacing ${var,,} case-modification with a portable [Yy] glob match.
  • Update the BATS harness to avoid process substitution when “sourcing” function definitions, switching to eval "$(head -n …)".

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
utilities/openemr-cmd/openemr-cmd Bump version and replace bash-4-only ${RESP,,} usage with bash 3.2-compatible input handling.
tests/bats/openemr-cmd/state.bats Replace source <(head -n …) with eval "$(head -n …)" for macOS bash 3.2 compatibility.
tests/bats/openemr-cmd/helpers.bash Update OC_SCRIPT_FUNCS_END and switch function-definition loading to eval "$(head -n …)".
tests/bats/openemr-cmd/helpers_pure.bats Replace source <(head -n …) with eval "$(head -n …)" for macOS bash 3.2 compatibility.
.github/workflows/test-bats-openemr-cmd.yml Convert to an OS matrix including ubuntu-22.04 and macos-14.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

openemr-cmd is a host CLI users run on their Macs, but BATS only ran on
ubuntu-22.04 — so macOS portability bugs (e.g. the BSD realpath issue in
PR openemr#783) reached users with zero CI coverage. Add a macos-14 leg to the
BATS matrix, where the script runs under system bash 3.2.

That surfaced two real bash 3.2 incompatibilities:

- openemr-cmd used ${RESP,,} (bash 4+ case-modification), which throws
  "bad substitution" under macOS bash 3.2. Replace with a [Yy] glob
  match, preserving the [Y/n] default-yes semantics.
- The test harness sourced the script via process substitution
  (source <(head -n ...)), which silently defines no functions under
  macOS bash 3.2. Switch the three sites to eval "$(head -n ...)".

The repo is public, so GitHub-hosted macOS minutes are free. The macOS
leg is advisory for now (fail-fast: false, not branch-protection
required). Suite passes 39/39 under both bash 3.2 and bash 5.

Assisted-by: Claude Code
@kojiromike kojiromike force-pushed the ci-bats-macos-matrix branch from ce22320 to 1e2fbd0 Compare June 6, 2026 02:44
@kojiromike kojiromike merged commit 380105a into openemr:master Jun 6, 2026
9 checks passed
@kojiromike kojiromike deleted the ci-bats-macos-matrix branch June 6, 2026 02:45
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.

2 participants