-
Notifications
You must be signed in to change notification settings - Fork 234
add support for running bats in a container #1598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's GuideAdds support for running BATS tests inside a local container using Podman-in-Podman, including new Makefile targets and a container image, and introduces a --dri option in ramalama to toggle /dev/dri mounts in the generated stack, with related updates to system tests and container build scripts. Class diagram for updated ramalama stack and CLI optionsclassDiagram
class StackArgs {
dri: str = "on"
}
class Stack {
+args: StackArgs
+model_type: str
+model_path: str
+add_label(label)
+generate()
}
class CLI {
+runtime_options(parser, command)
}
Stack --> StackArgs
CLI ..> StackArgs : adds --dri option
Stack : generate() now conditionally mounts /dev/dri based on args.dri
Flow diagram for Makefile BATS-in-container targetsflowchart TD
bats-in-container --> bats-image
bats-image -->|if not exists| BuildBATSImage["podman build container-images/bats"]
bats-in-container -->|run| PodmanRunBATS["podman run bats:latest make bats"]
bats-nocontainer-in-container --> bats-image
bats-nocontainer-in-container -->|run| PodmanRunNoContainer["podman run bats:latest make bats-nocontainer"]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @mikebonnet, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request significantly enhances our testing infrastructure by enabling BATS system tests to run within containers, addressing CI stability concerns. It also introduces a new command-line option to manage device mounting for better compatibility with containerized environments.
Highlights
- Containerized BATS Tests: I've added new Makefile targets (
bats-image
,bats-in-container
,bats-nocontainer-in-container
) and a dedicated container image (container-images/bats
) to enable running BATS system tests within a containerized environment, including support for Podman-in-Podman. - New
--dri
Option forramalama serve
: I've introduced a--dri
option toramalama serve --api llama-stack
to allow explicit control over mounting/dev/dri
into the container. This is crucial for environments like Podman-in-Podman where/dev/dri
mounting can cause conflicts. - CI/CD Improvement Prerequisite: These changes are a prerequisite for integrating BATS tests into Konflux CI, aiming to resolve existing out-of-space issues and improve test reliability.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @mikebonnet - I've reviewed your changes - here's some feedback:
- In ramalama/stack.py the volume_mounts and volumes strings are built via repeated concatenation, consider refactoring into a list or helper function to reduce duplication and improve readability.
- The bats-in-container and bats-nocontainer-in-container Makefile targets share nearly identical podman flags—extract those options into a variable to avoid drift between the two recipes.
- Defaulting BATS_IMAGE to “localhost/bats:latest” can lead to non‐reproducible builds; consider making the tag configurable or pinning to a specific version/digest.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In ramalama/stack.py the volume_mounts and volumes strings are built via repeated concatenation, consider refactoring into a list or helper function to reduce duplication and improve readability.
- The bats-in-container and bats-nocontainer-in-container Makefile targets share nearly identical podman flags—extract those options into a variable to avoid drift between the two recipes.
- Defaulting BATS_IMAGE to “localhost/bats:latest” can lead to non‐reproducible builds; consider making the tag configurable or pinning to a specific version/digest.
## Individual Comments
### Comment 1
<location> `container_build.sh:212` </location>
<code_context>
for i in ./container-images/*; do
i=$(basename "$i")
# skip these directories
- if [[ "$i" =~ ^(scripts|ramalama)$ ]]; then
+ if [[ "$i" =~ ^(scripts|ramalama|bats)$ ]]; then
continue
fi
</code_context>
<issue_to_address>
Excluding 'bats' from processing may need a comment for future maintainers.
If the reason for excluding 'bats' isn't documented, please add a brief explanation for clarity.
</issue_to_address>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds valuable support for running BATS tests in a container, which will improve CI reliability. The addition of the --dri
flag for configurable GPU device mounting is also a welcome enhancement.
I've provided a couple of suggestions: one to optimize the new test container's Containerfile
for better efficiency and a smaller image size, and another to fix a potential shell scripting bug in the entrypoint.sh
. Overall, this is a great contribution.
7673e02
to
84a3a0a
Compare
LGTM but we should fix the CI errors first :) |
23d7216
to
b6fddea
Compare
Add the --dri option to disable mounting /dev/dri into the container when running "ramalama serve --api llama-stack". Update bats test to pass "--dri off". Signed-off-by: Mike Bonnet <[email protected]>
b6fddea
to
bb80626
Compare
Add a new "bats" container which is configured to run the bats tests. The container supports running the standard bats test suite (container-in-container) as well as the "--nocontainer" tests. Add two new Makefile targets for running the bats container via podman. Signed-off-by: Mike Bonnet <[email protected]>
Signed-off-by: Mike Bonnet <[email protected]>
bb80626
to
4f47948
Compare
LGTM |
The
bats-in-container
andbats-nocontainer-in-container
will run thebats
tests in a local container. In the case ofbats-container
, this uses podman-in-podman to run the test suite as realistically as possible.Also includes a new
--dri
option toramalama serve --api llama-stack
, to allow disabling mounting/dev/dri
into the container. This is required for podman-in-podman to work.This is a prerequisite to getting
bats
tests running in Konflux on each pull request, and working around the out-of-space issues in the current CI setup.Summary by Sourcery
Add support for running the BATS test suite inside a Podman container and make DRI mounting configurable for llama-stack containers.
New Features:
Enhancements:
Tests: