Skip to content

Commit

Permalink
Merge pull request #435 from rhatdan/oci
Browse files Browse the repository at this point in the history
Make it easier to test-run manually
  • Loading branch information
rhatdan authored Nov 11, 2024
2 parents cb8db14 + 9d8d454 commit 752395d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ lint:
codespell:
codespell --dictionary=- -w

.PHONY: test-run
test-run:
_RAMALAMA_TEST=local RAMALAMA=$(CURDIR)/bin/ramalama bats -T test/system/030-run.bats
_RAMALAMA_OPTIONS=--nocontainer _RAMALAMA_TEST=local bats -T test/system/030-run.bats

.PHONY: validate
validate: codespell lint
ifeq ($(OS),Linux)
Expand Down
4 changes: 2 additions & 2 deletions ramalama/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ def setup_container(self, args):
"--security-opt=label=disable",
"--name",
name,
f"-v{args.store}:/var/lib/ramalama",
]

if sys.stdout.isatty() and sys.stdin.isatty():
Expand Down Expand Up @@ -171,6 +170,7 @@ def run_container(self, args, shortnames):
wd = find_working_directory()

conman_args += [
f"-v{args.store}:/var/lib/ramalama",
f"-v{os.path.realpath(sys.argv[0])}:/usr/bin/ramalama:ro",
f"-v{wd}:/usr/share/ramalama/ramalama:ro",
f"-v{short_file}:/usr/share/ramalama/shortnames.conf:ro,Z",
Expand Down Expand Up @@ -223,7 +223,7 @@ def exec_model_in_container(self, model_path, cmd_args, args):
return False

if model_path and os.path.exists(model_path):
conman_args += [f"--mount=type=bind,src={model_path},destination={mnt_file},rw=false,Z"]
conman_args += [f"--mount=type=bind,src={model_path},destination={mnt_file},rw=false"]
else:
conman_args += [f"--mount=type=image,src={self.model},destination={mnt_dir},rw=false,subpath=/models"]

Expand Down
11 changes: 4 additions & 7 deletions test/system/030-run.bats
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,9 @@ load helpers
is "$output" ".*${image} /bin/sh -c" "verify image name"
}

# FIXME no way to run this reliably without flakes in CI/CD system
#@test "ramalama run granite with prompt" {
# run_ramalama run --name foobar granite "How often to full moons happen"
# is "$output" ".*month" "should include some info about the Moon"
# run_ramalama list
# is "$output" ".*granite" "granite model should have been pulled"
#}
@test "ramalama run tiny with prompt" {
skip_if_notlocal
run_ramalama run --name foobar tiny "Write a 1 line poem"
}

# vim: filetype=sh
6 changes: 6 additions & 0 deletions test/system/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,12 @@ function skip_if_nocontainer() {
fi
}

function skip_if_notlocal() {
if [[ "${_RAMALAMA_TEST}" != "local" ]]; then
skip "Not supported unless --local"
fi
}

function skip_if_docker() {
if [[ "${_RAMALAMA_TEST_OPTS}" == "--engine=docker" ]]; then
skip "Not supported with ----engine=docker"
Expand Down

0 comments on commit 752395d

Please sign in to comment.