Add BATS tests for image structure and runtime#33
Conversation
0588e4f to
1e18881
Compare
2ecc249 to
d1f4e57
Compare
There was a problem hiding this comment.
Pull request overview
This PR expands CI validation for the HAProxy Docker image by adding BATS-based image structure and runtime/integration tests, alongside workflow hardening/modernization and a developer Makefile to run common tasks locally.
Changes:
- Add BATS test suites for image structure verification and runtime/backend discovery checks.
- Update CI workflow to pin most actions, replace a third-party find/replace action with shell+
sed, install test deps via Homebrew, and run the new BATS tests. - Introduce a Makefile to simplify building, testing, and basic container operations.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
.github/workflows/build_and_test.yml |
Pins actions (mostly), replaces find/replace action with sed, installs deps, pulls image, runs BATS tests, and modernizes some Docker Compose usage. |
tests/image_structure.bats |
Adds container-image “baked-in” checks (binaries, files, env, exposed ports, basic HAProxy validation). |
tests/runtime.bats |
Adds runtime/integration tests that start the container, check processes and /stats, and validate backend discovery via docker-gen. |
Makefile |
Adds local targets for build/test (BATS), config validation, and starting/stopping the stack. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
This PR hardens and modernizes the CI workflow while adding a BATS-based test suite to validate the built HAProxy Docker image’s structure and runtime behavior.
Changes:
- Pin GitHub Actions to commit SHAs, replace a third-party find/replace action with
sed, and modernize CI steps (incl.docker compose). - Add BATS tests for image structure (
tests/image_structure.bats) and runtime/integration behavior (tests/runtime.bats). - Introduce a Makefile to streamline local image builds and test execution.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
.github/workflows/build_and_test.yml |
Pins actions, replaces find/replace action with sed, installs BATS via Homebrew, pulls the built image, and runs the new BATS suites in CI. |
Makefile |
Adds developer-friendly targets for building the image and running BATS test subsets, plus common stack utilities. |
tests/image_structure.bats |
Validates expected binaries, baked-in files/config, metadata (exposed ports), and basic HAProxy functionality. |
tests/runtime.bats |
Starts a long-running container and performs runtime checks, stats endpoint validation, and backend discovery integration tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Adds a BATS-based test suite for validating the built HAProxy image (structure + runtime behavior) and hardens/modernizes the CI workflow by pinning actions, simplifying tag replacement, and running the new tests in CI.
Changes:
- Add BATS tests for image structure validation and runtime/integration behavior.
- Update CI workflow to pin actions by SHA, replace a third-party find/replace action with
sed, and run BATS tests against the built image. - Add a
Makefileto streamline local build/test workflows.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
.github/workflows/build_and_test.yml |
Pins actions, replaces find/replace with shell, installs deps via Homebrew, pulls built image, runs BATS tests, modernizes compose usage. |
Makefile |
Adds local developer targets for build, BATS test runs, config validation, compose up/down, etc. |
tests/image_structure.bats |
Adds container/image “baked-in” checks (binaries, required files, env, exposed ports). |
tests/runtime.bats |
Adds runtime checks (container health, processes, stats endpoint) and backend discovery integration tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
This PR hardens and modernizes CI while adding BATS-based validation for the published Docker image (both “built image structure” and “running container behavior”), plus a Makefile to simplify local workflows.
Changes:
- Pin GitHub Actions to commit SHAs and replace a third-party find/replace action with a native
find+sedimplementation. - Add BATS test suites for image structure and runtime/integration behavior (including backend discovery via docker-gen + HAProxy stats).
- Add a Makefile to build the image and run the new test suites locally.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
.github/workflows/build_and_test.yml |
Pins actions by SHA, installs BATS in CI, pulls built image, and runs the new BATS suites. |
Makefile |
Adds local targets for building, testing (BATS), config validation, and compose lifecycle. |
tests/image_structure.bats |
Validates image contents/metadata (binaries, files, env, exposed ports). |
tests/runtime.bats |
Runs a long-lived container and exercises runtime behavior (process checks, /stats, backend discovery). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This pull request introduces several improvements to the CI workflow and adds a comprehensive test suite for the Docker image using BATS. The most significant changes include pinning GitHub Actions to specific commit SHAs for improved security, replacing a third-party find-and-replace action with a native shell implementation, and adding new BATS-based image and runtime tests. Additionally, a new
Makefileis included to streamline common development and test tasks.CI/CD Workflow Improvements:
.github/workflows/build_and_test.ymlare now pinned to specific commit SHAs, increasing security and reproducibility. (actions/checkout,docker/metadata-action,docker/setup-qemu-action,docker/setup-buildx-action,docker/login-action,docker/build-push-action) [1] [2] [3]ubuntu-latestinstead of a fixed version, and minor shell quoting improvements were made.jacobtomlinson/gha-find-replaceaction for updating image tags in example files has been replaced with an inline shell script usingsed, removing a dependency and simplifying the workflow.docker composeCLI instead of the legacydocker-compose.Testing Enhancements:
Makefilewith targets for building the image, running BATS tests (all, structure-only, runtime-only), validating HAProxy config, starting/stopping the stack, and cleaning up images, making local development and testing easier.tests/image_structure.bats, a suite of tests verifying the presence of binaries, files, configuration, and exposed ports in the image.tests/runtime.bats, a suite of runtime and integration tests that start containers, check HAProxy and docker-gen processes, verify the stats endpoint, and test backend discovery logic.Minor Workflow and Test Adjustments:
-Fflag for fixed string matching. [1] [2]Summary of Most Important Changes:
1. CI/CD Workflow Hardening & Modernization
.github/workflows/build_and_test.ymlare now pinned to commit SHAs; replaced deprecated/third-party actions with native shell and modernized Docker Compose usage. [1] [2] [3] [4] [5]2. Test Suite Expansion
tests/image_structure.batsfor image structure validation andtests/runtime.batsfor runtime and integration testing using BATS. [1] [2]3. Developer Experience Improvements
Makefilewith targets for building, testing, and managing the Docker image and test runs, simplifying local development workflows.4. Workflow Reliability Enhancements
5. Homebrew and Package Management