Skip to content

ARO-26543: add ShellSpec and shfmt validation for first-wave bash scripts - #4959

Open
Affinito Alessandro (tuxerrante) wants to merge 3 commits into
masterfrom
tuxerrante/ARO-26543/bash-unit-tests-followup
Open

ARO-26543: add ShellSpec and shfmt validation for first-wave bash scripts#4959
Affinito Alessandro (tuxerrante) wants to merge 3 commits into
masterfrom
tuxerrante/ARO-26543/bash-unit-tests-followup

Conversation

@tuxerrante

@tuxerrante Affinito Alessandro (tuxerrante) commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Which issue this PR addresses:

Part of ARO-26543

What this PR does / why we need it:

This is the independent master-based ShellSpec + shfmt slice.

  • add .editorconfig, make fmt-bash, make validate-fmt-bash, make unit-test-bash, and make validate-bash for the new bash test assets;
  • add the containerized ShellSpec runner and dedicated ci-bash workflow for formatting plus unit tests;
  • add first-wave behavioral specs for VMSS helpers and entrypoints, backupandfixetcd.sh, and the dnsmasq templates;
  • align the dnsmasq restart template shebang with the bash-specific syntax the hook already uses.

This PR intentionally does not carry the shellcheck gate for existing runtime scripts; that stays in #4801 so both PRs remain independently reviewable on top of master.

Test plan for issue:

  • make validate-fmt-bash
  • make unit-test-bash
  • make validate-gh-actions

Is there any documentation that needs to be updated for this PR?

Yes. docs/testing.md documents the make unit-test-bash entrypoint and the containerized local workflow.

How do you know this will function as expected in production?

This PR is primarily test and CI infrastructure. The runtime-facing change is the dnsmasq shebang alignment, while the new ShellSpec layer adds repeatable regression coverage for the first-wave bash assets before they reach higher-cost VM or E2E validation.

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

Please rebase pull request.

1 similar comment
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

Please rebase pull request.

@tuxerrante Affinito Alessandro (tuxerrante) changed the title test(bash): add shellspec coverage for first-wave scripts ARO-26543: add ShellSpec coverage for first-wave bash scripts Jul 7, 2026
Introduce a containerized ShellSpec runner, shfmt checks for the new bash test assets, and first-wave behavioral coverage for the VMSS, etcd recovery, and dnsmasq shell paths without depending on the separate shellcheck PR.
@tuxerrante
Affinito Alessandro (tuxerrante) force-pushed the tuxerrante/ARO-26543/bash-test-coverage branch from 5e8d1f7 to 53ef522 Compare July 8, 2026 07:13
@tuxerrante
Affinito Alessandro (tuxerrante) force-pushed the tuxerrante/ARO-26543/bash-unit-tests-followup branch from 513d9c6 to d28ca9d Compare July 8, 2026 07:13
@tuxerrante
Affinito Alessandro (tuxerrante) changed the base branch from tuxerrante/ARO-26543/bash-test-coverage to master July 8, 2026 07:13
@github-actions github-actions Bot removed the needs-rebase branch needs a rebase label Jul 8, 2026
@tuxerrante Affinito Alessandro (tuxerrante) changed the title ARO-26543: add ShellSpec coverage for first-wave bash scripts ARO-26543: add ShellSpec and shfmt validation for first-wave bash scripts Jul 8, 2026
@tuxerrante

Copy link
Copy Markdown
Collaborator Author

These two PRs are now independently based on master and are no longer stacked.

  • #4801 is only the shellcheck gate plus the shellcheck-driven fixes for the first-wave runtime bash scripts.
  • #4959 is only the ShellSpec + shfmt layer, runner/docs, and the behavioral specs.

That split is intentional so each PR can be reviewed on its own.

@tuxerrante
Affinito Alessandro (tuxerrante) marked this pull request as ready for review July 8, 2026 08:55
Copilot AI review requested due to automatic review settings July 8, 2026 08:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 introduces a first slice of Bash-focused CI and unit testing using ShellSpec plus shfmt formatting validation, along with initial behavioral specs for selected VMSS/bootstrap scripts and dnsmasq templates. It adds local make entrypoints and a dedicated GitHub Actions workflow, and aligns a dnsmasq dispatcher template shebang with its bash-specific syntax.

Changes:

  • Add ShellSpec-based unit tests and supporting harness/helpers for first-wave Bash assets.
  • Add shfmt-based formatting targets (fmt-bash, validate-fmt-bash, validate-bash) and a ci-bash workflow.
  • Update dnsmasq restart dispatcher template shebang to #!/bin/bash and document the new bash unit-test entrypoint.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/bash/spec/vmss_helpers_spec.sh Adds ShellSpec coverage for VMSS utility scripts (common/packages/system/services).
test/bash/spec/vmss_entrypoints_spec.sh Adds ShellSpec coverage for VMSS entrypoint scripts and devproxy setup behavior.
test/bash/spec/unit_test_bash_runner_spec.sh Tests the containerized bash test runner behavior (docker vs podman detection, report dir safety).
test/bash/spec/support/helpers.sh Provides test harness utilities for fixtures, mocks, and template extraction.
test/bash/spec/spec_helper.sh Adds ShellSpec helper lifecycle hooks and host-safety prechecks.
test/bash/spec/dnsmasq_templates_spec.sh Adds template rendering + behavior checks for dnsmasq hook templates.
test/bash/spec/backupandfixetcd_spec.sh Adds behavioral specs for backupandfixetcd.sh backup and peer-removal modes.
pkg/operator/controllers/dnsmasq/scripts/99-dnsmasq-restart.gotmpl Aligns dispatcher script shebang with bash syntax used by the template.
Makefile Adds bash formatting/test targets and shfmt file lists.
hack/unit-test-bash.sh Adds a containerized ShellSpec runner with docker/podman detection and safe report dir handling.
docs/testing.md Documents the new make unit-test-bash workflow and containerized runner behavior.
.shellspec Adds ShellSpec configuration for default path, helper dir, and bash shell selection.
.github/workflows/ci-bash.yml Adds CI job to run shfmt validation and bash unit tests on PRs and master.
.editorconfig Adds bash/shfmt formatting policy for *.sh.

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

Comment thread test/bash/spec/support/helpers.sh
Comment thread test/bash/spec/support/helpers.sh
Comment thread Makefile

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Comment thread test/bash/spec/support/helpers.sh Outdated
Comment thread hack/unit-test-bash.sh
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 10, 2026 07:23
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Comment thread hack/unit-test-bash.sh
Comment on lines +9 to +10
readonly shellspec_image="${BASH_TEST_IMAGE:-docker.io/shellspec/shellspec-debian:0.28.1}"
readonly default_report_base="${TMPDIR:-/tmp}/aro-bash-test-report"
Copilot AI review requested due to automatic review settings July 10, 2026 07:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Comment on lines +49 to +52
done

copy_fixture() {
local source_path="$1"
Comment on lines +22 to +29
ln -s "${MOCK_BIN}/podman" "${MOCK_BIN}/docker"

(
PATH="${MOCK_BIN}:${ORIGINAL_PATH}" \
BASH_TEST_REPORT_DIR="${TEST_ROOT}/report" \
bash "${REPO_ROOT}/hack/unit-test-bash.sh"
) 2>&1
}
Comment on lines +63 to +68
(
PATH="${MOCK_BIN}:${ORIGINAL_PATH}" \
BASH_TEST_REPORT_DIR="${TEST_ROOT}/report" \
bash "${REPO_ROOT}/hack/unit-test-bash.sh"
) 2>&1
}
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