This repository was archived by the owner on Oct 6, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
[WIP] Add e2e test example #128
Draft
ilopezluna
wants to merge
10
commits into
main
Choose a base branch
from
add-e2e-test
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3c146be
Add e2e test example
ilopezluna d4b76ca
Adds Github workflow
ilopezluna acb7170
Potential fix for code scanning alert no. 5: Workflow does not contai…
ilopezluna 69e9694
Install docker model plugin in Windows
ilopezluna 2a77ea5
Make the env var PLUGIN_DIR visible to make
ilopezluna 9a54dc3
Override binary name
ilopezluna 1192aeb
Override plugin name
ilopezluna 030a444
Skip setup docker step on windows to check if docker is already setup…
ilopezluna 7ebd270
Disable Windows tests as we need to build a Windows-based DMR image f…
ilopezluna 42ef67b
Adds macOS runner
ilopezluna File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
name: E2E Shell Tests | ||
|
||
on: | ||
push: | ||
workflow_dispatch: | ||
inputs: | ||
test_model: | ||
description: "Model to test with" | ||
required: false | ||
default: "ai/smollm2" | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
e2e-shell-tests: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false # Continue other tests even if one fails | ||
matrix: | ||
include: | ||
# Linux shells | ||
- os: ubuntu-latest | ||
shell-name: bash | ||
shell-type: bash | ||
test-script: ./e2e/shells/bash_test.sh | ||
|
||
- os: ubuntu-latest | ||
shell-name: zsh | ||
shell-type: bash | ||
test-script: ./e2e/shells/zsh_test.sh | ||
|
||
# Windows shells | ||
- os: windows-latest | ||
shell-name: cmd | ||
shell-type: cmd | ||
test-script: e2e\shells\cmd_test.bat | ||
|
||
- os: windows-latest | ||
shell-name: git-bash | ||
shell-type: bash | ||
test-script: ./e2e/shells/mintty_test.sh | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: go.mod | ||
cache: true | ||
|
||
# Cross-platform Docker setup | ||
- name: Set up Docker | ||
uses: docker/setup-docker-action@v4 | ||
Check warning on line 56 in .github/workflows/e2e-tests.yml
|
||
|
||
if: runner.os != 'Windows' | ||
|
||
- name: Install model-cli as Docker plugin (Linux/macOS) | ||
if: runner.os != 'Windows' | ||
shell: bash | ||
run: | | ||
echo "Installing model-cli as Docker plugin..." | ||
make install | ||
echo "Installation completed successfully" | ||
|
||
- name: Install model-cli as Docker plugin (Windows) | ||
if: runner.os == 'Windows' | ||
run: | | ||
mkdir "%ProgramData%\Docker\cli-plugins" || echo already exists | ||
make PLUGIN_NAME=docker-model.exe install PLUGIN_DIR="%ProgramData%\Docker\cli-plugins" | ||
dir "%ProgramData%\Docker\cli-plugins" | ||
shell: cmd | ||
|
||
- name: Test docker model version | ||
shell: bash | ||
run: | | ||
echo "Testing docker model version command..." | ||
docker model version | ||
|
||
# Verify the command returns successfully | ||
if [ $? -eq 0 ]; then | ||
echo "✅ docker model version command works correctly" | ||
else | ||
echo "❌ docker model version command failed" | ||
exit 1 | ||
fi | ||
|
||
- name: Test model pull and run | ||
shell: bash | ||
run: | | ||
MODEL="${{ github.event.inputs.test_model || 'ai/smollm2' }}" | ||
echo "Testing with model: $MODEL" | ||
|
||
# Test model pull | ||
echo "Pulling model..." | ||
docker model pull "$MODEL" | ||
|
||
if [ $? -eq 0 ]; then | ||
echo "✅ Model pull successful" | ||
else | ||
echo "❌ Model pull failed" | ||
exit 1 | ||
fi | ||
|
||
# Test basic model run (with timeout to avoid hanging) | ||
echo "Testing docker model run..." | ||
if [ "$RUNNER_OS" = "Windows" ]; then | ||
# Windows doesn't have timeout command, use PowerShell | ||
powershell -Command "& { Start-Process -FilePath 'docker' -ArgumentList 'model', 'run', '$MODEL', 'Give me a fact about whales.' -Wait -TimeoutSec 60 }" || { | ||
exit_code=$? | ||
if [ $exit_code -eq 1 ]; then | ||
echo "✅ Model run test completed (timed out as expected for non-interactive test)" | ||
else | ||
echo "❌ Model run failed with exit code: $exit_code" | ||
exit 1 | ||
fi | ||
} | ||
else | ||
timeout 60s docker model run "$MODEL" "Give me a fact about whales." || { | ||
exit_code=$? | ||
if [ $exit_code -eq 124 ]; then | ||
echo "✅ Model run test completed (timed out as expected for non-interactive test)" | ||
else | ||
echo "❌ Model run failed with exit code: $exit_code" | ||
exit 1 | ||
fi | ||
} | ||
fi | ||
|
||
# Shell-specific setup | ||
- name: Install Zsh (Linux) | ||
if: matrix.shell-name == 'zsh' && runner.os == 'Linux' | ||
shell: bash | ||
run: sudo apt-get update && sudo apt-get install -y zsh | ||
|
||
# Shell-specific test execution | ||
- name: Run Bash E2E Tests | ||
if: matrix.shell-name == 'bash' | ||
shell: bash | ||
run: | | ||
chmod +x ${{ matrix.test-script }} | ||
${{ matrix.test-script }} | ||
|
||
- name: Run Zsh E2E Tests | ||
if: matrix.shell-name == 'zsh' | ||
shell: bash | ||
run: | | ||
chmod +x ${{ matrix.test-script }} | ||
zsh ${{ matrix.test-script }} | ||
|
||
- name: Run CMD E2E Tests | ||
if: matrix.shell-name == 'cmd' | ||
shell: cmd | ||
run: ${{ matrix.test-script }} | ||
|
||
- name: Run Git Bash E2E Tests | ||
if: matrix.shell-name == 'git-bash' | ||
shell: bash | ||
run: | | ||
chmod +x ${{ matrix.test-script }} | ||
${{ matrix.test-script }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
MODEL NAME PARAMETERS QUANTIZATION ARCHITECTURE MODEL ID CREATED SIZE | ||
ai/smollm2 361.82 M IQ2_XXS/Q4_K_M llama 354bf30d0aa3 3 months ago 256.35 MiB |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
#!/bin/bash | ||
|
||
# Bash-specific e2e test for docker model list command with fixture validation | ||
# This script validates the output against the expected fixture | ||
|
||
set -e | ||
|
||
TEST_MODEL="ai/smollm2" | ||
FAILED_TESTS=0 | ||
TOTAL_TESTS=0 | ||
|
||
# Colors for output | ||
RED='\033[0;31m' | ||
GREEN='\033[0;32m' | ||
NC='\033[0m' # No Color | ||
|
||
log_info() { | ||
echo -e "${GREEN}[INFO]${NC} $1" | ||
} | ||
|
||
log_success() { | ||
echo -e "${GREEN}[PASS]${NC} $1" | ||
} | ||
|
||
log_error() { | ||
echo -e "${RED}[FAIL]${NC} $1" | ||
FAILED_TESTS=$((FAILED_TESTS + 1)) | ||
} | ||
|
||
# Load fixture file and normalize lines | ||
load_fixture() { | ||
local fixture_path="$1" | ||
if [ ! -f "$fixture_path" ]; then | ||
log_error "Fixture file not found: $fixture_path" | ||
return 1 | ||
fi | ||
# Remove trailing whitespace | ||
sed 's/[[:space:]]*$//' "$fixture_path" | ||
} | ||
|
||
run_test_with_fixture_validation() { | ||
local test_name="$1" | ||
local command="$2" | ||
local fixture_path="$3" | ||
local expected_exit_code="${4:-0}" | ||
|
||
TOTAL_TESTS=$((TOTAL_TESTS + 1)) | ||
log_info "Running test: $test_name" | ||
|
||
# Load expected output from fixture | ||
expected_output=$(load_fixture "$fixture_path") | ||
|
||
if [ $? -ne 0 ]; then | ||
log_error "$test_name - Failed to load fixture" | ||
return 1 | ||
fi | ||
|
||
# Run command and capture output and exit code | ||
set +e | ||
output=$(eval "$command" 2>&1) | ||
exit_code=$? | ||
set -e | ||
|
||
# Normalize output: remove leading/trailing blank lines and trailing spaces | ||
normalized_output=$(echo "$output" | sed 's/[[:space:]]*$//') | ||
|
||
if [ $exit_code -eq $expected_exit_code ] && [ "$normalized_output" = "$expected_output" ]; then | ||
log_success "$test_name" | ||
return 0 | ||
else | ||
log_error "$test_name" | ||
echo "Command: $command" | ||
echo "Expected exit code: $expected_exit_code, got: $exit_code" | ||
echo "Expected output:" | ||
echo "$expected_output" | ||
echo "Actual normalized output:" | ||
echo "$normalized_output" | ||
return 1 | ||
fi | ||
} | ||
|
||
# Check prerequisites | ||
log_info "Checking prerequisites..." | ||
|
||
# Ensure we're running from the correct directory | ||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" | ||
cd "$PROJECT_ROOT" | ||
|
||
# Check if docker model is available | ||
if ! command -v docker &> /dev/null; then | ||
log_error "docker command not found" | ||
exit 1 | ||
fi | ||
|
||
# Check if model runner is running | ||
if ! docker model status | grep -q "Docker Model Runner is running"; then | ||
log_error "Docker Model Runner is not running" | ||
exit 1 | ||
fi | ||
|
||
# Check if test model is available | ||
if ! docker model list | grep -q "$TEST_MODEL"; then | ||
log_info "Test model $TEST_MODEL not found, pulling..." | ||
docker model pull "$TEST_MODEL" | ||
fi | ||
|
||
log_info "Starting fixture validation test..." | ||
|
||
# Test: Fixture format validation | ||
run_test_with_fixture_validation "Fixture format validation" \ | ||
"docker model list" \ | ||
"e2e/fixtures/table_format/with_models.txt" | ||
|
||
# Summary | ||
echo | ||
log_info "Test Summary:" | ||
echo "Total tests: $TOTAL_TESTS" | ||
echo "Failed tests: $FAILED_TESTS" | ||
echo "Passed tests: $((TOTAL_TESTS - FAILED_TESTS))" | ||
|
||
if [ $FAILED_TESTS -eq 0 ]; then | ||
log_success "Fixture validation test passed!" | ||
exit 0 | ||
else | ||
log_error "$FAILED_TESTS tests failed" | ||
exit 1 | ||
fi |
Empty file.
Empty file.
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.