fix: Compose generator should detect duplicate service names at generate-time (#850)
Some checks failed
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline failed
ci/woodpecker/pr/smoke-init Pipeline failed

This commit is contained in:
Agent 2026-04-19 11:16:44 +00:00
parent eb19aa6c84
commit 4ca768dd3a
3 changed files with 373 additions and 2 deletions

View file

@ -30,7 +30,8 @@ cleanup() {
rm -rf "$MOCK_BIN" /tmp/smoke-test-repo \
"${FACTORY_ROOT}/projects/smoke-repo.toml" \
/tmp/smoke-claude-shared /tmp/smoke-home-claude \
/tmp/smoke-env-before-rerun /tmp/smoke-env-before-dryrun
/tmp/smoke-env-before-rerun /tmp/smoke-env-before-dryrun \
"${FACTORY_ROOT}/docker-compose.yml"
# Restore .env only if we created the backup
if [ -f "${FACTORY_ROOT}/.env.smoke-backup" ]; then
mv "${FACTORY_ROOT}/.env.smoke-backup" "${FACTORY_ROOT}/.env"
@ -423,6 +424,50 @@ export CLAUDE_SHARED_DIR="$ORIG_CLAUDE_SHARED_DIR"
export CLAUDE_CONFIG_DIR="$ORIG_CLAUDE_CONFIG_DIR"
rm -rf /tmp/smoke-claude-shared /tmp/smoke-home-claude
# ── 8. Test duplicate service name detection ──────────────────────────────
echo "=== 8/8 Testing duplicate service name detection ==="
# Clean up for duplicate test
rm -f "${FACTORY_ROOT}/projects/duplicate-test.toml"
rm -f "${FACTORY_ROOT}/docker-compose.yml"
# Create a TOML that would conflict with ENABLE_LLAMA_AGENT
cat > "${FACTORY_ROOT}/projects/duplicate-test.toml" <<'TOMLEOF'
name = "duplicate-test"
description = "Test project for duplicate service detection"
[ci]
woodpecker_repo_id = "999"
[agents.llama]
base_url = "http://localhost:8080"
model = "qwen:latest"
roles = ["dev"]
forge_user = "llama-bot"
TOMLEOF
# Run disinto init with ENABLE_LLAMA_AGENT=1
# This should fail because [agents.llama] conflicts with ENABLE_LLAMA_AGENT
export ENABLE_LLAMA_AGENT="1"
export FORGE_URL="http://localhost:3000"
export SMOKE_FORGE_URL="$FORGE_URL"
export FORGE_ADMIN_PASS="smoke-test-password-123"
export SKIP_PUSH=true
if bash "${FACTORY_ROOT}/bin/disinto" init \
"duplicate-test" \
--bare --yes \
--forge-url "$FORGE_URL" \
--repo-root "/tmp/smoke-test-repo" 2>&1 | grep -q "Duplicate service name 'agents-llama'"; then
pass "Duplicate service detection: correctly detected conflict between ENABLE_LLAMA_AGENT and [agents.llama]"
else
fail "Duplicate service detection: should have detected conflict between ENABLE_LLAMA_AGENT and [agents.llama]"
fi
# Clean up
rm -f "${FACTORY_ROOT}/projects/duplicate-test.toml"
unset ENABLE_LLAMA_AGENT
# ── Summary ──────────────────────────────────────────────────────────────────
echo ""
if [ "$FAILED" -ne 0 ]; then