ARO-26543: add ShellSpec and shfmt validation for first-wave bash scripts - #4959
ARO-26543: add ShellSpec and shfmt validation for first-wave bash scripts#4959Affinito Alessandro (tuxerrante) wants to merge 3 commits into
Conversation
|
Please rebase pull request. |
1 similar comment
|
Please rebase pull request. |
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.
5e8d1f7 to
53ef522
Compare
513d9c6 to
d28ca9d
Compare
|
These two PRs are now independently based on
That split is intentional so each PR can be reviewed on its own. |
There was a problem hiding this comment.
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 aci-bashworkflow. - Update dnsmasq restart dispatcher template shebang to
#!/bin/bashand 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.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| readonly shellspec_image="${BASH_TEST_IMAGE:-docker.io/shellspec/shellspec-debian:0.28.1}" | ||
| readonly default_report_base="${TMPDIR:-/tmp}/aro-bash-test-report" |
| done | ||
|
|
||
| copy_fixture() { | ||
| local source_path="$1" |
| 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 | ||
| } |
| ( | ||
| PATH="${MOCK_BIN}:${ORIGINAL_PATH}" \ | ||
| BASH_TEST_REPORT_DIR="${TEST_ROOT}/report" \ | ||
| bash "${REPO_ROOT}/hack/unit-test-bash.sh" | ||
| ) 2>&1 | ||
| } |
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.
.editorconfig,make fmt-bash,make validate-fmt-bash,make unit-test-bash, andmake validate-bashfor the new bash test assets;ci-bashworkflow for formatting plus unit tests;backupandfixetcd.sh, and the dnsmasq templates;This PR intentionally does not carry the shellcheck gate for existing runtime scripts; that stays in
#4801so both PRs remain independently reviewable on top ofmaster.Test plan for issue:
make validate-fmt-bashmake unit-test-bashmake validate-gh-actionsIs there any documentation that needs to be updated for this PR?
Yes.
docs/testing.mddocuments themake unit-test-bashentrypoint 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.